diff --git a/.rubocop.yml b/.rubocop.yml index 05efb4830..de96c2b1d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -467,6 +467,10 @@ RSpec/AroundBlock: RSpec/BeforeAfterAll: Enabled: true +RSpec/BeNil: + Enabled: true + EnforcedStyle: be + RSpec/Capybara/CurrentPathExpectation: Enabled: true diff --git a/spec/controllers/management/sessions_controller_spec.rb b/spec/controllers/management/sessions_controller_spec.rb index 76e1cb4ee..be4338f70 100644 --- a/spec/controllers/management/sessions_controller_spec.rb +++ b/spec/controllers/management/sessions_controller_spec.rb @@ -8,7 +8,7 @@ describe Management::SessionsController do expect(response).to redirect_to "/" expect(flash[:alert]).to eq "You do not have permission to access this page." - expect(session[:manager]).to be_nil + expect(session[:manager]).to be nil end it "redirects to management root path if authorized manager with right credentials" do @@ -46,7 +46,7 @@ describe Management::SessionsController do expect(response).to redirect_to "/" expect(flash[:alert]).to eq "You do not have permission to access this page." - expect(session[:manager]).to be_nil + expect(session[:manager]).to be nil end end @@ -58,9 +58,9 @@ describe Management::SessionsController do delete :destroy - expect(session[:manager]).to be_nil - expect(session[:document_type]).to be_nil - expect(session[:document_number]).to be_nil + expect(session[:manager]).to be nil + expect(session[:document_type]).to be nil + expect(session[:document_number]).to be nil expect(response).to be_redirect end end diff --git a/spec/controllers/management/users_controller_spec.rb b/spec/controllers/management/users_controller_spec.rb index 78f80a6b0..a4a0e4523 100644 --- a/spec/controllers/management/users_controller_spec.rb +++ b/spec/controllers/management/users_controller_spec.rb @@ -10,8 +10,8 @@ describe Management::UsersController do get :logout expect(session[:manager]).to eq(user_key: "31415926", date: "20151031135905", login: "JJB033") - expect(session[:document_type]).to be_nil - expect(session[:document_number]).to be_nil + expect(session[:document_type]).to be nil + expect(session[:document_number]).to be nil expect(response).to be_redirect end end diff --git a/spec/lib/age_spec.rb b/spec/lib/age_spec.rb index e72b3f531..38d8821fc 100644 --- a/spec/lib/age_spec.rb +++ b/spec/lib/age_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" describe Age do describe ".in_years" do it "handles nils" do - expect(Age.in_years(nil)).to be_nil + expect(Age.in_years(nil)).to be nil end it "calculates age correctly for common dates" do diff --git a/spec/models/admin_notification_spec.rb b/spec/models/admin_notification_spec.rb index 3046f38da..c406c79dd 100644 --- a/spec/models/admin_notification_spec.rb +++ b/spec/models/admin_notification_spec.rb @@ -26,7 +26,7 @@ describe AdminNotification do describe "#complete_link_url" do it "does not change link if there is no value" do - expect(admin_notification.link).to be_nil + expect(admin_notification.link).to be nil end it "fixes a link without http://" do diff --git a/spec/models/budget/content_block_spec.rb b/spec/models/budget/content_block_spec.rb index e8d1e4d28..9c54ffb24 100644 --- a/spec/models/budget/content_block_spec.rb +++ b/spec/models/budget/content_block_spec.rb @@ -30,7 +30,7 @@ describe Budget::ContentBlock do it "returns nil on new records without heading" do block = Budget::ContentBlock.new - expect(block.name).to be_nil + expect(block.name).to be nil end end end diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 04ee16775..c6bf06024 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -956,7 +956,7 @@ describe Budget::Investment do it "accepts valid selections when selecting is allowed" do budget.phase = "selecting" - expect(district_sp.reason_for_not_being_selectable_by(user)).to be_nil + expect(district_sp.reason_for_not_being_selectable_by(user)).to be nil end it "rejects votes in two headings of the same group" do @@ -1174,12 +1174,12 @@ describe Budget::Investment do it "accepts valid ballots when voting is allowed" do budget.phase = "balloting" - expect(investment.reason_for_not_being_ballotable_by(user, ballot)).to be_nil + expect(investment.reason_for_not_being_ballotable_by(user, ballot)).to be nil end it "accepts valid selections" do budget.phase = "selecting" - expect(investment.reason_for_not_being_selectable_by(user)).to be_nil + expect(investment.reason_for_not_being_selectable_by(user)).to be nil end it "rejects users with different headings" do diff --git a/spec/models/concerns/has_public_author.rb b/spec/models/concerns/has_public_author.rb index 13dcf72ac..75b346211 100644 --- a/spec/models/concerns/has_public_author.rb +++ b/spec/models/concerns/has_public_author.rb @@ -15,7 +15,7 @@ shared_examples_for "has_public_author" do author = create(:user, public_activity: false) authored_element = create(model.to_s.underscore.to_sym, author: author) - expect(authored_element.public_author).to be_nil + expect(authored_element.public_author).to be nil end end end diff --git a/spec/models/legislation/question_spec.rb b/spec/models/legislation/question_spec.rb index d710415ea..90699b3a8 100644 --- a/spec/models/legislation/question_spec.rb +++ b/spec/models/legislation/question_spec.rb @@ -55,7 +55,7 @@ describe Legislation::Question do end it "returns nil" do - expect(question2.next_question_id).to be_nil + expect(question2.next_question_id).to be nil end end diff --git a/spec/models/local_census_records/import_spec.rb b/spec/models/local_census_records/import_spec.rb index 67a04cdf6..f89aa0b4b 100644 --- a/spec/models/local_census_records/import_spec.rb +++ b/spec/models/local_census_records/import_spec.rb @@ -48,7 +48,7 @@ describe LocalCensusRecords::Import do import.save! local_census_record = LocalCensusRecord.find_by(document_number: "X11556678") - expect(local_census_record).not_to be_nil + expect(local_census_record).not_to be nil expect(local_census_record.document_type).to eq("2") expect(local_census_record.document_number).to eq("X11556678") expect(local_census_record.date_of_birth).to eq(Date.parse("07/08/1987")) diff --git a/spec/models/search_cache_spec.rb b/spec/models/search_cache_spec.rb index 03dc09368..95924730c 100644 --- a/spec/models/search_cache_spec.rb +++ b/spec/models/search_cache_spec.rb @@ -6,22 +6,22 @@ describe SearchCache do debate = create(:debate) debate.update_column(:tsv, nil) - expect(debate.reload.tsv).to be_nil + expect(debate.reload.tsv).to be nil debate.calculate_tsvector - expect(debate.reload.tsv).not_to be_nil + expect(debate.reload.tsv).not_to be nil end it "calculates the tsv column of a hidden record" do debate = create(:debate, :hidden) debate.update_column(:tsv, nil) - expect(debate.reload.tsv).to be_nil + expect(debate.reload.tsv).to be nil debate.calculate_tsvector - expect(debate.reload.tsv).not_to be_nil + expect(debate.reload.tsv).not_to be nil end end end diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 22b0ebfe1..fafd06481 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -250,7 +250,7 @@ describe Setting do Setting.add_new_settings - expect(Setting.find_by(key: :stub).value).to be_nil + expect(Setting.find_by(key: :stub).value).to be nil end end @@ -265,7 +265,7 @@ describe Setting do Setting.add_new_settings expect(Setting.where(key: :stub)).not_to be_empty - expect(Setting.find_by(key: :stub).value).to be_nil + expect(Setting.find_by(key: :stub).value).to be nil end it "doesn't modify custom values" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 50106de69..a46e104e0 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -286,7 +286,7 @@ describe User do subject.remove_official_position! expect(subject).not_to be_official - expect(subject.official_position).to be_nil + expect(subject.official_position).to be nil expect(subject.official_level).to eq(0) end end @@ -508,16 +508,16 @@ describe User do expect(user.erase_reason).to eq("a test") expect(user.erased_at).to be - expect(user.username).to be_nil - expect(user.email).to be_nil - expect(user.unconfirmed_email).to be_nil - expect(user.phone_number).to be_nil - expect(user.confirmed_phone).to be_nil - expect(user.unconfirmed_phone).to be_nil + expect(user.username).to be nil + expect(user.email).to be nil + expect(user.unconfirmed_email).to be nil + expect(user.phone_number).to be nil + expect(user.confirmed_phone).to be nil + expect(user.unconfirmed_phone).to be nil expect(user.encrypted_password).to be_empty - expect(user.confirmation_token).to be_nil - expect(user.reset_password_token).to be_nil - expect(user.email_verification_token).to be_nil + expect(user.confirmation_token).to be nil + expect(user.reset_password_token).to be nil + expect(user.email_verification_token).to be nil end it "maintains associated identification document" do diff --git a/spec/models/verification/management/email_spec.rb b/spec/models/verification/management/email_spec.rb index 91d1c62f8..4921a5021 100644 --- a/spec/models/verification/management/email_spec.rb +++ b/spec/models/verification/management/email_spec.rb @@ -9,7 +9,7 @@ describe Verification::Management::Email do end it "returns nil/false when the user does not exist" do - expect(subject.user).to be_nil + expect(subject.user).to be nil expect(subject.user?).not_to be end end diff --git a/spec/system/home_spec.rb b/spec/system/home_spec.rb index f74659a07..053cef2ee 100644 --- a/spec/system/home_spec.rb +++ b/spec/system/home_spec.rb @@ -116,7 +116,7 @@ describe "Home" do visit root_path expect(page).to have_xpath(ie_alert_box_xpath) - expect(page.driver.request.cookies["ie_alert_closed"]).to be_nil + expect(page.driver.request.cookies["ie_alert_closed"]).to be nil # faking close button, since a normal find and click # will not work as the element is inside a HTML conditional comment @@ -130,7 +130,7 @@ describe "Home" do scenario "non-IE visitors are not bothered with IE alerts", :page_driver do visit root_path expect(page).not_to have_xpath(ie_alert_box_xpath) - expect(page.driver.request.cookies["ie_alert_closed"]).to be_nil + expect(page.driver.request.cookies["ie_alert_closed"]).to be nil end def ie_alert_box_xpath diff --git a/spec/system/registration_form_spec.rb b/spec/system/registration_form_spec.rb index a9e018ee1..ab7df5ce2 100644 --- a/spec/system/registration_form_spec.rb +++ b/spec/system/registration_form_spec.rb @@ -55,7 +55,7 @@ describe "Registration form" do new_user = User.last expect(new_user.username).to eq("NewUserWithCode77") - expect(new_user.redeemable_code).to be_nil + expect(new_user.redeemable_code).to be nil end scenario "Create with invisible_captcha honeypot field", :no_js do