Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/speccify.rb
Overview
OperatorMatcherProxy
Instance Method Summary collapse
-
#should(matcher = nil) ⇒ Object
obj.should matcher Set an expectation to this object.
-
#should_not(matcher = nil) ⇒ Object
obj.should_not matcher Set a negative expectation to this object.
Instance Method Details
#should(matcher = nil) ⇒ Object
obj.should matcher
Set an expectation to this object. Can be used in conjunction with an operator (except !=, !~) or a matcher.
Examples:
-
1.should == 1
-
“asd”.should =~ /a/
-
nil.should be_nil
171 172 173 174 175 176 177 178 |
# File 'lib/speccify.rb', line 171 def should matcher = nil if matcher matcher.loc = caller[0] $current_spec.assert(matcher.matches?(self), matcher.positive_msg) else OperatorMatcherProxy.create(self,caller[0]) end end |
#should_not(matcher = nil) ⇒ Object
obj.should_not matcher
Set a negative expectation to this object. Can be used in conjunction with an operator (except !=, !~) or a matcher.
Examples:
-
1.should_not == 2
-
“asd”.should_not =~ /b/
-
1.should_not be_nil
186 187 188 189 190 191 192 193 |
# File 'lib/speccify.rb', line 186 def should_not matcher = nil if matcher matcher.loc = caller[0] $current_spec.assert(!matcher.matches?(self), matcher.negative_msg) else OperatorMatcherProxy.create(self,caller[0], false) end end |