spec/spec/mocks/partial_mock_spec.rb in rspec-1.0.5 vs spec/spec/mocks/partial_mock_spec.rb in rspec-1.0.6

- old
+ new

@@ -4,11 +4,24 @@ module Mocks describe "using a Partial Mock," do before(:each) do @object = Object.new end - + + it "should name the class in the failure message" do + @object.should_receive(:foo) + lambda do + @object.rspec_verify + end.should raise_error(Spec::Mocks::MockExpectationError, /Object/) + end + + it "should not conflict with @options in the object" do + @object.instance_eval { @options = Object.new } + @object.should_receive(:blah) + @object.blah + end + it "should_not_receive should mock out the method" do @object.should_not_receive(:fuhbar) @object.fuhbar lambda do @object.rspec_verify @@ -45,8 +58,27 @@ lambda do @object.rspec_verify end.should raise_error(Spec::Mocks::MockExpectationError) end + it "should_receive should also take a String argument" do + @object.should_receive('foobar') + @object.foobar + end + + it "should_not_receive should also take a String argument" do + @object.should_not_receive('foobar') + @object.foobar + lambda do + @object.rspec_verify + end.should raise_error(Spec::Mocks::MockExpectationError) + end + + it "should use report nil in the error message" do + @this_will_resolve_to_nil.should_receive(:foobar) + lambda do + @this_will_resolve_to_nil.rspec_verify + end.should raise_error(Spec::Mocks::MockExpectationError, /NilClass.*expected :foobar with/) + end end end end