Skip to content

Commit

Permalink
Do not override existing custom feature aliases.
Browse files Browse the repository at this point in the history
It's possible that a user has their own custom `feature` alises which
has already been loaded. If we detect the alias we shouldn't write our
own.
  • Loading branch information
cupakromer committed Dec 31, 2014
1 parent 12d915e commit 0192401
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions lib/rspec/rails/example/feature_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,27 @@ def visit(*)
end
end

if defined?(Capybara) && ::Capybara::VERSION.to_f < 2.4
# Capybara 2.2 and 2.3 do not use `alias_example_xyz`
RSpec.configure do |c|
c.alias_example_group_to :feature, :type => :feature, :skip => <<-EOT.squish
Capybara < 2.4.0 does not support RSpec's namespace or
`config.expose_dsl_globally = false`. Upgrade to Capybara >= 2.4.0.
EOT
end
elsif !RSpec.respond_to?(:feature)
RSpec.configure do |c|
c.alias_example_group_to :feature, :type => :feature, :skip => <<-EOT.squish
unless RSpec.respond_to?(:feature)
opts = {
:type => :feature,
:skip => <<-EOT.squish
Feature specs require the Capybara (http://github.com/jnicklas/capybara)
gem, version 2.2.0 or later. We recommend version 2.4.0 or later to avoid
some deprecation warnings and have support for
`config.expose_dsl_globally = false`.
EOT
}

if defined?(Capybara) && ::Capybara::VERSION.to_f < 2.4
# Capybara 2.2 and 2.3 do not use `alias_example_xyz`
opts[:skip] = <<-EOT.squish
Capybara < 2.4.0 does not support RSpec's namespace or
`config.expose_dsl_globally = false`. Upgrade to Capybara >= 2.4.0.
EOT
end

RSpec.configure do |c|
c.alias_example_group_to :feature, opts
c.alias_example_to :scenario
c.alias_example_to :xscenario
end
Expand Down

0 comments on commit 0192401

Please sign in to comment.