From 5553a77472ad72f258f587d29ebbeef8310abfae Mon Sep 17 00:00:00 2001 From: JG Date: Wed, 15 Jun 2022 13:57:45 +0100 Subject: [PATCH] fixing spec failures --- spec/requests/schemes_controller_spec.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 8c8413766..d41ab9687 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -316,14 +316,15 @@ RSpec.describe SchemesController, type: :request do end context "when paginating over 20 results" do + let!(:locations) { FactoryBot.create_list(:location, 25, scheme:) } + context "when on the first page" do before do - FactoryBot.create_list(:location, 25, scheme:) get "/schemes/#{scheme.id}/locations" end it "shows which schemes are being shown on the current page" do - expect(CGI.unescape_html(response.body)).to match("Showing 1 to 20 of 25 locations") + expect(CGI.unescape_html(response.body)).to match("Showing 1 to 20 of #{locations.count} locations") end it "has correct page 1 of 2 title" do @@ -344,7 +345,7 @@ RSpec.describe SchemesController, type: :request do end it "shows which schemes are being shown on the current page" do - expect(CGI.unescape_html(response.body)).to match("Showing 21 to 25 of 25 locations") + expect(CGI.unescape_html(response.body)).to match("Showing 21 to 25 of #{locations.count} locations") end it "has correct page 1 of 2 title" do @@ -394,14 +395,15 @@ RSpec.describe SchemesController, type: :request do end context "when paginating over 20 results" do + let!(:locations) { FactoryBot.create_list(:location, 25, scheme:) } + context "when on the first page" do before do - FactoryBot.create_list(:location, 25, scheme:) get "/schemes/#{scheme.id}/locations" end it "shows which schemes are being shown on the current page" do - expect(CGI.unescape_html(response.body)).to match("Showing 1 to 20 of 25 locations") + expect(CGI.unescape_html(response.body)).to match("Showing 1 to 20 of #{locations.count} locations") end it "has correct page 1 of 2 title" do @@ -422,7 +424,7 @@ RSpec.describe SchemesController, type: :request do end it "shows which schemes are being shown on the current page" do - expect(CGI.unescape_html(response.body)).to match("Showing 21 to 25 of 25 locations") + expect(CGI.unescape_html(response.body)).to match("Showing 21 to 25 of #{locations.count} locations") end it "has correct page 1 of 2 title" do