Class: Spectus::Report Private
- Inherits:
-
Object
- Object
- Spectus::Report
- Defined in:
- lib/spectus/report.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The class that is responsible for reporting the result of the test.
Instance Attribute Summary collapse
-
#matcher ⇒ #matches?
readonly
private
The matcher.
-
#result ⇒ Boolean
readonly
private
The result of the test.
-
#state ⇒ Sandbox
readonly
private
The sandbox that tested the code.
Instance Method Summary collapse
-
#definition ⇒ String
private
The readable definition.
-
#initialize(matcher, negate, state, result) ⇒ Report
constructor
private
Initialize the report class.
-
#maybe_exception ⇒ String
private
The type of exception, if any.
-
#maybe_negate ⇒ String
private
The negation, if any.
-
#negate? ⇒ Boolean
private
The value of the negate instance variable.
-
#summary ⇒ String
private
The summary of the state.
-
#title ⇒ String
private
The title of the state.
-
#to_s ⇒ String
private
The message.
Constructor Details
#initialize(matcher, negate, state, result) ⇒ Report
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the report class.
15 16 17 18 19 20 |
# File 'lib/spectus/report.rb', line 15 def initialize(matcher, negate, state, result) @matcher = matcher @negate = negate @state = state @result = result end |
Instance Attribute Details
#matcher ⇒ #matches? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The matcher.
25 26 27 |
# File 'lib/spectus/report.rb', line 25 def matcher @matcher end |
#result ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The result of the test.
42 43 44 |
# File 'lib/spectus/report.rb', line 42 def result @result end |
#state ⇒ Sandbox (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The sandbox that tested the code.
37 38 39 |
# File 'lib/spectus/report.rb', line 37 def state @state end |
Instance Method Details
#definition ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The readable definition.
88 89 90 |
# File 'lib/spectus/report.rb', line 88 def definition matcher.to_s end |
#maybe_exception ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The type of exception, if any.
81 82 83 |
# File 'lib/spectus/report.rb', line 81 def maybe_exception state.exception.nil? ? '' : " (#{state.exception.class})" end |
#maybe_negate ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The negation, if any.
74 75 76 |
# File 'lib/spectus/report.rb', line 74 def maybe_negate negate? ? ' not' : '' end |
#negate? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The value of the negate instance variable.
30 31 32 |
# File 'lib/spectus/report.rb', line 30 def negate? @negate end |
#summary ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The summary of the state.
65 66 67 68 69 |
# File 'lib/spectus/report.rb', line 65 def summary return state.exception. unless state.valid? || state.exception.nil? "Expected #{state.actual.inspect}#{maybe_negate} to #{definition}" end |
#title ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The title of the state.
54 55 56 57 58 59 60 |
# File 'lib/spectus/report.rb', line 54 def title if result state.got ? 'Pass' : 'Info' else state.exception.nil? ? 'Failure' : 'Error' end end |
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The message.
47 48 49 |
# File 'lib/spectus/report.rb', line 47 def to_s "#{title}: #{summary}#{maybe_exception}." end |