2010-12-10 08:54:46 -05:00
|
|
|
require 'capybara'
|
|
|
|
require 'capybara/dsl'
|
2011-02-03 17:18:07 -05:00
|
|
|
require 'rspec/core'
|
2011-02-11 08:03:46 -05:00
|
|
|
require 'capybara/rspec/matchers'
|
2011-02-11 08:44:58 -05:00
|
|
|
require 'capybara/rspec/features'
|
2010-12-10 08:54:46 -05:00
|
|
|
|
2010-12-21 10:25:25 -05:00
|
|
|
RSpec.configure do |config|
|
2012-09-07 14:17:38 -04:00
|
|
|
config.include Capybara::DSL, :type => :feature
|
|
|
|
config.include Capybara::RSpecMatchers, :type => :feature
|
2011-02-03 17:18:07 -05:00
|
|
|
# The before and after blocks must run instantaneously, because Capybara
|
|
|
|
# might not actually be used in all examples where it's included.
|
2010-12-10 08:54:46 -05:00
|
|
|
config.after do
|
2011-04-11 01:58:42 -04:00
|
|
|
if self.class.include?(Capybara::DSL)
|
2011-01-09 07:57:41 -05:00
|
|
|
Capybara.reset_sessions!
|
|
|
|
Capybara.use_default_driver
|
|
|
|
end
|
2010-12-10 08:54:46 -05:00
|
|
|
end
|
|
|
|
config.before do
|
2011-04-11 01:58:42 -04:00
|
|
|
if self.class.include?(Capybara::DSL)
|
2011-01-09 07:57:41 -05:00
|
|
|
Capybara.current_driver = Capybara.javascript_driver if example.metadata[:js]
|
|
|
|
Capybara.current_driver = example.metadata[:driver] if example.metadata[:driver]
|
|
|
|
end
|
2010-12-10 08:54:46 -05:00
|
|
|
end
|
|
|
|
end
|
2012-08-21 09:46:58 -04:00
|
|
|
|
|
|
|
# Override default rack_test driver to respect data-method attributes.
|
|
|
|
Capybara.register_driver :rack_test do |app|
|
|
|
|
Capybara::RackTest::Driver.new(app, :respect_data_method => true)
|
|
|
|
end
|