Merge pull request #1125 from thomas-holmes/support-rspec-3
Support rspec 3
This commit is contained in:
commit
8bdc7f6dc2
|
@ -7,6 +7,12 @@ require 'capybara/rspec/features'
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include Capybara::DSL, :type => :feature
|
config.include Capybara::DSL, :type => :feature
|
||||||
config.include Capybara::RSpecMatchers, :type => :feature
|
config.include Capybara::RSpecMatchers, :type => :feature
|
||||||
|
|
||||||
|
# A work-around to support accessing the current example that works in both
|
||||||
|
# RSpec 2 and RSpec 3.
|
||||||
|
fetch_current_example = RSpec.respond_to?(:current_example) ?
|
||||||
|
proc { RSpec.current_example } : proc { |context| context.example }
|
||||||
|
|
||||||
# The before and after blocks must run instantaneously, because Capybara
|
# The before and after blocks must run instantaneously, because Capybara
|
||||||
# might not actually be used in all examples where it's included.
|
# might not actually be used in all examples where it's included.
|
||||||
config.after do
|
config.after do
|
||||||
|
@ -17,6 +23,7 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
config.before do
|
config.before do
|
||||||
if self.class.include?(Capybara::DSL)
|
if self.class.include?(Capybara::DSL)
|
||||||
|
example = fetch_current_example.call(self)
|
||||||
Capybara.current_driver = Capybara.javascript_driver if example.metadata[:js]
|
Capybara.current_driver = Capybara.javascript_driver if example.metadata[:js]
|
||||||
Capybara.current_driver = example.metadata[:driver] if example.metadata[:driver]
|
Capybara.current_driver = example.metadata[:driver] if example.metadata[:driver]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue