Module: Lookout::Expect
- Defined in:
- lib/lookout-3.0/expect.rb
Overview
Function-like namespace for type-specific expect blocks. Represents the “expect” keyword in expectation files. Used by Lookout::Expectations::Context.
Object is the base class for all classes defined under this namespace, so look to it for guidance.
Defined Under Namespace
Modules: Classes Classes: Exception, Object
Class Method Summary collapse
-
.expect(expected, file, line, &block) ⇒ Object
Wraps the creation of an Object or one of its sub-classes by dispatching #to_lookout_expected on the expected value and then calling #expect on the result, passing the expanded path to the FILE containing the expectation, the LINE in file on which the expectation is defined, and the BLOCK to evaluate for the actual result.
Class Method Details
.expect(expected, file, line, &block) ⇒ Object
Wraps the creation of an Object or one of its sub-classes by dispatching #to_lookout_expected on the expected value and then calling
#expect on the result, passing the expanded path to the FILE
containing the expectation, the LINE in file on which the expectation is defined, and the BLOCK to evaluate for the actual result.
If #to_lookout_expected raises NoMethodError, the result will be an Object, so that at least something gets set up.
24 25 26 27 28 29 30 |
# File 'lib/lookout-3.0/expect.rb', line 24 def expect(expected, file, line, &block) begin expected.to_lookout_expected rescue ::NoMethodError ::Lookout::Expected::Object.new(expected) end.expect(file, line, &block) end |