rubocop corrections

This commit is contained in:
Karol Selak 2021-03-22 03:16:29 +01:00
parent c63c6bc448
commit de29815686
72 changed files with 468 additions and 311 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ApplicationController do
@ -15,4 +17,4 @@ RSpec.describe ApplicationController do
describe 'logged_in?' do
# TODO
end
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe SessionsController do
@ -8,14 +10,14 @@ RSpec.describe SessionsController do
end
end
describe 'get create' do
# TODO test session status
# TODO: test session status
subject { get 'create' }
it 'redirects to /welcome' do
expect(subject).to redirect_to('/welcome')
end
end
describe 'get delete' do
# TODO test session status
# TODO: test session status
subject { get 'delete' }
it 'redirects to /welcome' do
expect(subject).to redirect_to('/welcome')
@ -27,4 +29,4 @@ RSpec.describe SessionsController do
expect(subject).to render_template('sessions/welcome')
end
end
end
end

View file

@ -1,7 +1,9 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UsersController do
before(:all) do # TODO change it to cleanup after each test
before(:all) do # TODO: change it to cleanup after each test
User.destroy_all
end
let(:user1) do
@ -15,7 +17,7 @@ RSpec.describe UsersController do
end
describe 'get create' do
subject do
get :create, params: {user: {email: 'test2@example.com', password: 'abcdefgh'}}
get :create, params: { user: { email: 'test2@example.com', password: 'abcdefgh' } }
end
it 'creates a user' do
subject
@ -34,13 +36,13 @@ RSpec.describe UsersController do
end
describe 'post password_recovery_request' do
subject do
get :password_recovery_request, params: {email: user1.email}
get :password_recovery_request, params: { email: user1.email }
end
it 'sends the proper recovery email' do
srand(10)
subject
email_text = ActionMailer::Base.deliveries.last.body.raw_source
expect(email_text).to match("recover_password/#{user1.id}/tfohbclx")
expect(email_text).to match("recover_password/#{user1.id}/jeravuxl")
end
it 'sends a recovery email to the proper email' do
subject
@ -53,7 +55,7 @@ RSpec.describe UsersController do
end
describe 'get recover_password_form' do
subject do
get :recover_password_form, params: {id: user1.id, recovery_password: 'recovery password'}
get :recover_password_form, params: { id: user1.id, recovery_password: 'recovery password' }
end
it 'renders proper form' do
subject
@ -104,4 +106,4 @@ RSpec.describe UsersController do
end
end
end
end
end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
# Preview all emails at http://localhost:3000/rails/mailers/user
class UserMailerPreview < ActionMailer::Preview
end

View file

@ -1,4 +1,6 @@
require "rails_helper"
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UserMailer, type: :mailer do
# TODO

View file

@ -1,9 +1,11 @@
# frozen_string_literal: true
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
@ -44,53 +46,51 @@ RSpec.configure do |config|
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# This allows you to limit a spec run to individual examples or groups
# you care about by tagging them with `:focus` metadata. When nothing
# is tagged with `:focus`, all examples get run. RSpec also provides
# aliases for `it`, `describe`, and `context` that include `:focus`
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
config.filter_run_when_matching :focus
# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
config.example_status_persistence_file_path = "spec/examples.txt"
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
config.disable_monkey_patching!
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = "doc"
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
=end
end
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
# # This allows you to limit a spec run to individual examples or groups
# # you care about by tagging them with `:focus` metadata. When nothing
# # is tagged with `:focus`, all examples get run. RSpec also provides
# # aliases for `it`, `describe`, and `context` that include `:focus`
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
# config.filter_run_when_matching :focus
#
# # Allows RSpec to persist some state between runs in order to support
# # the `--only-failures` and `--next-failure` CLI options. We recommend
# # you configure your source control system to ignore this file.
# config.example_status_persistence_file_path = "spec/examples.txt"
#
# # Limits the available syntax to the non-monkey patched syntax that is
# # recommended. For more details, see:
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
# config.disable_monkey_patching!
#
# # Many RSpec users commonly either run the entire suite or an individual
# # file, and it's useful to allow more verbose output when running an
# # individual spec file.
# if config.files_to_run.one?
# # Use the documentation formatter for detailed output,
# # unless a formatter has already been configured
# # (e.g. via a command-line flag).
# config.default_formatter = "doc"
# end
#
# # Print the 10 slowest examples and example groups at the
# # end of the spec run, to help surface which specs are running
# # particularly slow.
# config.profile_examples = 10
#
# # Run specs in random order to surface order dependencies. If you find an
# # order dependency and want to debug it, you can fix the order by providing
# # the seed, which is printed after each run.
# # --seed 1234
# config.order = :random
#
# # Seed global randomization in this process using the `--seed` CLI option.
# # Setting this allows you to use `--seed` to deterministically reproduce
# # test failures related to randomization by passing the same `--seed` value
# # as the one that triggered the failure.
# Kernel.srand config.seed
end