2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2014-06-13 23:02:20 -04:00
|
|
|
if RSpec::Core::Version::STRING.to_f >= 3.0
|
2016-07-22 13:21:24 -04:00
|
|
|
RSpec.shared_context "Capybara Features", capybara_feature: true do
|
2014-06-12 19:45:16 -04:00
|
|
|
instance_eval do
|
|
|
|
alias background before
|
|
|
|
alias given let
|
|
|
|
alias given! let!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-22 13:21:24 -04:00
|
|
|
# ensure shared_context is included if default shared_context_metadata_behavior is changed
|
|
|
|
if RSpec::Core::Version::STRING.to_f >= 3.5
|
|
|
|
RSpec.configure do |config|
|
|
|
|
config.include_context "Capybara Features", capybara_feature: true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-06-12 19:45:16 -04:00
|
|
|
RSpec.configure do |config|
|
2016-07-22 13:21:24 -04:00
|
|
|
config.alias_example_group_to :feature, capybara_feature: true, type: :feature
|
|
|
|
config.alias_example_group_to :xfeature, capybara_feature: true, type: :feature, skip: "Temporarily disabled with xfeature"
|
|
|
|
config.alias_example_group_to :ffeature, capybara_feature: true, type: :feature, focus: true
|
2014-06-12 19:45:16 -04:00
|
|
|
config.alias_example_to :scenario
|
2016-07-22 13:21:24 -04:00
|
|
|
config.alias_example_to :xscenario, skip: "Temporarily disabled with xscenario"
|
|
|
|
config.alias_example_to :fscenario, focus: true
|
2014-06-12 19:45:16 -04:00
|
|
|
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
|
2011-02-11 08:44:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-06-12 19:45:16 -04:00
|
|
|
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)
|
2011-02-11 08:44:58 -05:00
|
|
|
|
2014-06-12 19:45:16 -04:00
|
|
|
#call describe on RSpec in case user has expose_dsl_globally set to false
|
|
|
|
RSpec.describe(*args, &block)
|
|
|
|
end
|
2011-02-11 08:44:58 -05:00
|
|
|
|
2016-09-07 03:34:15 -04:00
|
|
|
RSpec.configure do |config|
|
2016-10-04 14:10:29 -04:00
|
|
|
config.include(Capybara::Features, capybara_feature: true)
|
2016-09-07 03:34:15 -04:00
|
|
|
end
|
2014-06-13 23:02:20 -04:00
|
|
|
end
|