Exception: Expectation::Error

Inherits:
ArgumentError
  • Object
show all
Defined in:
lib/expectation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, expectation, info = nil) ⇒ Error

Returns a new instance of Error.



36
37
38
39
# File 'lib/expectation.rb', line 36

def initialize(value, expectation, info = nil)
  @value, @expectation, @info = 
    value, expectation, info
end

Instance Attribute Details

#expectationObject (readonly)

Returns the value of attribute expectation.



34
35
36
# File 'lib/expectation.rb', line 34

def expectation
  @expectation
end

#infoObject (readonly)

Returns the value of attribute info.



34
35
36
# File 'lib/expectation.rb', line 34

def info
  @info
end

#valueObject (readonly)

Returns the value of attribute value.



34
35
36
# File 'lib/expectation.rb', line 34

def value
  @value
end

Instance Method Details

#to_sObject



41
42
43
44
45
# File 'lib/expectation.rb', line 41

def to_s
  message = "#{value.inspect} does not match #{expectation.inspect}"
  message += ", #{info}" if info
  message
end