From fcfe687b8dcbd3ff56de048c9070b1217f23c204 Mon Sep 17 00:00:00 2001 From: JG Date: Wed, 15 Jun 2022 07:30:02 +0100 Subject: [PATCH] failing feature to see locations on the page --- spec/features/schemes_spec.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 4202cd858..d46c14e49 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -112,8 +112,10 @@ RSpec.describe "Supported housing scheme Features" do end context "when I click to see individual scheme" do + let(:scheme) { schemes.first } + before do - click_link(schemes.first.service_name) + click_link(scheme.service_name) end it "shows me details about the selected scheme" do @@ -129,17 +131,24 @@ RSpec.describe "Supported housing scheme Features" do expect(page).to have_content(schemes.first.intended_stay_display) end - it "shows service and locations tab" do - expect(page).to have_link("Scheme") - expect(page).to have_link("#{schemes.first.locations.count} locations") - end - context "when there are locations that belong to the selected scheme" do - let!(:locations) { FactoryBot.create_list(:location, 3, scheme: schemes.first) } + let!(:schemes) { FactoryBot.create_list(:scheme, 5) } + let!(:locations) { FactoryBot.create_list(:location, 3, scheme: scheme) } + let(:scheme) { schemes.first } + + before do + visit("supported-housing") + click_link(scheme.service_name) + end + + it "shows service and locations tab" do + expect(page).to have_link("Scheme") + expect(page).to have_link("#{scheme.locations.count} locations") + end context "when I click locations link" do before do - click_link("#{schemes.first.locations.count} locations") + click_link("#{scheme.locations.count} locations") end it "shows details of those locations" do