Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / spec / spec / expectations / extensions / object_spec.rb
blob4ab094b4f3515e53725b33904f555487f19bc37c
1 require File.dirname(__FILE__) + '/../../../spec_helper.rb'
3 describe "Object#should" do
4   before(:each) do
5     @target = "target"
6     @matcher = mock("matcher")
7     @matcher.stub!(:matches?).and_return(true)
8     @matcher.stub!(:failure_message)
9   end
10   
11   it "should accept and interact with a matcher" do
12     @matcher.should_receive(:matches?).with(@target).and_return(true)
13     
14     @target.should @matcher
15   end
16   
17   it "should ask for a failure_message when matches? returns false" do
18     @matcher.should_receive(:matches?).with(@target).and_return(false)
19     @matcher.should_receive(:failure_message).and_return("the failure message")
20     lambda {
21       @target.should @matcher
22     }.should fail_with("the failure message")
23   end
24 end
26 describe "Object#should_not" do
27   before(:each) do
28     @target = "target"
29     @matcher = mock("matcher")
30   end
31   
32   it "should accept and interact with a matcher" do
33     @matcher.should_receive(:matches?).with(@target).and_return(false)
34     @matcher.stub!(:negative_failure_message)
35     
36     @target.should_not @matcher
37   end
38   
39   it "should ask for a negative_failure_message when matches? returns true" do
40     @matcher.should_receive(:matches?).with(@target).and_return(true)
41     @matcher.should_receive(:negative_failure_message).and_return("the negative failure message")
42     lambda {
43       @target.should_not @matcher
44     }.should fail_with("the negative failure message")
45   end
46 end