Skip to content

Commit

Permalink
Extract host context of system specs into a test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitemaeric committed Jan 2, 2024
1 parent 137ca55 commit 6350510
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 30 deletions.
3 changes: 3 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
rescue ActiveRecord::PendingMigrationError => e
abort e.to_s.strip
end

RSpec.configure do |config|
config.include ServicesTestHelper, type: :system

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_paths = [Rails.root.join("spec/fixtures")]

Expand Down
9 changes: 9 additions & 0 deletions spec/support/services_test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module ServicesTestHelper
def given_i_am_on_the_claims_site
Capybara.app_host = "http://#{ENV["CLAIMS_HOST"]}"
end

def given_i_am_on_the_placements_site
Capybara.app_host = "http://#{ENV["PLACEMENTS_HOST"]}"
end
end
20 changes: 0 additions & 20 deletions spec/system/home_page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
require "rails_helper"

RSpec.describe "Home Page", type: :system do
after { Capybara.app_host = nil }

scenario "User visits the claims homepage" do
given_i_am_on_the_claims_site
and_i_am_on_the_start_page
i_can_see_the_claims_service_name_in_the_header
and_i_can_see_the_claims_service_value_in_the_page
end

scenario "User visits the placements homepage" do
given_i_am_on_the_placements_site
and_i_am_on_the_start_page
i_can_see_the_placements_service_name_in_the_header
and_i_can_see_the_placements_service_value_in_the_page
end

private

def given_i_am_on_the_claims_site
Capybara.app_host = "http://#{ENV["CLAIMS_HOST"]}"
end

def given_i_am_on_the_placements_site
Capybara.app_host = "http://#{ENV["PLACEMENTS_HOST"]}"
end

def and_i_am_on_the_start_page
visit "/"
end
Expand All @@ -42,12 +30,4 @@ def i_can_see_the_placements_service_name_in_the_header
expect(page).to have_content("Manage School Placements")
end
end

def and_i_can_see_the_claims_service_value_in_the_page
expect(page).to have_css(".govuk-summary-list__value", text: "Claims")
end

def and_i_can_see_the_placements_service_value_in_the_page
expect(page).to have_css(".govuk-summary-list__value", text: "Placements")
end
end
10 changes: 0 additions & 10 deletions spec/system/service_updates_page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require "rails_helper"

RSpec.describe "Service updates page", type: :system do
after { Capybara.app_host = nil }

scenario "User visits the claims Service updates" do
given_i_am_on_the_claims_site
and_i_am_on_the_service_updates_page
Expand All @@ -17,14 +15,6 @@

private

def given_i_am_on_the_claims_site
Capybara.app_host = "http://#{ENV["CLAIMS_HOST"]}"
end

def given_i_am_on_the_placements_site
Capybara.app_host = "http://#{ENV["PLACEMENTS_HOST"]}"
end

def and_i_am_on_the_service_updates_page
visit "/service_updates"
end
Expand Down

0 comments on commit 6350510

Please sign in to comment.