class TestAssistant::FailureReporter::SummaryReporter
Base class for generating, saving and opening failure reports. Those classes that inherit from it provide further customisations to better parse and format different request and response bodies, depending on their format.
Attributes
Public Class Methods
Creates a new SummaryReport object
@param [ActionDispatch::Request] request the last request made before the test
failed
@param [ActionDispatch::TestResponse] response the response to the last request
made before the test failed
@param [String] extension what file extension should be used when saving the
failure report
@return [SummaryReport] new summary report object
# File lib/test_assistant/failure_reporter.rb, line 24 def initialize(request, response, extension = file_extension) @request, @response, @extension = request, response, extension end
Public Instance Methods
Opens the failure report file using an application that depends on the failure report's file extension. Expects that write
has already been called and the file exists.
@return void
# File lib/test_assistant/failure_reporter.rb, line 44 def open system "open #{file_path}" end
Writes the failure report to the tmp directory in the root of your Rails project so that it may be opened for viewing in an appropriate application depending on the failure report's file extension
@return void
# File lib/test_assistant/failure_reporter.rb, line 33 def write File.open(file_path, 'w') do |file| file.write(summary) end end
Protected Instance Methods
# File lib/test_assistant/failure_reporter.rb, line 54 def file_path @file_path ||= "#{Rails.root}/tmp/#{DateTime.now.to_i}.#{@extension}" end
# File lib/test_assistant/failure_reporter.rb, line 50 def summary @response.body end