Class: TrueTest::Assertion
- Inherits:
-
Object
- Object
- TrueTest::Assertion
show all
- Defined in:
- lib/true_test/assertion.rb
Instance Method Summary
collapse
Constructor Details
#initialize(description = nil, positive = true, &block) ⇒ Assertion
Returns a new instance of Assertion.
3
4
5
6
7
|
# File 'lib/true_test/assertion.rb', line 3
def initialize(description = nil, positive = true, &block)
@description = description
@positive = positive
@block = block || proc {false}
end
|
Instance Method Details
#description ⇒ Object
27
28
29
|
# File 'lib/true_test/assertion.rb', line 27
def description
[(@positive ? 'should' : 'should not'), @description, TrueTest::Context.current.description].join(' ')
end
|
#error ⇒ Object
24
25
26
|
# File 'lib/true_test/assertion.rb', line 24
def error
@error
end
|
#evaluate(binding) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/true_test/assertion.rb', line 8
def evaluate(binding)
@passed = false
begin
@result = binding.instance_eval &@block
@passed = @positive ? @result : !@result
rescue => e
@error = e
end
ensure
TrueTest.after_assertion_callbacks.each do |callback|
callback.call(self)
end
end
|
#passed? ⇒ Boolean
21
22
23
|
# File 'lib/true_test/assertion.rb', line 21
def passed?
@passed
end
|