Sha256: c0d80706db5a13eb71f8a9de6934f96da73078251e472f21efcfa3fabafb22f6

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

require 'rspec'

RSpec.configure do |config|
  config.before(:all) do
    Gnawrnip.ready!
  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
    else
      Gnawrnip.photographer.discard!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gnawrnip-0.2.5 lib/gnawrnip/rspec.rb
gnawrnip-0.2.4 lib/gnawrnip/rspec.rb