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