Skip to content

Restore respond_to? check for default_url_options #2277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/rspec/rails/example/feature_example_group.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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