spec/rspec-spies_spec.rb in rspec-spies-1.2.9 vs spec/rspec-spies_spec.rb in rspec-spies-2.0.0
- old
+ new
@@ -2,11 +2,11 @@
module Spec
module Matchers
describe "[object.should] have_received(method, *args)" do
before do
- @object = String.new
+ @object = String.new("HI!")
end
it "does match if method is called with correct args" do
@object.stub!(:slice)
@object.slice(5)
@@ -25,9 +25,26 @@
@object.stub!(:slice)
have_received(:slice).with(5).matches?(@object).should be_false
end
+ it "correctly lists expects arguments for should" do
+ @object.stub!(:slice)
+
+ matcher = have_received(:slice).with(5, 3)
+ messages = matcher.instance_variable_get("@messages")
+ message = messages[:failure_message_for_should].call(@object)
+ message.should == "expected \"HI!\" to have received :slice with [5, 3]"
+ end
+
+ it "correctly lists expects arguments for should_not" do
+ @object.stub!(:slice)
+
+ matcher = have_received(:slice).with(1, 2)
+ messages = matcher.instance_variable_get("@messages")
+ message = messages[:failure_message_for_should_not].call(@object)
+ message.should == "expected \"HI!\" to not have received :slice with [1, 2], but did"
+ end
end
end
end