diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-21 10:34:11 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-21 10:34:11 -0700 |
commit | 2f0a8ae8d4aed502a0b6c4780d4545c147bdcb47 (patch) | |
tree | 601c2aef98a6fedd5b8a6322685bc300c50c42b9 /spec/engines/sql/unit | |
parent | 862067cf14213ee9df0784250301a1987b3822db (diff) | |
download | rails-2f0a8ae8d4aed502a0b6c4780d4545c147bdcb47.tar.gz rails-2f0a8ae8d4aed502a0b6c4780d4545c147bdcb47.tar.bz2 rails-2f0a8ae8d4aed502a0b6c4780d4545c147bdcb47.zip |
fixing incompatibilities with AR
Diffstat (limited to 'spec/engines/sql/unit')
-rw-r--r-- | spec/engines/sql/unit/engine_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/engines/sql/unit/engine_spec.rb b/spec/engines/sql/unit/engine_spec.rb index f782f56938..85a9dc5bfb 100644 --- a/spec/engines/sql/unit/engine_spec.rb +++ b/spec/engines/sql/unit/engine_spec.rb @@ -1,12 +1,39 @@ require 'spec_helper' module Arel + FakeAR = Struct.new(:connection) + class FakeConnection < Struct.new :called + def initialize c = []; super; end + + def method_missing name, *args, &block + called << [name, args, block] + end + end + describe Sql::Engine do before do @users = Table.new(:users) @users.delete end + describe "method missing" do + it "should pass through" do + conn = FakeConnection.new + engine = Arel::Sql::Engine.new FakeAR.new conn + engine.foo + conn.called.should == [[:foo, [], nil]] + end + + it "should ask for a connection" do + conn = FakeConnection.new + ar = FakeAR.new conn + engine = Arel::Sql::Engine.new ar + + ar.connection = nil + lambda { engine.foo }.should raise_error + end + end + describe "CRUD" do describe "#create" do it "inserts into the relation" do |