Skip to content

Commit

Permalink
Merge pull request #1330 from jnicklas/rspec_scoping
Browse files Browse the repository at this point in the history
Support RSpec expose_dsl_globally configuration option - fix issue #1285
  • Loading branch information
twalpole committed Jun 13, 2014
2 parents 8d1fea1 + 6c0674d commit 6d3d8d9
Showing 1 changed file with 38 additions and 21 deletions.
59 changes: 38 additions & 21 deletions lib/capybara/rspec/features.rb
@@ -1,28 +1,45 @@
module Capybara
module Features
def self.included(base)
base.instance_eval do
alias :background :before
alias :scenario :it
alias :xscenario :xit
alias :given :let
alias :given! :let!
alias :feature :describe
if RSpec::Version::STRING.to_f >= 3.0
RSpec.shared_context "Capybara Features", :capybara_feature => true do
instance_eval do
alias background before
alias given let
alias given! let!
end
end

RSpec.configure do |config|
config.alias_example_group_to :feature, :capybara_feature => true, :type => :feature
config.alias_example_to :scenario
config.alias_example_to :xscenario, :skip => "Temporarily disabled with xscenario"
# config.alias_example_to :fscenario, :focus => true
end
else
module Capybara
module Features
def self.included(base)
base.instance_eval do
alias :background :before
alias :scenario :it
alias :xscenario :xit
alias :given :let
alias :given! :let!
alias :feature :describe
end
end
end
end
end


def self.feature(*args, &block)
options = if args.last.is_a?(Hash) then args.pop else {} end
options[:capybara_feature] = true
options[:type] = :feature
options[:caller] ||= caller
args.push(options)
def self.feature(*args, &block)
options = if args.last.is_a?(Hash) then args.pop else {} end
options[:capybara_feature] = true
options[:type] = :feature
options[:caller] ||= caller
args.push(options)

#call describe on RSpec in case user has expose_dsl_globally set to false
RSpec.describe(*args, &block)
end
#call describe on RSpec in case user has expose_dsl_globally set to false
RSpec.describe(*args, &block)
end

RSpec.configuration.include Capybara::Features, :capybara_feature => true
RSpec.configuration.include Capybara::Features, :capybara_feature => true
end

0 comments on commit 6d3d8d9

Please sign in to comment.