Skip to content

Commit

Permalink
rails 6 system spec compat
Browse files Browse the repository at this point in the history
  • Loading branch information
szTheory authored and mattheworiordan committed Oct 4, 2020
1 parent e19db98 commit 25b423d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/capybara-screenshot/rspec.rb
Original file line number Diff line number Diff line change
@@ -90,6 +90,14 @@ def failed?(example)
Capybara::Screenshot.final_session_name = nil
end

# TODO: DRY refactor into a method?
# Add support for Rails system specs (previously only worked with feature specs)
config.after(type: :system) do |example_from_block_arg|
# RSpec 3 no longer defines `example`, but passes the example as block argument instead
example = config.respond_to?(:expose_current_running_example_as) ? example_from_block_arg : self.example

Capybara::Screenshot::RSpec.after_failed_example(example)
end
config.after(type: :feature) do |example_from_block_arg|
# RSpec 3 no longer defines `example`, but passes the example as block argument instead
example = config.respond_to?(:expose_current_running_example_as) ? example_from_block_arg : self.example

0 comments on commit 25b423d

Please sign in to comment.