1 require File.dirname(__FILE__) + '/../../../spec_helper.rb'
3 describe "Object#should" do
6 @matcher = mock("matcher")
7 @matcher.stub!(:matches?).and_return(true)
8 @matcher.stub!(:failure_message)
11 it "should accept and interact with a matcher" do
12 @matcher.should_receive(:matches?).with(@target).and_return(true)
14 @target.should @matcher
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")
21 @target.should @matcher
22 }.should fail_with("the failure message")
26 describe "Object#should_not" do
29 @matcher = mock("matcher")
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)
36 @target.should_not @matcher
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")
43 @target.should_not @matcher
44 }.should fail_with("the negative failure message")