spec/bogus/shadow_spec.rb in bogus-0.0.4 vs spec/bogus/shadow_spec.rb in bogus-0.1.0

- old
+ new

@@ -1,10 +1,10 @@ require 'spec_helper' describe Bogus::Shadow do let(:object) { Samples::FooFake.new } - let(:shadow) { Bogus::Shadow.new{ object } } + let(:shadow) { Bogus::Shadow.new } shared_examples_for "spying on shadows" do context "spying" do before do shadow.run(:foo, "a", "b") rescue nil # for when the method raises an error @@ -20,12 +20,14 @@ end end end context "unrecorded interactions" do - it "returns the object, so that calls can be chained" do - shadow.run(:foo, "a", "b").should == object + it "returns an unstubbed value" do + return_value = shadow.run(:foo, "a", "b") + + return_value.should be_a_default_return_value end include_examples "spying on shadows" end @@ -48,12 +50,12 @@ context "interactions with no return value" do before do shadow.stubs(:foo, ["a", "b"]) end - it "returns the object" do - shadow.run(:foo, ["a", "b"]).should == object + it "returns the default value" do + shadow.run(:foo, ["a", "b"]).should be_a_default_return_value end include_examples "spying on shadows" end @@ -121,12 +123,12 @@ shadow.run(:foo, "a", "b").should == "stubbed twice" shadow.run(:foo, "b", "c").should == "different params" end it "returns the default value for non-stubbed calls" do - shadow.run(:foo, "c", "d").should == object - shadow.run(:bar).should == object + shadow.run(:foo, "c", "d").should be_a_default_return_value + shadow.run(:bar).should be_a_default_return_value end it "does not contribute towards unsatisfied interactions" do shadow.unsatisfied_interactions.should be_empty end @@ -168,10 +170,10 @@ shadow.unsatisfied_interactions.should be_empty end it "returns the default value for non-stubbed calls" do - shadow.run(:foo, "a", "c").should == object + shadow.run(:foo, "a", "c").should be_a_default_return_value end it "contributes towards unsatisfied interactions" do shadow.unsatisfied_interactions.should =~ [Bogus::Interaction.new(:foo, ["a", "b"])] end