Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gstark/456715 to your computer and use it in GitHub Desktop.

Select an option

Save gstark/456715 to your computer and use it in GitHub Desktop.
From 9280317952337086c26812f51e9674f5436b39d9 Mon Sep 17 00:00:00 2001
From: Gavin Stark <g.stark@realdigitalmedia.com>
Date: Mon, 28 Jun 2010 22:32:28 -0400
Subject: [PATCH] These specs shouldn't require hash methods being called a certain number of times. In these cases precisely once.
---
spec/ruby/core/hash/element_reference_spec.rb | 4 ++--
spec/ruby/core/hash/shared/key.rb | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/spec/ruby/core/hash/element_reference_spec.rb b/spec/ruby/core/hash/element_reference_spec.rb
index 1a65d53..87f0486 100644
--- a/spec/ruby/core/hash/element_reference_spec.rb
+++ b/spec/ruby/core/hash/element_reference_spec.rb
@@ -86,8 +86,8 @@ describe "Hash#[]" do
y = mock('y')
def x.eql?(o) raise("Shouldn't receive eql?") end
- x.should_receive(:hash).and_return(0)
- y.should_receive(:hash).and_return(1)
+ x.stub!(:hash).and_return(0)
+ y.stub!(:hash).and_return(1)
new_hash(y => 1)[x].should == nil
end
diff --git a/spec/ruby/core/hash/shared/key.rb b/spec/ruby/core/hash/shared/key.rb
index a867abe..1d6729a 100644
--- a/spec/ruby/core/hash/shared/key.rb
+++ b/spec/ruby/core/hash/shared/key.rb
@@ -25,8 +25,8 @@ describe :hash_key_p, :shared => true do
it "returns false for objects with the same hash" do
x = mock('x')
y = mock('y')
- x.should_receive(:hash).and_return(0)
- y.should_receive(:hash).and_return(0)
+ x.should_receive(:hash).at_least(:once).and_return(0)
+ y.should_receive(:hash).at_least(:once).and_return(0)
new_hash(x => nil).send(@method, y).should == false
end
--
1.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment