aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/crud_spec.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-08-23 13:28:08 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-08-23 13:28:08 -0700
commit8966434f2a0d7aaff5fdea26b40dc37e89fee239 (patch)
tree00a162631b5af1752f77041d2ad59d362dd31396 /spec/arel/crud_spec.rb
parent2579fec805f23903dd6c4f1726198e010f5a9a54 (diff)
downloadrails-8966434f2a0d7aaff5fdea26b40dc37e89fee239.tar.gz
rails-8966434f2a0d7aaff5fdea26b40dc37e89fee239.tar.bz2
rails-8966434f2a0d7aaff5fdea26b40dc37e89fee239.zip
making sure update delegates to update and insert delegates to insert
Diffstat (limited to 'spec/arel/crud_spec.rb')
-rw-r--r--spec/arel/crud_spec.rb51
1 files changed, 51 insertions, 0 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