Class: Liltest::Expectation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Expectation

Returns a new instance of Expectation.



5
6
7
# File 'lib/liltest/expectation.rb', line 5

def initialize(value)
  @value = value
end

Instance Attribute Details

#failed_reasonObject (readonly)

Returns the value of attribute failed_reason.



3
4
5
# File 'lib/liltest/expectation.rb', line 3

def failed_reason
  @failed_reason
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/liltest/expectation.rb', line 3

def value
  @value
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/liltest/expectation.rb', line 16

def failed?
  !!@failed_reason
end

#to_eq(expectation) ⇒ Object



9
10
11
12
13
14
# File 'lib/liltest/expectation.rb', line 9

def to_eq(expectation)
  if value != expectation
    @failed_reason = "Expected '#{value}' to equal '#{expectation}', but it was '#{value}'"
    raise "Failed"
  end
end