Sha256: fc24a9da23d2b9f352f8e1997a0416f7e2e68390b58bf09b31ed609b62c5dad2

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

require 'rspec'

RSpec.configure do |config|
  config.before(:all) do
    Gnawrnip.ready!
  end

  config.after(:all) do
    Gnawrnip.finish!
  end

  # https://github.com/jnicklas/capybara/blob/master/lib/capybara/rspec.rb
  fetch_current_example = RSpec.respond_to?(:current_example) ?
    proc { RSpec.current_example } : proc { |context| context.example }

  config.before(:each, turnip: true) do
    example = fetch_current_example.call(self)
    Gnawrnip.photographer.reset!
    example.metadata[:gnawrnip] = {}
  end

  config.after(:each, turnip: true) do
    example = fetch_current_example.call(self)

    if example.exception
      Gnawrnip.photographer.take_shot
      screenshots = Gnawrnip.photographer.frames.compact
      example.metadata[:gnawrnip][:screenshot] = screenshots
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gnawrnip-0.3.0 lib/gnawrnip/rspec.rb