spec/rspec-spies_spec.rb in rspec-spies-2.1.0 vs spec/rspec-spies_spec.rb in rspec-spies-2.1.1
- old
+ new
@@ -5,14 +5,37 @@
describe "[object.should] have_received(method, *args)" do
before do
@object = String.new("HI!")
end
- it "does match if method is called with correct args" do
+ it "matches if method is called with correct args" do
@object.stub!(:slice)
@object.slice(5)
have_received(:slice).with(5).matches?(@object).should be_true
+ end
+
+ it "matches if doesn't specify args, even if method is called with args" do
+ @object.stub!(:slice)
+ @object.slice(5)
+
+ have_received(:slice).matches?(@object).should be_true
+ end
+
+ it "matches if specifies nil arg, if method is called with a nil arg" do
+ @object.stub!(:slice)
+ @object.slice(nil)
+
+ have_received(:slice).with(nil).matches?(@object).should be_true
+ have_received(:slice).matches?(@object).should be_true
+ end
+
+ it "matches if specifies hash_including, if method is called with has including arguments" do
+ @object.stub!(:slice)
+ @object.slice({ :foo => :bar, :baz => :quux })
+
+ have_received(:slice).with(hash_including({ :foo => :bar })).matches?(@object).should be_true
+ have_received(:slice).with(hash_including({ :foo => :baz })).matches?(@object).should be_false
end
it "does not match if method is called with incorrect args" do
@object.stub!(:slice)
@object.slice(3)