Module: EEtee::Assertions
- Included in:
- AssertionWrapper
- Defined in:
- lib/eetee/assertion_wrapper.rb
Instance Method Summary collapse
- #be_a(klass) ⇒ Object
- #close?(target, error_margin) ⇒ Boolean
- #raise(expected_error_class = RuntimeError) ⇒ Object
Instance Method Details
#be_a(klass) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/eetee/assertion_wrapper.rb', line 4 def be_a(klass) object_class = @object.class invert_helper( "expected instance of #{klass}, got #{object_class}", "instance of #{klass} not expected" ) do object_class.should == klass end end |
#close?(target, error_margin) ⇒ Boolean
38 39 40 41 42 43 44 45 |
# File 'lib/eetee/assertion_wrapper.rb', line 38 def close?(target, error_margin) invert_helper( "expected #{target} += #{error_margin}, got #{@object}", "expected to be outside of #{target} += #{error_margin}, got #{@object}" ) do (target-error_margin .. target+error_margin).should.include?(@object) end end |
#raise(expected_error_class = RuntimeError) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/eetee/assertion_wrapper.rb', line 16 def raise(expected_error_class = RuntimeError) @object.should.be_a ::Proc err = nil begin @object.call() rescue => ex err = ex end = err ? err. : "" = err ? "#{err.class} (#{})" : "no error" invert_helper( "expected to raise #{expected_error_class}, got #{}", "expected not to raise #{expected_error_class} (#{})" ) do err.class.should == expected_error_class end err end |