From 07f7f752fecb56316456f144c121e471fd0d0847 Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sun, 16 Mar 2008 16:17:13 -0700 Subject: renamed operators - equals / eq - greater_than / gt - etc. --- .../unit/primitives/attribute_spec.rb | 22 +++++++++++----------- .../unit/relations/deletion_spec.rb | 2 +- spec/active_relation/unit/relations/join_spec.rb | 10 +++++----- .../unit/relations/relation_spec.rb | 2 +- spec/active_relation/unit/relations/update_spec.rb | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) (limited to 'spec') diff --git a/spec/active_relation/unit/primitives/attribute_spec.rb b/spec/active_relation/unit/primitives/attribute_spec.rb index bdd22721b3..a0f6cde8f7 100644 --- a/spec/active_relation/unit/primitives/attribute_spec.rb +++ b/spec/active_relation/unit/primitives/attribute_spec.rb @@ -16,7 +16,7 @@ module ActiveRelation describe '#bind' do it "manufactures an attribute with the relation bound and self as an ancestor" do - derived_relation = @relation.select(@relation[:id].equals(1)) + derived_relation = @relation.select(@relation[:id].eq(1)) @attribute.bind(derived_relation).should == Attribute.new(derived_relation, @attribute.name, :ancestor => @attribute) end @@ -95,33 +95,33 @@ module ActiveRelation @attribute = Attribute.new(@relation, :name) end - describe '#equals' do + describe '#eq' do it "manufactures an equality predicate" do - @attribute.equals('name').should == Equality.new(@attribute, 'name') + @attribute.eq('name').should == Equality.new(@attribute, 'name') end end - describe '#less_than' do + describe '#lt' do it "manufactures a less-than predicate" do - @attribute.less_than(10).should == LessThan.new(@attribute, 10) + @attribute.lt(10).should == LessThan.new(@attribute, 10) end end - describe '#less_than_or_equal_to' do + describe '#lteq' do it "manufactures a less-than or equal-to predicate" do - @attribute.less_than_or_equal_to(10).should == LessThanOrEqualTo.new(@attribute, 10) + @attribute.lteq(10).should == LessThanOrEqualTo.new(@attribute, 10) end end - describe '#greater_than' do + describe '#gt' do it "manufactures a greater-than predicate" do - @attribute.greater_than(10).should == GreaterThan.new(@attribute, 10) + @attribute.gt(10).should == GreaterThan.new(@attribute, 10) end end - describe '#greater_than_or_equal_to' do + describe '#gteq' do it "manufactures a greater-than or equal-to predicate" do - @attribute.greater_than_or_equal_to(10).should == GreaterThanOrEqualTo.new(@attribute, 10) + @attribute.gteq(10).should == GreaterThanOrEqualTo.new(@attribute, 10) end end diff --git a/spec/active_relation/unit/relations/deletion_spec.rb b/spec/active_relation/unit/relations/deletion_spec.rb index 27d879e96f..71ddd8d820 100644 --- a/spec/active_relation/unit/relations/deletion_spec.rb +++ b/spec/active_relation/unit/relations/deletion_spec.rb @@ -15,7 +15,7 @@ module ActiveRelation end it 'manufactures sql deleting a selection relation' do - Deletion.new(@relation.select(@relation[:id].equals(1))).to_sql.should be_like(" + Deletion.new(@relation.select(@relation[:id].eq(1))).to_sql.should be_like(" DELETE FROM `users` WHERE `users`.`id` = 1 diff --git a/spec/active_relation/unit/relations/join_spec.rb b/spec/active_relation/unit/relations/join_spec.rb index a0e94a5b65..515c9ce0f2 100644 --- a/spec/active_relation/unit/relations/join_spec.rb +++ b/spec/active_relation/unit/relations/join_spec.rb @@ -5,12 +5,12 @@ module ActiveRelation before do @relation1 = Table.new(:users) @relation2 = Table.new(:photos) - @predicate = @relation1[:id].equals(@relation2[:user_id]) + @predicate = @relation1[:id].eq(@relation2[:user_id]) end describe '==' do before do - @another_predicate = @relation1[:id].equals(1) + @another_predicate = @relation1[:id].eq(1) @another_relation = Table.new(:cameras) end @@ -96,8 +96,8 @@ module ActiveRelation end it 'manufactures sql joining the two tables, merging any selects' do - Join.new("INNER JOIN", @relation1.select(@relation1[:id].equals(1)), - @relation2.select(@relation2[:id].equals(2)), @predicate).to_sql.should be_like(" + Join.new("INNER JOIN", @relation1.select(@relation1[:id].eq(1)), + @relation2.select(@relation2[:id].eq(2)), @predicate).to_sql.should be_like(" SELECT `users`.`id`, `users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id` FROM `users` INNER JOIN `photos` ON `users`.`id` = `photos`.`user_id` @@ -149,7 +149,7 @@ module ActiveRelation end it "keeps selects on the aggregation within the derived table" do - Join.new("INNER JOIN", @relation1, @aggregation.select(@aggregation[:user_id].equals(1)), @predicate).to_sql.should be_like(" + Join.new("INNER JOIN", @relation1, @aggregation.select(@aggregation[:user_id].eq(1)), @predicate).to_sql.should be_like(" SELECT `users`.`id`, `users`.`name`, `photo_count`.`user_id`, `photo_count`.`cnt` FROM `users` INNER JOIN (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` WHERE `photos`.`user_id` = 1 GROUP BY `photos`.`user_id`) AS `photo_count` diff --git a/spec/active_relation/unit/relations/relation_spec.rb b/spec/active_relation/unit/relations/relation_spec.rb index b562ec2a2a..b5e204abcf 100644 --- a/spec/active_relation/unit/relations/relation_spec.rb +++ b/spec/active_relation/unit/relations/relation_spec.rb @@ -45,7 +45,7 @@ module ActiveRelation describe Relation::Operations do describe 'joins' do before do - @predicate = @relation[:id].equals(@relation[:id]) + @predicate = @relation[:id].eq(@relation[:id]) end describe '#join' do diff --git a/spec/active_relation/unit/relations/update_spec.rb b/spec/active_relation/unit/relations/update_spec.rb index 485c86372d..9053f292d6 100644 --- a/spec/active_relation/unit/relations/update_spec.rb +++ b/spec/active_relation/unit/relations/update_spec.rb @@ -36,7 +36,7 @@ module ActiveRelation describe 'when the relation is a selection' do before do @update = Update.new( - @relation.select(@relation[:id].equals(1)), + @relation.select(@relation[:id].eq(1)), @relation[:name] => "nick".bind(@relation) ) end -- cgit v1.2.3