aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-08-16 17:26:12 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-08-16 17:26:12 -0700
commitae547dc139179720a814ae21f43f3e0aaad97c5c (patch)
tree8e3b12ee400c200067676511f976e36486f74fba /spec
parent66243e491d06edf0bff21000adad2837e67c21e2 (diff)
downloadrails-ae547dc139179720a814ae21f43f3e0aaad97c5c.tar.gz
rails-ae547dc139179720a814ae21f43f3e0aaad97c5c.tar.bz2
rails-ae547dc139179720a814ae21f43f3e0aaad97c5c.zip
OR nodes are somewhat working
Diffstat (limited to 'spec')
-rw-r--r--spec/arel/nodes/equality_spec.rb16
-rw-r--r--spec/arel/nodes/or_spec.rb20
-rw-r--r--spec/arel/visitors/to_sql_spec.rb7
3 files changed, 43 insertions, 0 deletions
diff --git a/spec/arel/nodes/equality_spec.rb b/spec/arel/nodes/equality_spec.rb
new file mode 100644
index 0000000000..b74af3a039
--- /dev/null
+++ b/spec/arel/nodes/equality_spec.rb
@@ -0,0 +1,16 @@
+module Arel
+ module Nodes
+ describe 'equality' do
+ describe 'or' do
+ it 'makes an OR node' do
+ attr = Table.new(:users)[:id]
+ left = attr.eq(10)
+ right = attr.eq(11)
+ node = left.or right
+ check node.left.should == left
+ check node.right.should == right
+ end
+ end
+ end
+ end
+end
diff --git a/spec/arel/nodes/or_spec.rb b/spec/arel/nodes/or_spec.rb
new file mode 100644
index 0000000000..e855b92453
--- /dev/null
+++ b/spec/arel/nodes/or_spec.rb
@@ -0,0 +1,20 @@
+module Arel
+ module Nodes
+ describe 'or' do
+ describe '#or' do
+ it 'makes an OR node' do
+ attr = Table.new(:users)[:id]
+ left = attr.eq(10)
+ right = attr.eq(11)
+ node = left.or right
+ check node.left.should == left
+ check node.right.should == right
+
+ oror = node.or(right)
+ check oror.left == node
+ check oror.right == right
+ end
+ end
+ end
+ end
+end
diff --git a/spec/arel/visitors/to_sql_spec.rb b/spec/arel/visitors/to_sql_spec.rb
index 554b69a5bd..b70c392630 100644
--- a/spec/arel/visitors/to_sql_spec.rb
+++ b/spec/arel/visitors/to_sql_spec.rb
@@ -8,6 +8,13 @@ module Arel
@attr = Table.new(:users)[:id]
end
+ it "should visit_Arel_Nodes_Or" do
+ node = Nodes::Or.new @attr.eq(10), @attr.eq(11)
+ @visitor.accept(node).should be_like %{
+ "users"."id" = 10 OR "users"."id" = 11
+ }
+ end
+
it "should visit visit_Arel_Attributes_Time" do
attr = Attributes::Time.new(@attr.relation, @attr.name, @attr.column)
@visitor.accept attr