Module: Capybara::Screenshot::MiniTestPlugin

Defined in:
lib/capybara-screenshot/minitest.rb

Instance Method Summary collapse

Instance Method Details

#before_setupObject


4
5
6
7
# File 'lib/capybara-screenshot/minitest.rb', line 4

def before_setup
  super
  Capybara::Screenshot.final_session_name = nil
end

#before_teardownObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/capybara-screenshot/minitest.rb', line 9

def before_teardown
  super
  if self.class.ancestors.map(&:to_s).include?('Capybara::DSL')
    if Capybara::Screenshot.autosave_on_failure && !passed? && !skipped?
      Capybara.using_session(Capybara::Screenshot.final_session_name) do
        filename_prefix = Capybara::Screenshot.filename_prefix_for(:minitest, self)

        saver = Capybara::Screenshot.new_saver(Capybara, Capybara.page, true, filename_prefix)
        saver.save
        saver.output_screenshot_path
      end
    end
  end
end