diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/arel/tree_manager.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/arel/tree_manager.rb b/spec/arel/tree_manager.rb new file mode 100644 index 0000000000..513b41e305 --- /dev/null +++ b/spec/arel/tree_manager.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +module Arel + describe 'tree manager' do + describe 'where' do + it "knows where" do + table = Table.new :users + manager = Arel::TreeManager.new Table.engine + manager.from(table).project(table['id']) + manager.where(table['id'].eq(1)) + manager.to_sql.should == %{ + SELECT "users"."id" + FROM "users" + WHERE "users"."id" = 1 + }.gsub("\n", '').gsub(/(^\s*|\s*$)/, '').squeeze(' ') + end + + it "chains" do + table = Table.new :users + manager = Arel::TreeManager.new Table.engine + manager.from(table) + manager.project(table['id']).where(table['id'].eq 1).should == manager + end + end + + describe 'from' do + it "makes sql" do + table = Table.new :users + manager = Arel::TreeManager.new Table.engine + + manager.from table + manager.project table['id'] + manager.to_sql.should == 'SELECT "users"."id" FROM "users"' + end + + it "chains" do + table = Table.new :users + manager = Arel::TreeManager.new Table.engine + manager.from(table).project(table['id']).should == manager + manager.to_sql.should == 'SELECT "users"."id" FROM "users"' + end + end + end +end |