Class: TestAssistant::FailureReporter::SummaryReporter
- Inherits:
-
Object
- Object
- TestAssistant::FailureReporter::SummaryReporter
- Defined in:
- lib/test_assistant/failure_reporter.rb
Overview
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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file_extension ⇒ Object
Returns the value of attribute file_extension.
-
#next ⇒ Object
Returns the value of attribute next.
Instance Method Summary collapse
-
#initialize(request, response, extension = file_extension) ⇒ SummaryReport
constructor
Creates a new SummaryReport object.
-
#open ⇒ Object
Opens the failure report file using an application that depends on the failure report’s file extension.
-
#write ⇒ Object
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.
Constructor Details
#initialize(request, response, extension = file_extension) ⇒ SummaryReport
Creates a new SummaryReport object
24 25 26 |
# File 'lib/test_assistant/failure_reporter.rb', line 24 def initialize(request, response, extension = file_extension) @request, @response, @extension = request, response, extension end |
Instance Attribute Details
#file_extension ⇒ Object
Returns the value of attribute file_extension.
13 14 15 |
# File 'lib/test_assistant/failure_reporter.rb', line 13 def file_extension @file_extension end |
#next ⇒ Object
Returns the value of attribute next.
13 14 15 |
# File 'lib/test_assistant/failure_reporter.rb', line 13 def next @next end |
Instance Method Details
#open ⇒ Object
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.
44 45 46 |
# File 'lib/test_assistant/failure_reporter.rb', line 44 def open system "open #{file_path}" end |
#write ⇒ Object
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
33 34 35 36 37 |
# File 'lib/test_assistant/failure_reporter.rb', line 33 def write File.open(file_path, 'w') do |file| file.write(summary) end end |