diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-11 22:42:47 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-11 22:42:47 -0700 |
commit | a29ceffc9476c99ff02f0617d2e38627c526bac2 (patch) | |
tree | fc9aa702ad9a2f506a4a51b71791798fb8a6ca4b /spec/active_relation | |
parent | 98527c8f7dd64f086895c1576fb33e8b91071142 (diff) | |
download | rails-a29ceffc9476c99ff02f0617d2e38627c526bac2.tar.gz rails-a29ceffc9476c99ff02f0617d2e38627c526bac2.tar.bz2 rails-a29ceffc9476c99ff02f0617d2e38627c526bac2.zip |
implemented hashing macro; implemented custom matcher testing this macro
Diffstat (limited to 'spec/active_relation')
-rw-r--r-- | spec/active_relation/unit/primitives/attribute_spec.rb | 7 | ||||
-rw-r--r-- | spec/active_relation/unit/relations/table_spec.rb | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/spec/active_relation/unit/primitives/attribute_spec.rb b/spec/active_relation/unit/primitives/attribute_spec.rb index 95c972d814..d424bf4dff 100644 --- a/spec/active_relation/unit/primitives/attribute_spec.rb +++ b/spec/active_relation/unit/primitives/attribute_spec.rb @@ -68,6 +68,13 @@ module ActiveRelation Attribute.new(@relation, :name).should =~ Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name)) end end + + describe 'hashing' do + it "implements hash equality" do + Attribute.new(@relation, 'name').should hash_the_same_as(Attribute.new(@relation, 'name')) + Attribute.new(@relation, 'name').should_not hash_the_same_as(Attribute.new(@relation, 'id')) + end + end end describe '#to_sql' do diff --git a/spec/active_relation/unit/relations/table_spec.rb b/spec/active_relation/unit/relations/table_spec.rb index 95ad7133db..41ed2dc404 100644 --- a/spec/active_relation/unit/relations/table_spec.rb +++ b/spec/active_relation/unit/relations/table_spec.rb @@ -75,9 +75,8 @@ module ActiveRelation describe 'hashing' do it "implements hash equality" do - hash = {} - hash[Table.new(:users)] = 1 - hash[Table.new(:users)].should == 1 + Table.new(:users).should hash_the_same_as(Table.new(:users)) + Table.new(:users).should_not hash_the_same_as(Table.new(:photos)) end end |