Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / lib / spec / expectations / extensions / object.rb
blobf59af722e2cb72c769ceea740854b19bf1c6b774
1 module Spec
2   module Expectations
3     # rspec adds #should and #should_not to every Object (and,
4     # implicitly, every Class).
5     module ObjectExpectations
7       # :call-seq:
8       #   should(matcher)
9       #   should == expected
10       #   should === expected
11       #   should =~ expected
12       #
13       #   receiver.should(matcher)
14       #     => Passes if matcher.matches?(receiver)
15       #
16       #   receiver.should == expected #any value
17       #     => Passes if (receiver == expected)
18       #
19       #   receiver.should === expected #any value
20       #     => Passes if (receiver === expected)
21       #
22       #   receiver.should =~ regexp
23       #     => Passes if (receiver =~ regexp)
24       #
25       # See Spec::Matchers for more information about matchers
26       #
27       # == Warning
28       #
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)
34       end
36       # :call-seq:
37       #   should_not(matcher)
38       #   should_not == expected
39       #   should_not === expected
40       #   should_not =~ expected
41       #
42       #   receiver.should_not(matcher)
43       #     => Passes unless matcher.matches?(receiver)
44       #
45       #   receiver.should_not == expected
46       #     => Passes unless (receiver == expected)
47       #
48       #   receiver.should_not === expected
49       #     => Passes unless (receiver === expected)
50       #
51       #   receiver.should_not =~ regexp
52       #     => Passes unless (receiver =~ regexp)
53       #
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)
58       end
60     end
61   end
62 end
64 class Object
65   include Spec::Expectations::ObjectExpectations
66 end