3 # rspec adds #should and #should_not to every Object (and,
4 # implicitly, every Class).
5 module ObjectExpectations
13 # receiver.should(matcher)
14 # => Passes if matcher.matches?(receiver)
16 # receiver.should == expected #any value
17 # => Passes if (receiver == expected)
19 # receiver.should === expected #any value
20 # => Passes if (receiver === expected)
22 # receiver.should =~ regexp
23 # => Passes if (receiver =~ regexp)
25 # See Spec::Matchers for more information about matchers
29 # NOTE that this does NOT support receiver.should != expected.
30 # Instead, use receiver.should_not == expected
31 def should(matcher=nil, &block)
32 return ExpectationMatcherHandler.handle_matcher(self, matcher, &block) if matcher
33 Spec::Matchers::PositiveOperatorMatcher.new(self)
38 # should_not == expected
39 # should_not === expected
40 # should_not =~ expected
42 # receiver.should_not(matcher)
43 # => Passes unless matcher.matches?(receiver)
45 # receiver.should_not == expected
46 # => Passes unless (receiver == expected)
48 # receiver.should_not === expected
49 # => Passes unless (receiver === expected)
51 # receiver.should_not =~ regexp
52 # => Passes unless (receiver =~ regexp)
54 # See Spec::Matchers for more information about matchers
55 def should_not(matcher=nil, &block)
56 return NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block) if matcher
57 Spec::Matchers::NegativeOperatorMatcher.new(self)
65 include Spec::Expectations::ObjectExpectations