Skip to content

Commit

Permalink
Added a basic test for the informix visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Khronos committed May 16, 2011
1 parent 85da419 commit ca6e7f7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/arel/visitors.rb
Expand Up @@ -11,6 +11,7 @@
require 'arel/visitors/order_clauses'
require 'arel/visitors/dot'
require 'arel/visitors/ibm_db'
require 'arel/visitors/informix'

module Arel
module Visitors
Expand All @@ -24,6 +25,7 @@ module Visitors
'sqlite' => Arel::Visitors::SQLite,
'sqlite3' => Arel::Visitors::SQLite,
'ibm_db' => Arel::Visitors::IBM_DB,
'informix' => Arel::Visitors::Informix,
}

ENGINE_VISITORS = Hash.new do |hash, engine|
Expand Down
34 changes: 34 additions & 0 deletions test/visitors/test_informix.rb
@@ -0,0 +1,34 @@
require 'helper'

module Arel
module Visitors
describe 'the informix visitor' do
before do
@visitor = Informix.new Table.engine
end

it 'uses LIMIT n to limit results' do
stmt = Nodes::SelectStatement.new
stmt.limit = Nodes::Limit.new(1)
sql = @visitor.accept(stmt)
sql.must_be_like "SELECT LIMIT 1"
end

it 'uses LIMIT n in updates with a limit' do
stmt = Nodes::UpdateStatement.new
stmt.limit = Nodes::Limit.new(1)
stmt.key = 'id'
sql = @visitor.accept(stmt)
sql.must_be_like "UPDATE NULL WHERE 'id' IN (SELECT LIMIT 1 'id')"
end

it 'uses SKIP n to jump results' do
stmt = Nodes::SelectStatement.new
stmt.offset = Nodes::Offset.new(10)
sql = @visitor.accept(stmt)
sql.must_be_like "SELECT SKIP 10"
end

end
end
end

0 comments on commit ca6e7f7

Please sign in to comment.