Class: Matchy::Expectations::OperatorExpectation
- Defined in:
- lib/matchy/built_in/operator_expectations.rb
Overview
Class to handle operator expectations.
Examples
13.should == 13
"hello".length.should_not == 2
Instance Method Summary collapse
- #<(expected) ⇒ Object
- #<=(expected) ⇒ Object
- #==(expected) ⇒ Object
- #===(expected) ⇒ Object
- #=~(expected) ⇒ Object
- #>(expected) ⇒ Object
- #>=(expected) ⇒ Object
-
#initialize(receiver, match) ⇒ OperatorExpectation
constructor
A new instance of OperatorExpectation.
Methods inherited from Base
Constructor Details
#initialize(receiver, match) ⇒ OperatorExpectation
Returns a new instance of OperatorExpectation.
11 12 13 14 |
# File 'lib/matchy/built_in/operator_expectations.rb', line 11 def initialize(receiver, match) @receiver = receiver @match = match end |
Instance Method Details
#<(expected) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/matchy/built_in/operator_expectations.rb', line 52 def <(expected) @expected = expected if @receiver.send(:<, expected) == @match pass! else fail!("<") end end |
#<=(expected) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/matchy/built_in/operator_expectations.rb', line 70 def <=(expected) @expected = expected if @receiver.send(:<=, expected) == @match pass! else fail!("<=") end end |
#==(expected) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/matchy/built_in/operator_expectations.rb', line 16 def ==(expected) @expected = expected if @receiver.send(:==, expected) == @match pass! else fail!("==") end end |
#===(expected) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/matchy/built_in/operator_expectations.rb', line 25 def ===(expected) @expected = expected if @receiver.send(:===, expected) == @match pass! else fail!("===") end end |
#=~(expected) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/matchy/built_in/operator_expectations.rb', line 34 def =~(expected) @expected = expected if @receiver.send(:=~, expected).nil? != @match pass! else fail!("=~") end end |
#>(expected) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/matchy/built_in/operator_expectations.rb', line 43 def >(expected) @expected = expected if @receiver.send(:>, expected) == @match pass! else fail!(">") end end |
#>=(expected) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/matchy/built_in/operator_expectations.rb', line 61 def >=(expected) @expected = expected if @receiver.send(:>=, expected) == @match pass! else fail!(">=") end end |