diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/arel/crud_spec.rb | 51 | ||||
-rw-r--r-- | spec/arel/select_manager_spec.rb | 3 |
2 files changed, 53 insertions, 1 deletions
diff --git a/spec/arel/crud_spec.rb b/spec/arel/crud_spec.rb new file mode 100644 index 0000000000..ca1b92a041 --- /dev/null +++ b/spec/arel/crud_spec.rb @@ -0,0 +1,51 @@ +module Arel + class FakeCrudder < SelectManager + class FakeEngine + attr_reader :calls + + def initialize + @calls = [] + end + + def connection; self end + + def method_missing name, *args + @calls << [name, args] + end + end + + include Crud + + attr_reader :engine + attr_accessor :ctx + + def initialize engine = FakeEngine.new + super + end + end + + describe 'crud' do + describe 'insert' do + it 'should call insert on the connection' do + table = Table.new :users + fc = FakeCrudder.new + fc.insert [[table[:id], 'foo']] + fc.engine.calls.find { |method, _| + method == :insert + }.should_not be_nil + end + end + + describe 'update' do + it 'should call update on the connection' do + table = Table.new :users + fc = FakeCrudder.new + fc.from table + fc.update [[table[:id], 'foo']] + fc.engine.calls.find { |method, _| + method == :update + }.should_not be_nil + end + end + end +end diff --git a/spec/arel/select_manager_spec.rb b/spec/arel/select_manager_spec.rb index c29754cb55..b6e09ea65e 100644 --- a/spec/arel/select_manager_spec.rb +++ b/spec/arel/select_manager_spec.rb @@ -17,9 +17,10 @@ module Arel def quote_column_name thing; @engine.connection.quote_column_name thing end def quote thing, column; @engine.connection.quote thing, column end - def execute sql + def execute sql, name = nil @executed << sql end + alias :update :execute end describe 'select manager' do |