Class: Lookout::Expected::Exception

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

Overview

Represents expected Exceptions.

Instance Method Summary collapse

Instance Method Details

#difference(actual) ⇒ Difference::Exception?

Returns A difference report between ACTUAL and #expected unless they’re #equal? or their classes are ‘#==` and their messages match or #expecteds message is a Regexp that matches actual’s message.

Parameters:

Returns:

  • (Difference::Exception, nil)

    A difference report between ACTUAL and #expected unless they’re #equal? or their classes are ‘#==` and their messages match or #expecteds message is a Regexp that matches actual’s message



20
21
22
23
24
25
26
27
# File 'lib/lookout-3.0/expected/exception.rb', line 20

def difference(actual)
  Lookout::Difference::Exception.new(actual, expected, regexp) unless
    expected.equal?(actual) or
    (expected.class == actual.class and
     (actual.respond_to? :message rescue false) and
     (m = actual.message rescue nil) and
     (regexp ? regexp === m : expected.message == m))
end

#expect(file, line) {|exception| ... } ⇒ Expect::Exception

Returns An expect block for the receiver at LINE in FILE that’ll yield the expected EXCEPTION and expect the exception to be raised.

Yield Parameters:

Yield Returns:

Returns:

  • (Expect::Exception)

    An expect block for the receiver at LINE in FILE that’ll yield the expected EXCEPTION and expect the exception to be raised



11
12
13
# File 'lib/lookout-3.0/expected/exception.rb', line 11

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