diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-19 09:26:11 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-19 10:24:16 -0800 |
commit | 6519df4157a861c9c9d567ee57983ded0e967a10 (patch) | |
tree | 14de75a1542137d115b67b6ba81d69a65d8f8cbe /activerecord/test/cases/migration/command_recorder_test.rb | |
parent | 6dbbfae5638a6c847fd63d52a72247e2bb15a320 (diff) | |
download | rails-6519df4157a861c9c9d567ee57983ded0e967a10.tar.gz rails-6519df4157a861c9c9d567ee57983ded0e967a10.tar.bz2 rails-6519df4157a861c9c9d567ee57983ded0e967a10.zip |
command recorder will record commands sent to a delegate object
Diffstat (limited to 'activerecord/test/cases/migration/command_recorder_test.rb')
-rw-r--r-- | activerecord/test/cases/migration/command_recorder_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration/command_recorder_test.rb b/activerecord/test/cases/migration/command_recorder_test.rb index 50d75e0400..ea2292dda5 100644 --- a/activerecord/test/cases/migration/command_recorder_test.rb +++ b/activerecord/test/cases/migration/command_recorder_test.rb @@ -7,6 +7,28 @@ module ActiveRecord @recorder = CommandRecorder.new end + def test_respond_to_delegates + recorder = CommandRecorder.new(Class.new { + def america; end + }.new) + assert recorder.respond_to?(:america) + end + + def test_send_calls_super + assert_raises(NoMethodError) do + @recorder.send(:create_table, :horses) + end + end + + def test_send_delegates_to_record + recorder = CommandRecorder.new(Class.new { + def create_table(name); end + }.new) + assert recorder.respond_to?(:create_table), 'respond_to? create_table' + recorder.send(:create_table, :horses) + assert_equal [[:create_table, [:horses]]], recorder.commands + end + def test_unknown_commands_raise_exception @recorder.record :execute, ['some sql'] assert_raises(ActiveRecord::IrreversibleMigration) do |