diff --git a/lib/twitter/request.rb b/lib/twitter/request.rb index 93956e470..4c09c0913 100644 --- a/lib/twitter/request.rb +++ b/lib/twitter/request.rb @@ -74,13 +74,22 @@ def parse(response) def mash(obj) if obj.is_a?(Array) - obj.map { |item| Mash.new(item) } + obj.map { |item| make_mash_with_consistent_hash(item) } elsif obj.is_a?(Hash) - Mash.new(obj) + make_mash_with_consistent_hash(obj) else obj end end + + # Lame workaround for the fact that mash doesn't hash correctly + def make_mash_with_consistent_hash(obj) + m = Mash.new(obj) + def m.hash + inspect.hash + end + return m + end def to_query(options) options.inject([]) do |collection, opt| diff --git a/test/twitter/base_test.rb b/test/twitter/base_test.rb index 2d682c86d..afdda9d67 100644 --- a/test/twitter/base_test.rb +++ b/test/twitter/base_test.rb @@ -69,6 +69,12 @@ class BaseTest < Test::Unit::TestCase first.user.name.should == '-oAk-' first.text.should == '@jnunemaker cold out today. cold yesterday. even colder today.' end + + should "correctly hash statuses" do + stub_get('/statuses/friends_timeline.json', 'friends_timeline.json') + hashes = @twitter.friends_timeline.map{ |s| s.hash } + hashes.should == @twitter.friends_timeline.map{ |s| s.hash } + end end end end \ No newline at end of file