Skip to content

Commit eb67808

Browse files
authored
Merge pull request #2277 from eugeneius/default_url_options
Restore respond_to? check for default_url_options
2 parents e69be80 + 94c43d9 commit eb67808

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/rspec/rails/example/feature_example_group.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ module FeatureExampleGroup
1515
include app.routes.url_helpers if app.routes.respond_to?(:url_helpers)
1616
include app.routes.mounted_helpers if app.routes.respond_to?(:mounted_helpers)
1717

18-
default_url_options[:host] ||= ::RSpec::Rails::FeatureExampleGroup::DEFAULT_HOST
18+
if respond_to?(:default_url_options)
19+
default_url_options[:host] ||= ::RSpec::Rails::FeatureExampleGroup::DEFAULT_HOST
20+
end
1921
end
2022
end
2123

spec/rspec/rails/example/feature_example_group_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ module RSpec::Rails
1818
expect(group.new.foo_url).to eq("http://www.example.com/foo")
1919
end
2020

21+
context "when nested inside a request example group" do
22+
it "includes Rails route helpers" do
23+
Rails.application.routes.draw do
24+
get "/foo", :as => :foo, :to => "foo#bar"
25+
end
26+
27+
group = RSpec::Core::ExampleGroup.describe do
28+
include RequestExampleGroup
29+
end.describe do
30+
include FeatureExampleGroup
31+
end
32+
33+
expect(group.new.foo_path).to eq("/foo")
34+
expect(group.new.foo_url).to eq("http://www.example.com/foo")
35+
end
36+
end
37+
2138
describe "#visit" do
2239
it "raises an error informing about missing Capybara" do
2340
group = RSpec::Core::ExampleGroup.describe do

0 commit comments

Comments
 (0)