aboutsummaryrefslogtreecommitdiffstats
path: root/spec/active_relation/predicates/binary_spec.rb
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-12 18:57:22 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-01-12 18:57:22 -0800
commit45d2557ae097da1e5dd3dc532444233b4fed0b31 (patch)
tree5b114baa2fe0791435b750d2251f5453263f84e5 /spec/active_relation/predicates/binary_spec.rb
parentc2cbe7bb27b6cd2e136ac06f4f36d6de0ec52459 (diff)
downloadrails-45d2557ae097da1e5dd3dc532444233b4fed0b31.tar.gz
rails-45d2557ae097da1e5dd3dc532444233b4fed0b31.tar.bz2
rails-45d2557ae097da1e5dd3dc532444233b4fed0b31.zip
missing files
Diffstat (limited to 'spec/active_relation/predicates/binary_spec.rb')
-rw-r--r--spec/active_relation/predicates/binary_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/active_relation/predicates/binary_spec.rb b/spec/active_relation/predicates/binary_spec.rb
new file mode 100644
index 0000000000..02c72ef96d
--- /dev/null
+++ b/spec/active_relation/predicates/binary_spec.rb
@@ -0,0 +1,42 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+describe ActiveRelation::Predicates::Binary do
+ before do
+ @relation1 = ActiveRelation::Relations::Table.new(:foo)
+ @relation2 = ActiveRelation::Relations::Table.new(:bar)
+ @attribute1 = ActiveRelation::Primitives::Attribute.new(@relation1, :name1)
+ @attribute2 = ActiveRelation::Primitives::Attribute.new(@relation2, :name2)
+ class ActiveRelation::Predicates::ConcreteBinary < ActiveRelation::Predicates::Binary
+ def predicate_sql
+ "<=>"
+ end
+ end
+ end
+
+ describe '==' do
+ it "obtains if attribute1 and attribute2 are identical" do
+ ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2).should == ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2)
+ ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2).should_not == ActiveRelation::Predicates::Binary.new(@attribute1, @attribute1)
+ end
+
+ it "obtains if the concrete type of the ActiveRelation::Predicates::Binarys are identical" do
+ ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2).should == ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2)
+ ActiveRelation::Predicates::Binary.new(@attribute1, @attribute2).should_not == ActiveRelation::Predicates::ConcreteBinary.new(@attribute1, @attribute2)
+ end
+ end
+
+ describe '#qualify' do
+ it "distributes over the predicates and attributes" do
+ ActiveRelation::Predicates::ConcreteBinary.new(@attribute1, @attribute2).qualify. \
+ should == ActiveRelation::Predicates::ConcreteBinary.new(@attribute1.qualify, @attribute2.qualify)
+ end
+ end
+
+ describe '#to_sql' do
+ it 'manufactures correct sql' do
+ ActiveRelation::Predicates::ConcreteBinary.new(@attribute1, @attribute2).to_sql.should be_like("""
+ `foo`.`name1` <=> `bar`.`name2`
+ """)
+ end
+ end
+end \ No newline at end of file