2016-03-08 00:52:19 +00:00
|
|
|
# frozen_string_literal: true
|
2018-01-08 20:23:54 +00:00
|
|
|
|
2011-02-03 22:18:07 +00:00
|
|
|
require 'rspec/core'
|
2017-03-28 17:41:49 +00:00
|
|
|
require 'capybara/dsl'
|
2011-02-11 13:03:46 +00:00
|
|
|
require 'capybara/rspec/matchers'
|
2011-02-11 13:44:58 +00:00
|
|
|
require 'capybara/rspec/features'
|
2017-03-28 17:41:49 +00:00
|
|
|
require 'capybara/rspec/matcher_proxies'
|
2010-12-10 13:54:46 +00:00
|
|
|
|
2010-12-21 15:25:25 +00:00
|
|
|
RSpec.configure do |config|
|
2018-01-09 22:05:50 +00:00
|
|
|
config.include Capybara::DSL, type: :feature
|
|
|
|
config.include Capybara::RSpecMatchers, type: :feature
|
|
|
|
config.include Capybara::RSpecMatchers, type: :view
|
2013-07-22 00:19:42 +00:00
|
|
|
|
2011-02-03 22:18:07 +00: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 13:54:46 +00:00
|
|
|
config.after do
|
2011-04-11 05:58:42 +00:00
|
|
|
if self.class.include?(Capybara::DSL)
|
2011-01-09 12:57:41 +00:00
|
|
|
Capybara.reset_sessions!
|
|
|
|
Capybara.use_default_driver
|
|
|
|
end
|
2010-12-10 13:54:46 +00:00
|
|
|
end
|
2017-03-28 17:41:49 +00:00
|
|
|
|
2013-07-21 21:56:21 +00:00
|
|
|
config.before do
|
2011-04-11 05:58:42 +00:00
|
|
|
if self.class.include?(Capybara::DSL)
|
2016-08-17 23:14:39 +00:00
|
|
|
example = RSpec.current_example
|
2013-07-20 19:27:28 +00:00
|
|
|
Capybara.current_driver = Capybara.javascript_driver if example.metadata[:js]
|
2013-07-21 04:11:46 +00:00
|
|
|
Capybara.current_driver = example.metadata[:driver] if example.metadata[:driver]
|
2011-01-09 12:57:41 +00:00
|
|
|
end
|
2010-12-10 13:54:46 +00:00
|
|
|
end
|
|
|
|
end
|