aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/unit/primitives/attribute_spec.rb
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-12 15:40:06 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-12 15:40:06 -0700
commitfff47a5a5e92eccf949785231d1f6953d6fdc640 (patch)
treee7e651d680bacc1542883b6a1c6c2ef21c3f2d1d /spec/arel/unit/primitives/attribute_spec.rb
parentea111521b7eb7456934a283d96f6eb986322baf2 (diff)
downloadrails-fff47a5a5e92eccf949785231d1f6953d6fdc640.tar.gz
rails-fff47a5a5e92eccf949785231d1f6953d6fdc640.tar.bz2
rails-fff47a5a5e92eccf949785231d1f6953d6fdc640.zip
some memoizing and hash equality performance optimizations
Diffstat (limited to 'spec/arel/unit/primitives/attribute_spec.rb')
-rw-r--r--spec/arel/unit/primitives/attribute_spec.rb20
1 files changed, 6 insertions, 14 deletions
diff --git a/spec/arel/unit/primitives/attribute_spec.rb b/spec/arel/unit/primitives/attribute_spec.rb
index e21a5902d5..7e0155f84d 100644
--- a/spec/arel/unit/primitives/attribute_spec.rb
+++ b/spec/arel/unit/primitives/attribute_spec.rb
@@ -4,7 +4,7 @@ module Arel
describe Attribute do
before do
@relation = Table.new(:users)
- @attribute = Attribute.new(@relation, :id)
+ @attribute = @relation[:id]
end
describe Attribute::Transformations do
@@ -45,22 +45,21 @@ module Arel
end
describe Attribute::Congruence do
- describe 'match?' do
-
+ describe '#match?' do
it "obtains if the attributes are identical" do
- Attribute.new(@relation, :name).should be_match(Attribute.new(@relation, :name))
+ @attribute.should be_match(@attribute)
end
it "obtains if the attributes have an overlapping history" do
- Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name)).should be_match(Attribute.new(@relation, :name))
- Attribute.new(@relation, :name).should be_match(Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name)))
+ Attribute.new(@relation, :id, :ancestor => @attribute).should be_match(@attribute)
+ @attribute.should be_match(Attribute.new(@relation, :id, :ancestor => @attribute))
end
end
describe '/' do
before do
@aliased_relation = @relation.alias
- @doubly_aliased_relation = @aliased_relation.alias.alias.alias.alias
+ @doubly_aliased_relation = @aliased_relation.alias
end
describe 'when dividing two identical attributes' do
@@ -85,13 +84,6 @@ module Arel
end
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