Apply explict RSpec/DescribedClass rubocop rule

We settled on using this style in commit 4cbe81a1, but didn't add the
rule enforcing this style and we didn't apply it to existing code.
This commit is contained in:
Javi Martín
2019-09-21 11:34:41 +02:00
parent 1faa659c89
commit ffc50246c2
48 changed files with 445 additions and 441 deletions

View File

@@ -18,9 +18,9 @@ describe Poll::Booth do
booth1 = create(:poll_booth, name: "Booth number 1", location: "City center")
booth2 = create(:poll_booth, name: "Central", location: "Town hall")
expect(described_class.search("number")).to eq([booth1])
expect(described_class.search("hall")).to eq([booth2])
expect(described_class.search("cen").size).to eq 2
expect(Poll::Booth.search("number")).to eq([booth1])
expect(Poll::Booth.search("hall")).to eq([booth2])
expect(Poll::Booth.search("cen").size).to eq 2
end
end
@@ -36,8 +36,8 @@ describe Poll::Booth do
create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll)
create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll)
expect(described_class.available).to include(booth_for_current_poll)
expect(described_class.available).not_to include(booth_for_expired_poll)
expect(Poll::Booth.available).to include(booth_for_current_poll)
expect(Poll::Booth.available).not_to include(booth_for_expired_poll)
end
it "returns polls with multiple translations only once" do

View File

@@ -54,8 +54,8 @@ describe Poll::PairAnswer do
it "returns pair_answers associated to an user" do
author = pair_answer_1.author
expect(described_class.by_author(author)).to include(pair_answer_1)
expect(described_class.by_author(author)).not_to include(pair_answer_2)
expect(Poll::PairAnswer.by_author(author)).to include(pair_answer_1)
expect(Poll::PairAnswer.by_author(author)).not_to include(pair_answer_2)
end
end
@@ -65,8 +65,8 @@ describe Poll::PairAnswer do
it "returns pair_answers associated to a question" do
question = pair_answer_1.question
expect(described_class.by_question(question)).to include(pair_answer_1)
expect(described_class.by_question(question)).not_to include(pair_answer_2)
expect(Poll::PairAnswer.by_question(question)).to include(pair_answer_1)
expect(Poll::PairAnswer.by_question(question)).not_to include(pair_answer_2)
end
end
@@ -79,7 +79,7 @@ describe Poll::PairAnswer do
context "without question_answers" do
it "assigns nil value to pair_answers" do
pair_answer = described_class.generate_pair(question, user)
pair_answer = Poll::PairAnswer.generate_pair(question, user)
expect(pair_answer).to be_a Poll::PairAnswer
expect(pair_answer.question).to eq(question)
@@ -93,7 +93,7 @@ describe Poll::PairAnswer do
let!(:answer1) { create(:poll_question_answer, question: question) }
it "assigns only right question if only has one question_answer" do
pair_answer = described_class.generate_pair(question, user)
pair_answer = Poll::PairAnswer.generate_pair(question, user)
expect(pair_answer).to be_a Poll::PairAnswer
expect(pair_answer.question).to eq(question)
@@ -105,7 +105,7 @@ describe Poll::PairAnswer do
it "assigns random values if question has some question_answer" do
create(:poll_question_answer, question: question)
pair_answer = described_class.generate_pair(question, user)
pair_answer = Poll::PairAnswer.generate_pair(question, user)
expect(pair_answer).to be_a Poll::PairAnswer
expect(pair_answer.question).to eq(question)

View File

@@ -116,7 +116,7 @@ describe Poll do
expired = create(:poll, :expired)
recounting = create(:poll, :recounting)
recounting_polls = described_class.recounting
recounting_polls = Poll.recounting
expect(recounting_polls).not_to include(current)
expect(recounting_polls).not_to include(expired)
@@ -130,7 +130,7 @@ describe Poll do
expired = create(:poll, :expired)
recounting = create(:poll, :recounting)
current_or_recounting = described_class.current_or_recounting
current_or_recounting = Poll.current_or_recounting
expect(current_or_recounting).to include(current)
expect(current_or_recounting).to include(recounting)
@@ -186,16 +186,16 @@ describe Poll do
describe "class method" do
it "returns no polls for non-users and level 1 users" do
expect(described_class.answerable_by(nil)).to be_empty
expect(described_class.answerable_by(level1)).to be_empty
expect(Poll.answerable_by(nil)).to be_empty
expect(Poll.answerable_by(level1)).to be_empty
end
it "returns unrestricted polls for level 2 users" do
expect(described_class.answerable_by(level2).to_a).to eq([current_poll])
expect(Poll.answerable_by(level2).to_a).to eq([current_poll])
end
it "returns restricted & unrestricted polls for level 2 users of the correct geozone" do
list = described_class.answerable_by(level2_from_geozone)
list = Poll.answerable_by(level2_from_geozone)
.order(:geozone_restricted)
expect(list.to_a).to eq([current_poll, current_restricted_poll])
end

View File

@@ -81,7 +81,7 @@ describe Poll::Shift do
create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment1, date: Date.tomorrow)
expect { described_class.last.destroy }.to change { Poll::OfficerAssignment.all.count }.by(-2)
expect { Poll::Shift.last.destroy }.to change { Poll::OfficerAssignment.all.count }.by(-2)
end
it "creates final officer_assignments" do

View File

@@ -139,7 +139,7 @@ describe Poll::Voter do
voter2 = create(:poll_voter, :from_web)
voter3 = create(:poll_voter, :from_booth)
web_voters = described_class.web
web_voters = Poll::Voter.web
expect(web_voters.count).to eq(2)
expect(web_voters).to include(voter1)
@@ -154,7 +154,7 @@ describe Poll::Voter do
voter2 = create(:poll_voter, :from_booth)
voter3 = create(:poll_voter, :from_web)
booth_voters = described_class.booth
booth_voters = Poll::Voter.booth
expect(booth_voters.count).to eq(2)
expect(booth_voters).to include(voter1)