aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/attributes/test_attribute.rb6
-rw-r--r--test/test_select_manager.rb7
-rw-r--r--test/test_table.rb7
-rw-r--r--test/visitors/test_join_sql.rb3
-rw-r--r--test/visitors/test_to_sql.rb10
5 files changed, 19 insertions, 14 deletions
diff --git a/test/attributes/test_attribute.rb b/test/attributes/test_attribute.rb
index 06954c242b..df7dc69621 100644
--- a/test/attributes/test_attribute.rb
+++ b/test/attributes/test_attribute.rb
@@ -326,7 +326,7 @@ module Arel
describe '#eq' do
it 'should return an equality node' do
- attribute = Attribute.new nil, nil, nil
+ attribute = Attribute.new nil, nil
equality = attribute.eq 1
equality.left.must_equal attribute
equality.right.must_equal 1
@@ -485,7 +485,7 @@ module Arel
end
it 'should return an in node' do
- attribute = Attribute.new nil, nil, nil
+ attribute = Attribute.new nil, nil
node = Nodes::In.new attribute, [1,2,3]
node.left.must_equal attribute
node.right.must_equal [1, 2, 3]
@@ -538,7 +538,7 @@ module Arel
end
it 'should return a NotIn node' do
- attribute = Attribute.new nil, nil, nil
+ attribute = Attribute.new nil, nil
node = Nodes::NotIn.new attribute, [1,2,3]
node.left.must_equal attribute
node.right.must_equal [1, 2, 3]
diff --git a/test/test_select_manager.rb b/test/test_select_manager.rb
index 0ecc78ce83..db2b306916 100644
--- a/test/test_select_manager.rb
+++ b/test/test_select_manager.rb
@@ -26,6 +26,13 @@ module Arel
def quote_table_name thing; @engine.connection.quote_table_name thing end
def quote_column_name thing; @engine.connection.quote_column_name thing end
def quote thing, column; @engine.connection.quote thing, column end
+ def columns table, message = nil
+ @engine.connection.columns table, message
+ end
+
+ def table_exists? name
+ @engine.connection.table_exists? name
+ end
def execute sql, name = nil, *args
@executed << sql
diff --git a/test/test_table.rb b/test/test_table.rb
index 93cdde8f68..bb7bd255fd 100644
--- a/test/test_table.rb
+++ b/test/test_table.rb
@@ -174,13 +174,6 @@ module Arel
it "manufactures an attribute if the symbol names an attribute within the relation" do
column = @relation[:id]
column.name.must_equal :id
- column.must_be_kind_of Attributes::Integer
- end
- end
-
- describe 'when table does not exist' do
- it 'returns nil' do
- @relation[:foooo].must_be_nil
end
end
end
diff --git a/test/visitors/test_join_sql.rb b/test/visitors/test_join_sql.rb
index 8253fe5ab4..181ef6c570 100644
--- a/test/visitors/test_join_sql.rb
+++ b/test/visitors/test_join_sql.rb
@@ -4,7 +4,8 @@ module Arel
module Visitors
describe 'the join_sql visitor' do
before do
- @visitor = JoinSql.new Table.engine
+ @visitor = ToSql.new Table.engine
+ @visitor.extend(JoinSql)
end
describe 'inner join' do
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index 1c5c8eac0c..04d5e2d39f 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -84,7 +84,7 @@ module Arel
end
it "should visit visit_Arel_Attributes_Time" do
- attr = Attributes::Time.new(@attr.relation, @attr.name, @attr.column)
+ attr = Attributes::Time.new(@attr.relation, @attr.name)
@visitor.accept attr
end
@@ -143,7 +143,9 @@ module Arel
end
in_node = Nodes::In.new @attr, %w{ a b c }
visitor = visitor.new(Table.engine)
- visitor.expected = @attr.column
+ visitor.expected = Table.engine.connection.columns(:users).find { |x|
+ x.name == 'name'
+ }
visitor.accept(in_node).must_equal %("users"."name" IN ('a', 'b', 'c'))
end
end
@@ -189,7 +191,9 @@ module Arel
end
in_node = Nodes::NotIn.new @attr, %w{ a b c }
visitor = visitor.new(Table.engine)
- visitor.expected = @attr.column
+ visitor.expected = Table.engine.connection.columns(:users).find { |x|
+ x.name == 'name'
+ }
visitor.accept(in_node).must_equal %("users"."name" NOT IN ('a', 'b', 'c'))
end
end