diff options
Diffstat (limited to 'spec/arel/unit')
-rw-r--r-- | spec/arel/unit/predicates/binary_spec.rb | 17 | ||||
-rw-r--r-- | spec/arel/unit/primitives/attribute_spec.rb | 11 | ||||
-rw-r--r-- | spec/arel/unit/relations/join_spec.rb | 10 |
3 files changed, 13 insertions, 25 deletions
diff --git a/spec/arel/unit/predicates/binary_spec.rb b/spec/arel/unit/predicates/binary_spec.rb index f39b37d913..2d6ef5d7e3 100644 --- a/spec/arel/unit/predicates/binary_spec.rb +++ b/spec/arel/unit/predicates/binary_spec.rb @@ -59,12 +59,21 @@ module Arel describe '#bind' do before do - @another_relation = Table.new(:photos) + @another_relation = @relation.alias end - it "descends" do - ConcreteBinary.new(@attribute1, @attribute2).bind(@another_relation). \ - should == ConcreteBinary.new(@attribute1.bind(@another_relation), @attribute2.bind(@another_relation)) + describe 'when both operands are attributes' do + it "manufactures an expression with the attributes bound to the relation" do + ConcreteBinary.new(@attribute1, @attribute2).bind(@another_relation). \ + should == ConcreteBinary.new(@another_relation[@attribute1], @another_relation[@attribute2]) + end + end + + describe 'when an operand is a value' do + it "manufactures an expression with unmodified values" do + ConcreteBinary.new(@attribute1, "asdf").bind(@another_relation). \ + should == ConcreteBinary.new(@another_relation[@attribute1], "asdf") + end end end end diff --git a/spec/arel/unit/primitives/attribute_spec.rb b/spec/arel/unit/primitives/attribute_spec.rb index 34665b5adf..890ac0e813 100644 --- a/spec/arel/unit/primitives/attribute_spec.rb +++ b/spec/arel/unit/primitives/attribute_spec.rb @@ -45,17 +45,6 @@ module Arel end describe Attribute::Congruence do - describe '#match?' do - it "obtains if the attributes are identical" do - @attribute.should be_match(@attribute) - end - - it "obtains if the attributes have an overlapping history" do - 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 diff --git a/spec/arel/unit/relations/join_spec.rb b/spec/arel/unit/relations/join_spec.rb index 347566e6ea..d128dd0560 100644 --- a/spec/arel/unit/relations/join_spec.rb +++ b/spec/arel/unit/relations/join_spec.rb @@ -55,16 +55,6 @@ module Arel INNER JOIN `photos` ON `users`.`id` = `photos`.`user_id` ") end - - it 'manufactures sql joining the two tables, with selects from the right table in the ON clause' do - 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` AND `photos`.`id` = 2 - WHERE `users`.`id` = 1 - ") - end end describe 'when joining with a string' do |