class PryRescue::RSpec
Public Class Methods
after(example)
click to toggle source
# File lib/pry-rescue/rspec.rb, line 36 def self.after(example) e = example.exception Pry::rescued(e) if e end
after_filters()
click to toggle source
# File lib/pry-rescue/rspec.rb, line 60 def self.after_filters @after_filters ||= [] end
after_outside()
click to toggle source
# File lib/pry-rescue/rspec.rb, line 41 def self.after_outside after_filters.each(&:call) end
before()
click to toggle source
# File lib/pry-rescue/rspec.rb, line 32 def self.before monkeypatch_capybara if defined?(Capybara) end
monkeypatch_capybara()
click to toggle source
Shunt Capybara's after filter from before Pry::rescued
to after.
The after filter navigates to 'about:blank', but people debugging tests probably want to see the page that failed.
# File lib/pry-rescue/rspec.rb, line 49 def self.monkeypatch_capybara unless Capybara.respond_to?(:reset_sessions_after_rescue!) class << Capybara alias_method :reset_sessions_after_rescue!, :reset_sessions! def reset_sessions!; end end after_filters << Capybara.method(:reset_sessions_after_rescue!) end end
run(example)
click to toggle source
Run an Rspec example within Pry::rescue
{ }.
Takes care to ensure that `try-again` will work.
`example` is a RSpec::Core::Example::Procsy
# File lib/pry-rescue/rspec.rb, line 13 def self.run(example) Pry::rescue do begin before example.example.instance_variable_set(:@exception, nil) example.example_group_instance.instance_variable_set(:@__init_memoized, true) example.run # Rescued will be called in :after hook, which is ran before the second # :around leg ensure after_outside end end end