aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'test/nodes')
-rw-r--r--test/nodes/test_ascending.rb34
-rw-r--r--test/nodes/test_descending.rb34
-rw-r--r--test/nodes/test_infix_operation.rb4
3 files changed, 70 insertions, 2 deletions
diff --git a/test/nodes/test_ascending.rb b/test/nodes/test_ascending.rb
new file mode 100644
index 0000000000..0e2c4810c6
--- /dev/null
+++ b/test/nodes/test_ascending.rb
@@ -0,0 +1,34 @@
+require 'helper'
+
+module Arel
+ module Nodes
+ class TestAscending < MiniTest::Unit::TestCase
+ def test_construct
+ ascending = Ascending.new 'zomg'
+ assert_equal 'zomg', ascending.expr
+ end
+
+ def test_reverse
+ ascending = Ascending.new 'zomg'
+ descending = ascending.reverse
+ assert_kind_of Descending, descending
+ assert_equal ascending.expr, descending.expr
+ end
+
+ def test_direction
+ ascending = Ascending.new 'zomg'
+ assert_equal :asc, ascending.direction
+ end
+
+ def test_ascending?
+ ascending = Ascending.new 'zomg'
+ assert ascending.ascending?
+ end
+
+ def test_descending?
+ ascending = Ascending.new 'zomg'
+ assert !ascending.descending?
+ end
+ end
+ end
+end
diff --git a/test/nodes/test_descending.rb b/test/nodes/test_descending.rb
new file mode 100644
index 0000000000..424f8298cd
--- /dev/null
+++ b/test/nodes/test_descending.rb
@@ -0,0 +1,34 @@
+require 'helper'
+
+module Arel
+ module Nodes
+ class TestDescending < MiniTest::Unit::TestCase
+ def test_construct
+ descending = Descending.new 'zomg'
+ assert_equal 'zomg', descending.expr
+ end
+
+ def test_reverse
+ descending = Descending.new 'zomg'
+ ascending = descending.reverse
+ assert_kind_of Ascending, ascending
+ assert_equal descending.expr, ascending.expr
+ end
+
+ def test_direction
+ descending = Descending.new 'zomg'
+ assert_equal :desc, descending.direction
+ end
+
+ def test_ascending?
+ descending = Descending.new 'zomg'
+ assert !descending.ascending?
+ end
+
+ def test_descending?
+ descending = Descending.new 'zomg'
+ assert descending.descending?
+ end
+ end
+ end
+end
diff --git a/test/nodes/test_infix_operation.rb b/test/nodes/test_infix_operation.rb
index db3216eeee..3d2eb0d9c6 100644
--- a/test/nodes/test_infix_operation.rb
+++ b/test/nodes/test_infix_operation.rb
@@ -21,9 +21,9 @@ module Arel
def test_opertaion_ordering
operation = InfixOperation.new :+, 1, 2
ordering = operation.desc
- assert_kind_of Ordering, ordering
+ assert_kind_of Descending, ordering
assert_equal operation, ordering.expr
- assert_equal :desc, ordering.direction
+ assert ordering.descending?
end
end
end