diff options
Diffstat (limited to 'spec/engines')
-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 |