1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
3 require 'spec/expectations/differs/default'
5 describe "should ==" do
7 it "should delegate message to target" do
9 subject.should_receive(:==).with("apple").and_return(true)
10 subject.should == "apple"
13 it "should fail when target.==(actual) returns false" do
15 Spec::Expectations.should_receive(:fail_with).with(%[expected "orange", got "apple" (using ==)], "orange", "apple")
16 subject.should == "orange"
21 describe "should_not ==" do
23 it "should delegate message to target" do
25 subject.should_receive(:==).with("apple").and_return(false)
26 subject.should_not == "apple"
29 it "should fail when target.==(actual) returns false" do
31 Spec::Expectations.should_receive(:fail_with).with(%[expected not == "apple", got "apple"], "apple", "apple")
32 subject.should_not == "apple"
37 describe "should ===" do
39 it "should delegate message to target" do
41 subject.should_receive(:===).with("apple").and_return(true)
42 subject.should === "apple"
45 it "should fail when target.===(actual) returns false" do
47 subject.should_receive(:===).with("orange").and_return(false)
48 Spec::Expectations.should_receive(:fail_with).with(%[expected "orange", got "apple" (using ===)], "orange", "apple")
49 subject.should === "orange"
54 describe "should_not ===" do
56 it "should delegate message to target" do
58 subject.should_receive(:===).with("apple").and_return(false)
59 subject.should_not === "apple"
62 it "should fail when target.===(actual) returns false" do
64 subject.should_receive(:===).with("apple").and_return(true)
65 Spec::Expectations.should_receive(:fail_with).with(%[expected not === "apple", got "apple"], "apple", "apple")
66 subject.should_not === "apple"
71 describe "should =~" do
73 it "should delegate message to target" do
75 subject.should_receive(:=~).with(/oo/).and_return(true)
76 subject.should =~ /oo/
79 it "should fail when target.=~(actual) returns false" do
81 subject.should_receive(:=~).with(/oo/).and_return(false)
82 Spec::Expectations.should_receive(:fail_with).with(%[expected =~ /oo/, got "fu"], /oo/, "fu")
83 subject.should =~ /oo/
88 describe "should_not =~" do
90 it "should delegate message to target" do
92 subject.should_receive(:=~).with(/oo/).and_return(false)
93 subject.should_not =~ /oo/
96 it "should fail when target.=~(actual) returns false" do
98 subject.should_receive(:=~).with(/oo/).and_return(true)
99 Spec::Expectations.should_receive(:fail_with).with(%[expected not =~ /oo/, got "foo"], /oo/, "foo")
100 subject.should_not =~ /oo/
105 describe "should >" do
107 it "should pass if > passes" do
111 it "should fail if > fails" do
112 Spec::Expectations.should_receive(:fail_with).with(%[expected > 5, got 4], 5, 4)
118 describe "should >=" do
120 it "should pass if >= passes" do
125 it "should fail if > fails" do
126 Spec::Expectations.should_receive(:fail_with).with(%[expected >= 5, got 4], 5, 4)
132 describe "should <" do
134 it "should pass if < passes" do
138 it "should fail if > fails" do
139 Spec::Expectations.should_receive(:fail_with).with(%[expected < 3, got 4], 3, 4)
145 describe "should <=" do
147 it "should pass if <= passes" do
152 it "should fail if > fails" do
153 Spec::Expectations.should_receive(:fail_with).with(%[expected <= 3, got 4], 3, 4)