Add and apply RSpec/BeNil rubocop rule
This rule was added in rubocop-rspec 2.9.0. We were using `be_nil` 50% of the time, and `be nil` the rest of the time. No strong preference for either one, but IMHO we don't lose anything be being consistent.
This commit is contained in:
@@ -467,6 +467,10 @@ RSpec/AroundBlock:
|
|||||||
RSpec/BeforeAfterAll:
|
RSpec/BeforeAfterAll:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
RSpec/BeNil:
|
||||||
|
Enabled: true
|
||||||
|
EnforcedStyle: be
|
||||||
|
|
||||||
RSpec/Capybara/CurrentPathExpectation:
|
RSpec/Capybara/CurrentPathExpectation:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe Management::SessionsController do
|
|||||||
|
|
||||||
expect(response).to redirect_to "/"
|
expect(response).to redirect_to "/"
|
||||||
expect(flash[:alert]).to eq "You do not have permission to access this page."
|
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
|
||||||
|
|
||||||
it "redirects to management root path if authorized manager with right credentials" do
|
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(response).to redirect_to "/"
|
||||||
expect(flash[:alert]).to eq "You do not have permission to access this page."
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -58,9 +58,9 @@ describe Management::SessionsController do
|
|||||||
|
|
||||||
delete :destroy
|
delete :destroy
|
||||||
|
|
||||||
expect(session[:manager]).to be_nil
|
expect(session[:manager]).to be nil
|
||||||
expect(session[:document_type]).to be_nil
|
expect(session[:document_type]).to be nil
|
||||||
expect(session[:document_number]).to be_nil
|
expect(session[:document_number]).to be nil
|
||||||
expect(response).to be_redirect
|
expect(response).to be_redirect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ describe Management::UsersController do
|
|||||||
get :logout
|
get :logout
|
||||||
|
|
||||||
expect(session[:manager]).to eq(user_key: "31415926", date: "20151031135905", login: "JJB033")
|
expect(session[:manager]).to eq(user_key: "31415926", date: "20151031135905", login: "JJB033")
|
||||||
expect(session[:document_type]).to be_nil
|
expect(session[:document_type]).to be nil
|
||||||
expect(session[:document_number]).to be_nil
|
expect(session[:document_number]).to be nil
|
||||||
expect(response).to be_redirect
|
expect(response).to be_redirect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require "rails_helper"
|
|||||||
describe Age do
|
describe Age do
|
||||||
describe ".in_years" do
|
describe ".in_years" do
|
||||||
it "handles nils" do
|
it "handles nils" do
|
||||||
expect(Age.in_years(nil)).to be_nil
|
expect(Age.in_years(nil)).to be nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calculates age correctly for common dates" do
|
it "calculates age correctly for common dates" do
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ describe AdminNotification do
|
|||||||
|
|
||||||
describe "#complete_link_url" do
|
describe "#complete_link_url" do
|
||||||
it "does not change link if there is no value" 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
|
end
|
||||||
|
|
||||||
it "fixes a link without http://" do
|
it "fixes a link without http://" do
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ describe Budget::ContentBlock do
|
|||||||
it "returns nil on new records without heading" do
|
it "returns nil on new records without heading" do
|
||||||
block = Budget::ContentBlock.new
|
block = Budget::ContentBlock.new
|
||||||
|
|
||||||
expect(block.name).to be_nil
|
expect(block.name).to be nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -956,7 +956,7 @@ describe Budget::Investment do
|
|||||||
|
|
||||||
it "accepts valid selections when selecting is allowed" do
|
it "accepts valid selections when selecting is allowed" do
|
||||||
budget.phase = "selecting"
|
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
|
end
|
||||||
|
|
||||||
it "rejects votes in two headings of the same group" do
|
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
|
it "accepts valid ballots when voting is allowed" do
|
||||||
budget.phase = "balloting"
|
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
|
end
|
||||||
|
|
||||||
it "accepts valid selections" do
|
it "accepts valid selections" do
|
||||||
budget.phase = "selecting"
|
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
|
end
|
||||||
|
|
||||||
it "rejects users with different headings" do
|
it "rejects users with different headings" do
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ shared_examples_for "has_public_author" do
|
|||||||
author = create(:user, public_activity: false)
|
author = create(:user, public_activity: false)
|
||||||
authored_element = create(model.to_s.underscore.to_sym, author: author)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ describe Legislation::Question do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns nil" do
|
it "returns nil" do
|
||||||
expect(question2.next_question_id).to be_nil
|
expect(question2.next_question_id).to be nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ describe LocalCensusRecords::Import do
|
|||||||
import.save!
|
import.save!
|
||||||
local_census_record = LocalCensusRecord.find_by(document_number: "X11556678")
|
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_type).to eq("2")
|
||||||
expect(local_census_record.document_number).to eq("X11556678")
|
expect(local_census_record.document_number).to eq("X11556678")
|
||||||
expect(local_census_record.date_of_birth).to eq(Date.parse("07/08/1987"))
|
expect(local_census_record.date_of_birth).to eq(Date.parse("07/08/1987"))
|
||||||
|
|||||||
@@ -6,22 +6,22 @@ describe SearchCache do
|
|||||||
debate = create(:debate)
|
debate = create(:debate)
|
||||||
debate.update_column(:tsv, nil)
|
debate.update_column(:tsv, nil)
|
||||||
|
|
||||||
expect(debate.reload.tsv).to be_nil
|
expect(debate.reload.tsv).to be nil
|
||||||
|
|
||||||
debate.calculate_tsvector
|
debate.calculate_tsvector
|
||||||
|
|
||||||
expect(debate.reload.tsv).not_to be_nil
|
expect(debate.reload.tsv).not_to be nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calculates the tsv column of a hidden record" do
|
it "calculates the tsv column of a hidden record" do
|
||||||
debate = create(:debate, :hidden)
|
debate = create(:debate, :hidden)
|
||||||
debate.update_column(:tsv, nil)
|
debate.update_column(:tsv, nil)
|
||||||
|
|
||||||
expect(debate.reload.tsv).to be_nil
|
expect(debate.reload.tsv).to be nil
|
||||||
|
|
||||||
debate.calculate_tsvector
|
debate.calculate_tsvector
|
||||||
|
|
||||||
expect(debate.reload.tsv).not_to be_nil
|
expect(debate.reload.tsv).not_to be nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ describe Setting do
|
|||||||
|
|
||||||
Setting.add_new_settings
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ describe Setting do
|
|||||||
Setting.add_new_settings
|
Setting.add_new_settings
|
||||||
|
|
||||||
expect(Setting.where(key: :stub)).not_to be_empty
|
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
|
end
|
||||||
|
|
||||||
it "doesn't modify custom values" do
|
it "doesn't modify custom values" do
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ describe User do
|
|||||||
subject.remove_official_position!
|
subject.remove_official_position!
|
||||||
|
|
||||||
expect(subject).not_to be_official
|
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)
|
expect(subject.official_level).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -508,16 +508,16 @@ describe User do
|
|||||||
expect(user.erase_reason).to eq("a test")
|
expect(user.erase_reason).to eq("a test")
|
||||||
expect(user.erased_at).to be
|
expect(user.erased_at).to be
|
||||||
|
|
||||||
expect(user.username).to be_nil
|
expect(user.username).to be nil
|
||||||
expect(user.email).to be_nil
|
expect(user.email).to be nil
|
||||||
expect(user.unconfirmed_email).to be_nil
|
expect(user.unconfirmed_email).to be nil
|
||||||
expect(user.phone_number).to be_nil
|
expect(user.phone_number).to be nil
|
||||||
expect(user.confirmed_phone).to be_nil
|
expect(user.confirmed_phone).to be nil
|
||||||
expect(user.unconfirmed_phone).to be_nil
|
expect(user.unconfirmed_phone).to be nil
|
||||||
expect(user.encrypted_password).to be_empty
|
expect(user.encrypted_password).to be_empty
|
||||||
expect(user.confirmation_token).to be_nil
|
expect(user.confirmation_token).to be nil
|
||||||
expect(user.reset_password_token).to be_nil
|
expect(user.reset_password_token).to be nil
|
||||||
expect(user.email_verification_token).to be_nil
|
expect(user.email_verification_token).to be nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "maintains associated identification document" do
|
it "maintains associated identification document" do
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ describe Verification::Management::Email do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns nil/false when the user does not exist" do
|
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
|
expect(subject.user?).not_to be
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ describe "Home" do
|
|||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
expect(page).to have_xpath(ie_alert_box_xpath)
|
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
|
# faking close button, since a normal find and click
|
||||||
# will not work as the element is inside a HTML conditional comment
|
# 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
|
scenario "non-IE visitors are not bothered with IE alerts", :page_driver do
|
||||||
visit root_path
|
visit root_path
|
||||||
expect(page).not_to have_xpath(ie_alert_box_xpath)
|
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
|
end
|
||||||
|
|
||||||
def ie_alert_box_xpath
|
def ie_alert_box_xpath
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ describe "Registration form" do
|
|||||||
|
|
||||||
new_user = User.last
|
new_user = User.last
|
||||||
expect(new_user.username).to eq("NewUserWithCode77")
|
expect(new_user.username).to eq("NewUserWithCode77")
|
||||||
expect(new_user.redeemable_code).to be_nil
|
expect(new_user.redeemable_code).to be nil
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Create with invisible_captcha honeypot field", :no_js do
|
scenario "Create with invisible_captcha honeypot field", :no_js do
|
||||||
|
|||||||
Reference in New Issue
Block a user