Class: Lookout::Expected::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/lookout-3.0/expected/object.rb

Overview

Represents expected Objects. This is the base expected-value class and may be subclassed if you have a type that would benefit from more specific treatment than what this class affords. Such a subclass should override #expect and/or #difference to set up type-specific expect blocks and/or difference checks and difference report generation.

Instance Method Summary collapse

Instance Method Details

#difference(actual) ⇒ Difference::Object?

Returns A difference report between ACTUAL and #expected unless they’re ‘#==`.

Parameters:

Returns:

  • (Difference::Object, nil)

    A difference report between ACTUAL and #expected unless they’re ‘#==`



27
28
29
# File 'lib/lookout-3.0/expected/object.rb', line 27

def difference(actual)
  Lookout::Difference::Object.new(actual, expected) unless expected == actual
end

#expect(file, line, &block) ⇒ Expect::Object

Returns An expect block for the receiver at LINE in FILE that’ll yield the #expected object and expect an object that’ll exhibit no #differences from it to be returned.

Returns:

  • (Expect::Object)

    An expect block for the receiver at LINE in FILE that’ll yield the #expected object and expect an object that’ll exhibit no #differences from it to be returned



20
21
22
# File 'lib/lookout-3.0/expected/object.rb', line 20

def expect(file, line, &block)
  Lookout::Expect::Object.new(self, file, line, &block)
end