Class: Riot::Assertion
- Inherits:
-
Object
- Object
- Riot::Assertion
- Defined in:
- lib/riot/assertion.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#raised ⇒ Object
readonly
Returns the value of attribute raised.
-
#situation ⇒ Object
readonly
Returns the value of attribute situation.
-
#to_s ⇒ Object
readonly
Returns the value of attribute to_s.
Instance Method Summary collapse
- #actual ⇒ Object
- #errored? ⇒ Boolean
- #fail(message) ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(description, situation, &assertion_block) ⇒ Assertion
constructor
A new instance of Assertion.
- #passed? ⇒ Boolean
- #result ⇒ Object
Constructor Details
#initialize(description, situation, &assertion_block) ⇒ Assertion
Returns a new instance of Assertion.
4 5 6 7 8 |
# File 'lib/riot/assertion.rb', line 4 def initialize(description, situation, &assertion_block) @description = @to_s = description @situation = situation run(situation, &assertion_block) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/riot/assertion.rb', line 3 def description @description end |
#raised ⇒ Object (readonly)
Returns the value of attribute raised.
3 4 5 |
# File 'lib/riot/assertion.rb', line 3 def raised @raised end |
#situation ⇒ Object (readonly)
Returns the value of attribute situation.
3 4 5 |
# File 'lib/riot/assertion.rb', line 3 def situation @situation end |
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
3 4 5 |
# File 'lib/riot/assertion.rb', line 3 def to_s @to_s end |
Instance Method Details
#actual ⇒ Object
10 11 12 13 |
# File 'lib/riot/assertion.rb', line 10 def actual unfail_if_default_failure_recorded @actual end |
#errored? ⇒ Boolean
21 |
# File 'lib/riot/assertion.rb', line 21 def errored?; !@raised.nil?; end |
#fail(message) ⇒ Object
15 16 17 |
# File 'lib/riot/assertion.rb', line 15 def fail() @failure = Failure.new("#{description}: #{}") unless errored? end |
#failed? ⇒ Boolean
20 |
# File 'lib/riot/assertion.rb', line 20 def failed?; !@failure.nil?; end |
#passed? ⇒ Boolean
19 |
# File 'lib/riot/assertion.rb', line 19 def passed?; !(failed? || errored?); end |
#result ⇒ Object
22 |
# File 'lib/riot/assertion.rb', line 22 def result; @failure || @raised; end |