diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/nodes/test_as.rb | 16 | ||||
-rw-r--r-- | test/visitors/test_to_sql.rb | 6 |
2 files changed, 22 insertions, 0 deletions
diff --git a/test/nodes/test_as.rb b/test/nodes/test_as.rb new file mode 100644 index 0000000000..8585fbc963 --- /dev/null +++ b/test/nodes/test_as.rb @@ -0,0 +1,16 @@ +require 'helper' + +module Arel + module Nodes + describe 'As' do + describe '#as' do + it 'makes an AS node' do + attr = Table.new(:users)[:id] + as = attr.as(Arel.sql('foo')) + assert_equal attr, as.left + assert_equal 'foo', as.right + end + end + end + end +end diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb index 89f3f60de2..037fca9931 100644 --- a/test/visitors/test_to_sql.rb +++ b/test/visitors/test_to_sql.rb @@ -38,6 +38,12 @@ module Arel sql.must_be_like "NOT foo" end + it "should visit_As" do + as = Nodes::As.new(Arel.sql("foo"), Arel.sql("bar")) + sql = @visitor.accept as + sql.must_be_like "foo AS bar" + end + it "should visit_Bignum" do @visitor.accept 8787878092 end |