diff --git a/spec/lib/acts_as_taggable_on_spec.rb b/spec/lib/acts_as_taggable_on_spec.rb index 6ea488f79..9ea565387 100644 --- a/spec/lib/acts_as_taggable_on_spec.rb +++ b/spec/lib/acts_as_taggable_on_spec.rb @@ -73,7 +73,7 @@ describe ActsAsTaggableOn do proposal.tag_list.add(tag) proposal.save - expect(ActsAsTaggableOn::Tag.public_for_api).to include(tag) + expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag] end it "returns tags whose kind is 'category' and have at least one tagging whose taggable is not hidden" do @@ -82,7 +82,7 @@ describe ActsAsTaggableOn do proposal.tag_list.add(tag) proposal.save - expect(ActsAsTaggableOn::Tag.public_for_api).to include(tag) + expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag] end it "blocks other kinds of tags" do @@ -126,7 +126,7 @@ describe ActsAsTaggableOn do proposal.tag_list.add(tag) proposal.save - expect(ActsAsTaggableOn::Tag.public_for_api).to include(tag) + expect(ActsAsTaggableOn::Tag.public_for_api).to eq [tag] proposal.delete diff --git a/spec/lib/email_digests_spec.rb b/spec/lib/email_digests_spec.rb index dea0abf21..af70ede35 100644 --- a/spec/lib/email_digests_spec.rb +++ b/spec/lib/email_digests_spec.rb @@ -14,7 +14,7 @@ describe EmailDigest do email_digest = EmailDigest.new(user1) - expect(email_digest.notifications).to include(notification1) + expect(email_digest.notifications).to eq [notification1] expect(email_digest.notifications).not_to include(notification2) end @@ -29,7 +29,7 @@ describe EmailDigest do email_digest = EmailDigest.new(user) - expect(email_digest.notifications).to include(notification1) + expect(email_digest.notifications).to eq [notification1] expect(email_digest.notifications).not_to include(notification2) end diff --git a/spec/lib/user_segments_spec.rb b/spec/lib/user_segments_spec.rb index e4bc6d6ae..8344a41a1 100644 --- a/spec/lib/user_segments_spec.rb +++ b/spec/lib/user_segments_spec.rb @@ -10,7 +10,7 @@ describe UserSegments do active_user = create(:user) erased_user = create(:user, erased_at: Time.current) - expect(UserSegments.all_users).to include active_user + expect(UserSegments.all_users).to eq [active_user] expect(UserSegments.all_users).not_to include erased_user end end @@ -21,7 +21,7 @@ describe UserSegments do active_admin = create(:administrator).user erased_user = create(:user, erased_at: Time.current) - expect(UserSegments.administrators).to include active_admin + expect(UserSegments.administrators).to eq [active_admin] expect(UserSegments.administrators).not_to include active_user expect(UserSegments.administrators).not_to include erased_user end @@ -34,9 +34,8 @@ describe UserSegments do create(:proposal, :retired, author: user3) all_proposal_authors = UserSegments.all_proposal_authors - expect(all_proposal_authors).to include user1 - expect(all_proposal_authors).to include user2 - expect(all_proposal_authors).to include user3 + + expect(all_proposal_authors).to match_array [user1, user2, user3] end it "does not return duplicated users" do @@ -55,8 +54,8 @@ describe UserSegments do create(:proposal, author: user1) proposal_authors = UserSegments.proposal_authors - expect(proposal_authors).to include user1 - expect(proposal_authors).not_to include user2 + + expect(proposal_authors).to eq [user1] end it "does not return duplicated users" do @@ -75,8 +74,8 @@ describe UserSegments do investment.update(budget: budget) investment_authors = UserSegments.investment_authors - expect(investment_authors).to include user1 - expect(investment_authors).not_to include user2 + + expect(investment_authors).to eq [user1] end it "does not return duplicated users" do @@ -113,11 +112,7 @@ describe UserSegments do unfeasible_investment_finished.update(budget: budget) investment_authors = UserSegments.feasible_and_undecided_investment_authors - expect(investment_authors).to include user1 - expect(investment_authors).to include user2 - expect(investment_authors).to include user3 - expect(investment_authors).to include user4 - expect(investment_authors).to include user5 + expect(investment_authors).to match_array [user1, user2, user3, user4, user5] expect(investment_authors).not_to include user6 end @@ -142,8 +137,8 @@ describe UserSegments do unselected_investment.update(budget: budget) investment_authors = UserSegments.selected_investment_authors - expect(investment_authors).to include user1 - expect(investment_authors).not_to include user2 + + expect(investment_authors).to eq [user1] end it "does not return duplicated users" do @@ -167,8 +162,8 @@ describe UserSegments do selected_investment.update(budget: budget) investment_authors = UserSegments.winner_investment_authors - expect(investment_authors).to include user1 - expect(investment_authors).not_to include user2 + + expect(investment_authors).to eq [user1] end it "does not return duplicated users" do @@ -191,7 +186,8 @@ describe UserSegments do investment1.update(budget: budget) current_budget_investments = UserSegments.current_budget_investments - expect(current_budget_investments).to include investment1 + + expect(current_budget_investments).to eq [investment1] expect(current_budget_investments).not_to include investment2 end end diff --git a/spec/models/budget/ballot/line_spec.rb b/spec/models/budget/ballot/line_spec.rb index e9010e04f..3ba4ca97a 100644 --- a/spec/models/budget/ballot/line_spec.rb +++ b/spec/models/budget/ballot/line_spec.rb @@ -75,8 +75,7 @@ describe Budget::Ballot::Line do ballot_lines_by_investment = Budget::Ballot::Line.by_investment(investment1.id) - expect(ballot_lines_by_investment).to include ballot_line1 - expect(ballot_lines_by_investment).to include ballot_line2 + expect(ballot_lines_by_investment).to match_array [ballot_line1, ballot_line2] expect(ballot_lines_by_investment).not_to include ballot_line3 end diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 071a68731..ebd984d15 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -319,8 +319,7 @@ describe Budget::Investment do investments_by_budget = Budget::Investment.by_budget(budget1) - expect(investments_by_budget).to include investment1 - expect(investments_by_budget).to include investment2 + expect(investments_by_budget).to match_array [investment1, investment2] expect(investments_by_budget).not_to include investment3 end end @@ -656,8 +655,7 @@ describe Budget::Investment do results = Budget::Investment.apply_filters_and_search(budget, search: "health") - expect(results).to include investment1 - expect(results).to include investment2 + expect(results).to match_array [investment1, investment2] expect(results).not_to include investment3 end end @@ -935,7 +933,7 @@ describe Budget::Investment do inv2 = create(:budget_investment) create(:vote, votable: inv1) - expect(Budget::Investment.with_supports).to include(inv1) + expect(Budget::Investment.with_supports).to eq [inv1] expect(Budget::Investment.with_supports).not_to include(inv2) end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index d797a1b8c..01fe265ec 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -139,7 +139,7 @@ describe Comment do it "returns comments" do comment = create(:comment) - expect(Comment.public_for_api).to include(comment) + expect(Comment.public_for_api).to eq [comment] end it "does not return hidden comments" do @@ -149,10 +149,9 @@ describe Comment do end it "returns comments on debates" do - debate = create(:debate) - comment = create(:comment, commentable: debate) + comment = create(:comment, commentable: create(:debate)) - expect(Comment.public_for_api).to include(comment) + expect(Comment.public_for_api).to eq [comment] end it "does not return comments on hidden debates" do @@ -166,7 +165,7 @@ describe Comment do proposal = create(:proposal) comment = create(:comment, commentable: proposal) - expect(Comment.public_for_api).to include(comment) + expect(Comment.public_for_api).to eq [comment] end it "does not return comments on hidden proposals" do diff --git a/spec/models/debate_spec.rb b/spec/models/debate_spec.rb index 7c9f0a084..eac4c2cf0 100644 --- a/spec/models/debate_spec.rb +++ b/spec/models/debate_spec.rb @@ -707,7 +707,8 @@ describe Debate do describe "#last_week" do it "returns debates created this week" do debate = create(:debate) - expect(Debate.last_week.all).to include debate + + expect(Debate.last_week.all).to eq [debate] end it "does not show debates created more than a week ago" do @@ -725,7 +726,8 @@ describe Debate do describe "public_for_api scope" do it "returns debates" do debate = create(:debate) - expect(Debate.public_for_api).to include(debate) + + expect(Debate.public_for_api).to eq [debate] end it "does not return hidden debates" do diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb index fdfa606f9..c09416925 100644 --- a/spec/models/legislation/process_spec.rb +++ b/spec/models/legislation/process_spec.rb @@ -114,9 +114,7 @@ describe Legislation::Process do it "filters past" do past_processes = ::Legislation::Process.past - expect(past_processes).to include(process_3) - expect(past_processes).not_to include(process_2) - expect(past_processes).not_to include(process_1) + expect(past_processes).to eq [process_3] end end diff --git a/spec/models/local_census_record_spec.rb b/spec/models/local_census_record_spec.rb index f1ba467ee..4f4beb854 100644 --- a/spec/models/local_census_record_spec.rb +++ b/spec/models/local_census_record_spec.rb @@ -59,7 +59,7 @@ describe LocalCensusRecord do context "search" do it "filter document_numbers by given terms" do - expect(LocalCensusRecord.search("A")).to include a_local_census_record + expect(LocalCensusRecord.search("A")).to eq [a_local_census_record] expect(LocalCensusRecord.search("A")).not_to include b_local_census_record end diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 2e796c46c..4ad6fcd6e 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -51,7 +51,7 @@ describe Milestone do published_in_application_time_zone = create(:milestone, publication_date: Date.current) - expect(Milestone.published).to include(published_in_application_time_zone) + expect(Milestone.published).to eq [published_in_application_time_zone] expect(Milestone.published).not_to include(published_in_local_time_zone) end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index d36fbbe5d..bd527d5d4 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -25,8 +25,7 @@ describe Notification do read_notification2 = create(:notification, :read) unread_notification = create(:notification) - expect(Notification.read).to include read_notification1 - expect(Notification.read).to include read_notification2 + expect(Notification.read).to match_array [read_notification1, read_notification2] expect(Notification.read).not_to include unread_notification end end @@ -37,8 +36,7 @@ describe Notification do unread_notification1 = create(:notification) unread_notification2 = create(:notification) - expect(Notification.unread).to include unread_notification1 - expect(Notification.unread).to include unread_notification2 + expect(Notification.unread).to match_array [unread_notification1, unread_notification2] expect(Notification.unread).not_to include read_notification end end diff --git a/spec/models/poll/booth_spec.rb b/spec/models/poll/booth_spec.rb index 19dc8e05d..95a9b7ad3 100644 --- a/spec/models/poll/booth_spec.rb +++ b/spec/models/poll/booth_spec.rb @@ -30,7 +30,7 @@ describe Poll::Booth do booth_for_current_poll = create(:poll_booth, polls: [create(:poll, :current)]) booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)]) - expect(Poll::Booth.available).to include(booth_for_current_poll) + expect(Poll::Booth.available).to eq [booth_for_current_poll] expect(Poll::Booth.available).not_to include(booth_for_expired_poll) end diff --git a/spec/models/poll/officer_spec.rb b/spec/models/poll/officer_spec.rb index fd2165862..f494ed84e 100644 --- a/spec/models/poll/officer_spec.rb +++ b/spec/models/poll/officer_spec.rb @@ -140,7 +140,7 @@ describe Poll::Officer do date: Date.current, officer: officer) - expect(officer.todays_booths).to include(assignment_with_application_time_zone.booth) + expect(officer.todays_booths).to eq [assignment_with_application_time_zone.booth] expect(officer.todays_booths).not_to include(assignment_with_local_time_zone.booth) end end diff --git a/spec/models/poll/pair_answer_spec.rb b/spec/models/poll/pair_answer_spec.rb index 008ab39e5..78b8fba1b 100644 --- a/spec/models/poll/pair_answer_spec.rb +++ b/spec/models/poll/pair_answer_spec.rb @@ -54,8 +54,7 @@ describe Poll::PairAnswer do it "returns pair_answers associated to an user" do author = pair_answer_1.author - expect(Poll::PairAnswer.by_author(author)).to include(pair_answer_1) - expect(Poll::PairAnswer.by_author(author)).not_to include(pair_answer_2) + expect(Poll::PairAnswer.by_author(author)).to eq [pair_answer_1] end end @@ -65,8 +64,7 @@ describe Poll::PairAnswer do it "returns pair_answers associated to a question" do question = pair_answer_1.question - expect(Poll::PairAnswer.by_question(question)).to include(pair_answer_1) - expect(Poll::PairAnswer.by_question(question)).not_to include(pair_answer_2) + expect(Poll::PairAnswer.by_question(question)).to eq [pair_answer_1] end end diff --git a/spec/models/poll/poll_spec.rb b/spec/models/poll/poll_spec.rb index 21c05f46c..3efc6704c 100644 --- a/spec/models/poll/poll_spec.rb +++ b/spec/models/poll/poll_spec.rb @@ -212,9 +212,7 @@ describe Poll do create(:poll_voter, user: user, poll: poll1) - expect(Poll.votable_by(user)).to include(poll2) - expect(Poll.votable_by(user)).to include(poll3) - expect(Poll.votable_by(user)).not_to include(poll1) + expect(Poll.votable_by(user)).to match_array [poll2, poll3] end it "returns polls that are answerable by a user" do @@ -224,7 +222,7 @@ describe Poll do allow(Poll).to receive(:answerable_by).and_return(Poll.where(id: poll1)) - expect(Poll.votable_by(user)).to include(poll1) + expect(Poll.votable_by(user)).to eq [poll1] expect(Poll.votable_by(user)).not_to include(poll2) end @@ -232,7 +230,7 @@ describe Poll do user = create(:user, :level_two) poll = create(:poll) - expect(Poll.votable_by(user)).to include(poll) + expect(Poll.votable_by(user)).to eq [poll] end end @@ -328,7 +326,7 @@ describe Poll do end it "returns overlaping polls for the same proposal" do - expect(Poll.overlaping_with(overlaping_poll)).to include(poll) + expect(Poll.overlaping_with(overlaping_poll)).to eq [poll] end it "do not returs non overlaping polls for the same proposal" do @@ -349,8 +347,7 @@ describe Poll do poll2 = create(:poll) poll3 = create(:poll, :for_budget) - expect(Poll.not_budget).to include(poll1) - expect(Poll.not_budget).to include(poll2) + expect(Poll.not_budget).to match_array [poll1, poll2] expect(Poll.not_budget).not_to include(poll3) end diff --git a/spec/models/proposal_notification_spec.rb b/spec/models/proposal_notification_spec.rb index c7f99b90a..4a765ed8f 100644 --- a/spec/models/proposal_notification_spec.rb +++ b/spec/models/proposal_notification_spec.rb @@ -24,10 +24,9 @@ describe ProposalNotification do describe "public_for_api scope" do it "returns proposal notifications" do - proposal = create(:proposal) - notification = create(:proposal_notification, proposal: proposal) + notification = create(:proposal_notification, proposal: create(:proposal)) - expect(ProposalNotification.public_for_api).to include(notification) + expect(ProposalNotification.public_for_api).to eq [notification] end it "blocks proposal notifications whose proposal is hidden" do diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index d7f79522d..d13736825 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -449,8 +449,7 @@ describe Proposal do create(:vote, voter: voter1, votable: proposal) create(:vote, voter: voter2, votable: proposal) - expect(proposal.voters).to include(voter1) - expect(proposal.voters).to include(voter2) + expect(proposal.voters).to match_array [voter1, voter2] expect(proposal.voters).not_to include(voter3) end @@ -463,8 +462,7 @@ describe Proposal do create(:vote, voter: voter2, votable: proposal) voter2.erase - expect(proposal.voters).to include(voter1) - expect(proposal.voters).not_to include(voter2) + expect(proposal.voters).to eq [voter1] end it "does not return users that have been blocked" do @@ -476,8 +474,7 @@ describe Proposal do create(:vote, voter: voter2, votable: proposal) voter2.block - expect(proposal.voters).to include(voter1) - expect(proposal.voters).not_to include(voter2) + expect(proposal.voters).to eq [voter1] end end @@ -743,7 +740,8 @@ describe Proposal do describe "#last_week" do it "returns proposals created this week" do proposal = create(:proposal) - expect(Proposal.last_week).to include(proposal) + + expect(Proposal.last_week).to eq [proposal] end it "does not return proposals created more than a week ago" do @@ -760,7 +758,7 @@ describe Proposal do create(:tag, :category, name: "culture") proposal = create(:proposal, tag_list: "culture") - expect(Proposal.for_summary.values.flatten).to include(proposal) + expect(Proposal.for_summary.values.flatten).to eq [proposal] end it "does not return proposals tagged without a category" do @@ -777,7 +775,7 @@ describe Proposal do california = create(:geozone, name: "california") proposal = create(:proposal, geozone: california) - expect(Proposal.for_summary.values.flatten).to include(proposal) + expect(Proposal.for_summary.values.flatten).to eq [proposal] end it "does not return proposals without a geozone" do @@ -791,7 +789,8 @@ describe Proposal do it "returns proposals created this week" do create(:tag, :category, name: "culture") proposal = create(:proposal, tag_list: "culture") - expect(Proposal.for_summary.values.flatten).to include(proposal) + + expect(Proposal.for_summary.values.flatten).to eq [proposal] end it "does not return proposals created more than a week ago" do @@ -904,7 +903,8 @@ describe Proposal do describe "public_for_api scope" do it "returns proposals" do proposal = create(:proposal) - expect(Proposal.public_for_api).to include(proposal) + + expect(Proposal.public_for_api).to eq [proposal] end it "does not return hidden proposals" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 03824e495..ad66de9a5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -390,8 +390,7 @@ describe User do user2 = create(:user, erased_at: nil) user3 = create(:user, erased_at: Time.current) - expect(User.active).to include(user1) - expect(User.active).to include(user2) + expect(User.active).to match_array [user1, user2] expect(User.active).not_to include(user3) end @@ -401,8 +400,7 @@ describe User do user3 = create(:user) user3.block - expect(User.active).to include(user1) - expect(User.active).to include(user2) + expect(User.active).to match_array [user1, user2] expect(User.active).not_to include(user3) end @@ -415,8 +413,7 @@ describe User do user2 = create(:user, erased_at: Time.current) user3 = create(:user, erased_at: nil) - expect(User.erased).to include(user1) - expect(User.erased).to include(user2) + expect(User.erased).to match_array [user1, user2] expect(User.erased).not_to include(user3) end diff --git a/spec/models/vote_spec.rb b/spec/models/vote_spec.rb index 6692c4f2d..5891a9941 100644 --- a/spec/models/vote_spec.rb +++ b/spec/models/vote_spec.rb @@ -46,7 +46,7 @@ describe Vote do debate = create(:debate) vote = create(:vote, votable: debate) - expect(Vote.public_for_api).to include(vote) + expect(Vote.public_for_api).to eq [vote] end it "blocks votes on hidden debates" do @@ -60,7 +60,7 @@ describe Vote do proposal = create(:proposal) vote = create(:vote, votable: proposal) - expect(Vote.public_for_api).to include(vote) + expect(Vote.public_for_api).to eq [vote] end it "blocks votes on hidden proposals" do @@ -74,7 +74,7 @@ describe Vote do comment = create(:comment) vote = create(:vote, votable: comment) - expect(Vote.public_for_api).to include(vote) + expect(Vote.public_for_api).to eq [vote] end it "blocks votes on hidden comments" do diff --git a/spec/models/widget/card_spec.rb b/spec/models/widget/card_spec.rb index 75c7dd3d4..cd563df56 100644 --- a/spec/models/widget/card_spec.rb +++ b/spec/models/widget/card_spec.rb @@ -31,8 +31,7 @@ describe Widget::Card do card2 = create(:widget_card, header: false) page_card = create(:widget_card, header: false, page: create(:site_customization_page)) - expect(Widget::Card.body).to include(card1) - expect(Widget::Card.body).to include(card2) + expect(Widget::Card.body).to match_array [card1, card2] expect(Widget::Card.body).not_to include(header) expect(Widget::Card.body).not_to include(page_card) end diff --git a/spec/support/verifiable.rb b/spec/support/verifiable.rb index 3548e700e..78c436a1b 100644 --- a/spec/support/verifiable.rb +++ b/spec/support/verifiable.rb @@ -7,7 +7,7 @@ shared_examples_for "verifiable" do user1 = create(:user, verified_at: Time.current) user2 = create(:user, verified_at: nil) - expect(model.level_three_verified).to include(user1) + expect(model.level_three_verified).to eq [user1] expect(model.level_three_verified).not_to include(user2) end end @@ -19,10 +19,9 @@ shared_examples_for "verifiable" do user3 = create(:user, confirmed_phone: nil, residence_verified_at: Time.current) user4 = create(:user, level_two_verified_at: Time.current) - expect(model.level_two_verified).to include(user1) + expect(model.level_two_verified).to match_array [user1, user4] expect(model.level_two_verified).not_to include(user2) expect(model.level_two_verified).not_to include(user3) - expect(model.level_two_verified).to include(user4) end end @@ -34,11 +33,9 @@ shared_examples_for "verifiable" do user4 = create(:user, confirmed_phone: nil, residence_verified_at: Time.current) user5 = create(:user, level_two_verified_at: Time.current) - expect(model.level_two_or_three_verified).to include(user1) - expect(model.level_two_or_three_verified).to include(user2) + expect(model.level_two_or_three_verified).to match_array [user1, user2, user5] expect(model.level_two_or_three_verified).not_to include(user3) expect(model.level_two_or_three_verified).not_to include(user4) - expect(model.level_two_or_three_verified).to include(user5) end end @@ -53,9 +50,7 @@ shared_examples_for "verifiable" do confirmed_phone: "123456789") user5 = create(:user, level_two_verified_at: Time.current) - expect(model.unverified).to include(user1) - expect(model.unverified).to include(user2) - expect(model.unverified).to include(user3) + expect(model.unverified).to match_array [user1, user2, user3] expect(model.unverified).not_to include(user4) expect(model.unverified).not_to include(user5) end @@ -72,8 +67,7 @@ shared_examples_for "verifiable" do user4 = create(:user, verified_at: Time.current, residence_verified_at: Time.current, unconfirmed_phone: "123456789", confirmed_phone: "123456789") - expect(model.incomplete_verification).to include(user1) - expect(model.incomplete_verification).to include(user2) + expect(model.incomplete_verification).to match_array [user1, user2] expect(model.incomplete_verification).not_to include(user3) expect(model.incomplete_verification).not_to include(user4) end