Skip to content

Commit 49b14cb

Browse files
committed
Set capybara as the default host in system specs
See: rails/rails@ea77dbf#diff-ff5f366a442b8761d35f94807700fa77R162
1 parent 0896526 commit 49b14cb

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Diff for: lib/rspec/rails/example/system_example_group.rb

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def driven_by(driver, **driver_options, &blk)
102102

103103
before do
104104
@routes = ::Rails.application.routes
105+
default_url_options.merge!(host: Capybara.app_host)
105106
end
106107

107108
after do

Diff for: spec/rspec/rails/example/system_example_group_spec.rb

+34
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,40 @@ module RSpec::Rails
1818
end
1919
end
2020

21+
describe 'rails url helpers' do
22+
it 'have the rails system test default host' do
23+
full_url = nil
24+
group = RSpec::Core::ExampleGroup.describe do
25+
include SystemExampleGroup
26+
27+
specify do
28+
@routes.draw { get "/" => "page#index", as: :root }
29+
full_url = root_url
30+
end
31+
end
32+
group.run(failure_reporter)
33+
expect(failure_reporter.exceptions).to eq []
34+
expect(full_url).to match a_string_including(ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown::DEFAULT_HOST)
35+
end
36+
end
37+
38+
describe '#url_options' do
39+
it 'has the rails system test default host' do
40+
rails_url_options = {}
41+
group = RSpec::Core::ExampleGroup.describe do
42+
include SystemExampleGroup
43+
44+
specify { rails_url_options.merge!(url_options) }
45+
end
46+
group.run(failure_reporter)
47+
expect(failure_reporter.exceptions).to eq []
48+
49+
expect(
50+
rails_url_options
51+
).to match hash_including(host: ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown::DEFAULT_HOST)
52+
end
53+
end
54+
2155
describe '#driver' do
2256
it 'uses :selenium driver by default' do
2357
group = RSpec::Core::ExampleGroup.describe do

0 commit comments

Comments
 (0)