Updated to latest rspec
[gitorious:georgyos-clone.git] / vendor / plugins / rspec / lib / spec / expectations / extensions / object.rb
1 module Spec
2   module Expectations
3     # rspec adds #should and #should_not to every Object (and,
4     # implicitly, every Class).
5     module ObjectExpectations
6       # :call-seq:
7       #   should(matcher)
8       #   should == expected
9       #   should === expected
10       #   should =~ expected
11       #
12       #   receiver.should(matcher)
13       #     => Passes if matcher.matches?(receiver)
14       #
15       #   receiver.should == expected #any value
16       #     => Passes if (receiver == expected)
17       #
18       #   receiver.should === expected #any value
19       #     => Passes if (receiver === expected)
20       #
21       #   receiver.should =~ regexp
22       #     => Passes if (receiver =~ regexp)
23       #
24       # See Spec::Matchers for more information about matchers
25       #
26       # == Warning
27       #
28       # NOTE that this does NOT support receiver.should != expected.
29       # Instead, use receiver.should_not == expected
30       def should(matcher=:use_operator_matcher, &block)
31         ExpectationMatcherHandler.handle_matcher(self, matcher, &block)
32       end
33
34       # :call-seq:
35       #   should_not(matcher)
36       #   should_not == expected
37       #   should_not === expected
38       #   should_not =~ expected
39       #
40       #   receiver.should_not(matcher)
41       #     => Passes unless matcher.matches?(receiver)
42       #
43       #   receiver.should_not == expected
44       #     => Passes unless (receiver == expected)
45       #
46       #   receiver.should_not === expected
47       #     => Passes unless (receiver === expected)
48       #
49       #   receiver.should_not =~ regexp
50       #     => Passes unless (receiver =~ regexp)
51       #
52       # See Spec::Matchers for more information about matchers
53       def should_not(matcher=:use_operator_matcher, &block)
54         NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block)
55       end
56
57     end
58   end
59 end
60
61 class Object
62   include Spec::Expectations::ObjectExpectations
63 end