Sha256: 7df09f81e6578372806585f813ab2a7831f6cd7a426c6a252abc725db62465ad

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

require 'capybara'
require 'capybara/dsl'
require 'rspec/core'
require 'capybara/rspec/matchers'
require 'capybara/rspec/features'

RSpec.configure do |config|
  config.include Capybara::DSL, :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
  # might not actually be used in all examples where it's included.
  config.after do
    if self.class.include?(Capybara::DSL)
      Capybara.reset_sessions!
      Capybara.use_default_driver
    end
  end
  config.before do
    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 = example.metadata[:driver] if example.metadata[:driver]
    end
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/capybara-2.4.4/lib/capybara/rspec.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/capybara-2.4.4/lib/capybara/rspec.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/capybara-2.4.4/lib/capybara/rspec.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/capybara-2.4.4/lib/capybara/rspec.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/capybara-2.4.4/lib/capybara/rspec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/capybara-2.4.4/lib/capybara/rspec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/capybara-2.4.4/lib/capybara/rspec.rb
capybara-2.4.4 lib/capybara/rspec.rb
capybara-2.4.3 lib/capybara/rspec.rb
capybara-2.4.2 lib/capybara/rspec.rb
capybara-2.4.1 lib/capybara/rspec.rb
capybara-2.4.0 lib/capybara/rspec.rb
capybara-2.3.0 lib/capybara/rspec.rb