From d09be11a08209d5ad68d4c46f2b4df7c96a13338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 14:17:24 +0200 Subject: [PATCH] Make test for feed limit more explicit The limit parameter wasn't specified in the test but in the default value in the database, making the test hard to read. Since now we've moved the other processes to separate tests, now we can create four processes using `times` and keep the test simple. --- spec/models/widget/feed_spec.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spec/models/widget/feed_spec.rb b/spec/models/widget/feed_spec.rb index a0bc3faa5..5500c7fde 100644 --- a/spec/models/widget/feed_spec.rb +++ b/spec/models/widget/feed_spec.rb @@ -57,15 +57,12 @@ describe Widget::Feed do end describe "#processes" do - let(:feed) { build(:widget_feed, kind: "processes") } + let(:feed) { build(:widget_feed, kind: "processes", limit: 3) } - it "returns open and published processes" do - open_process1 = create(:legislation_process, :open, :published, title: "Open process 1") - open_process2 = create(:legislation_process, :open, :published, title: "Open process 2") - open_process3 = create(:legislation_process, :open, :published, title: "Open process 3") - open_process4 = create(:legislation_process, :open, :published, title: "Open process 4") + it "returns a maximum number of open published processes given by the limit" do + 4.times { create(:legislation_process, :open, :published) } - expect(feed.processes).to eq([open_process4, open_process3, open_process2]) + expect(feed.processes.count).to be 3 end it "does not return past processes" do