Skip to content

Commit

Permalink
Merge pull request #2277 from eugeneius/default_url_options
Browse files Browse the repository at this point in the history
Restore respond_to? check for default_url_options
  • Loading branch information
JonRowe committed Mar 13, 2020
1 parent 99e937a commit e227cfd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rspec/rails/example/feature_example_group.rb
Expand Up @@ -15,7 +15,9 @@ module FeatureExampleGroup
include app.routes.url_helpers if app.routes.respond_to?(:url_helpers)
include app.routes.mounted_helpers if app.routes.respond_to?(:mounted_helpers)

default_url_options[:host] ||= ::RSpec::Rails::FeatureExampleGroup::DEFAULT_HOST
if respond_to?(:default_url_options)
default_url_options[:host] ||= ::RSpec::Rails::FeatureExampleGroup::DEFAULT_HOST
end
end
end

Expand Down
17 changes: 17 additions & 0 deletions spec/rspec/rails/example/feature_example_group_spec.rb
Expand Up @@ -18,6 +18,23 @@ module RSpec::Rails
expect(group.new.foo_url).to eq("http://www.example.com/foo")
end

context "when nested inside a request example group" do
it "includes Rails route helpers" do
Rails.application.routes.draw do
get "/foo", :as => :foo, :to => "foo#bar"
end

group = RSpec::Core::ExampleGroup.describe do
include RequestExampleGroup
end.describe do
include FeatureExampleGroup
end

expect(group.new.foo_path).to eq("/foo")
expect(group.new.foo_url).to eq("http://www.example.com/foo")
end
end

describe "#visit" do
it "raises an error informing about missing Capybara" do
group = RSpec::Core::ExampleGroup.describe do
Expand Down

0 comments on commit e227cfd

Please sign in to comment.