aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/nodes/equality_spec.rb18
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/fake_record.rb15
3 files changed, 26 insertions, 9 deletions
diff --git a/spec/nodes/equality_spec.rb b/spec/nodes/equality_spec.rb
index 81eea4d482..f1ed7a6904 100644
--- a/spec/nodes/equality_spec.rb
+++ b/spec/nodes/equality_spec.rb
@@ -26,6 +26,24 @@ module Arel
check left.right.should == left.operand2
end
end
+
+ describe 'to_sql' do
+ it 'takes an engine' do
+ engine = FakeRecord::Base.new
+ engine.connection.extend Module.new {
+ attr_accessor :quote_count
+ def quote(*args) @quote_count += 1; super; end
+ def quote_column_name(*args) @quote_count += 1; super; end
+ def quote_table_name(*args) @quote_count += 1; super; end
+ }
+ engine.connection.quote_count = 0
+
+ attr = Table.new(:users)[:id]
+ test = attr.eq(10)
+ test.to_sql engine
+ check engine.connection.quote_count.should == 2
+ end
+ end
end
describe 'or' do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 0031f6903f..b9fd9db930 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -13,6 +13,6 @@ Spec::Runner.configure do |config|
config.include Check
config.before do
- Arel::Table.engine = Arel::Sql::Engine.new(FakeRecord::Base)
+ Arel::Table.engine = Arel::Sql::Engine.new(FakeRecord::Base.new)
end
end
diff --git a/spec/support/fake_record.rb b/spec/support/fake_record.rb
index 2aba0c10f2..30c49f2b16 100644
--- a/spec/support/fake_record.rb
+++ b/spec/support/fake_record.rb
@@ -63,14 +63,11 @@ module FakeRecord
class Spec < Struct.new(:config)
end
- attr_reader :spec
+ attr_reader :spec, :connection
def initialize
@spec = Spec.new('sqlite3')
- end
-
- def connection
- Connection.new
+ @connection = Connection.new
end
def with_connection
@@ -79,11 +76,13 @@ module FakeRecord
end
class Base
- def self.connection_pool
- ConnectionPool.new
+ attr_accessor :connection_pool
+
+ def initialize
+ @connection_pool = ConnectionPool.new
end
- def self.connection
+ def connection
connection_pool.connection
end
end