Class: RLab::Assert::Assertion::SubjectThunk
- Inherits:
-
Object
- Object
- RLab::Assert::Assertion::SubjectThunk
- Defined in:
- lib/rlab/assert/assertion.rb
Instance Method Summary collapse
- #call ⇒ Object
- #expect_error ⇒ Object
-
#initialize(block) ⇒ SubjectThunk
constructor
A new instance of SubjectThunk.
- #subject_resolved? ⇒ Boolean
Constructor Details
#initialize(block) ⇒ SubjectThunk
Returns a new instance of SubjectThunk.
91 92 93 |
# File 'lib/rlab/assert/assertion.rb', line 91 def initialize block @block = block end |
Instance Method Details
#call ⇒ Object
95 96 97 98 |
# File 'lib/rlab/assert/assertion.rb', line 95 def call return @subject if subject_resolved? @subject = @block.call end |
#expect_error ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/rlab/assert/assertion.rb', line 100 def expect_error raise "called after initially fetched" if subject_resolved? @block.call nothing_raised = true rescue => error @subject = error ensure raise NothingRaised.new if nothing_raised end |
#subject_resolved? ⇒ Boolean
110 111 112 |
# File 'lib/rlab/assert/assertion.rb', line 110 def subject_resolved? instance_variable_defined? :@subject end |