Class: Lookout::Warning
Overview
Warning expectation proxy. Used to expect warning outputs during the execution of the expect block. Warnings are matched by ignoring any trailing newlines and by removing any file/line warning prefixes. This is done as Ruby internally uses two different functions to generate warnings (rb_warn() and rb_warning()).
Instance Method Summary collapse
-
#===(other) ⇒ Object
True if the receiver ‘#==` OTHER or if their classes and normalized expected output `#==` each other.
-
#diff(other) ⇒ Enumerable<String>
An Enumerable over the formatted operations that would have to be applied to the actual warning output to get the expected warning output after any normalization of the warning outputs have been performed.
-
#initialize(expected) ⇒ Warning
constructor
Proxies the EXPECTED warning output.
- #inspect ⇒ Object
-
#to_lookout_expected ⇒ Expected::Lookout::Warning
A wrapper around the receiver, making it an expected value.
Constructor Details
#initialize(expected) ⇒ Warning
Proxies the EXPECTED warning output.
11 |
# File 'lib/lookout-3.0/warning.rb', line 11 def initialize(expected) super expected.chomp end |
Instance Method Details
#===(other) ⇒ Object
Returns True if the receiver ‘#==` OTHER or if their classes and normalized expected output `#==` each other.
15 16 17 18 |
# File 'lib/lookout-3.0/warning.rb', line 15 def ===(other) self == other or (self.class == other.class and normalized == other.normalized) end |
#diff(other) ⇒ Enumerable<String>
Returns An Enumerable over the formatted operations that would have to be applied to the actual warning output to get the expected warning output after any normalization of the warning outputs have been performed.
26 27 28 |
# File 'lib/lookout-3.0/warning.rb', line 26 def diff(other) self == normalized ? super(other.normalized) : normalized.diff(other) end |
#inspect ⇒ Object
20 |
# File 'lib/lookout-3.0/warning.rb', line 20 def inspect; 'warning(%p)' % expected end |
#to_lookout_expected ⇒ Expected::Lookout::Warning
Returns A wrapper around the receiver, making it an expected value.
32 |
# File 'lib/lookout-3.0/warning.rb', line 32 def to_lookout_expected; Lookout::Expected::Lookout::Warning.new(self) end |