diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-11 17:57:02 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-11 17:57:02 -0800 |
commit | f8700038afdaea80cad34a4fca005e1ef068b53e (patch) | |
tree | 0a8c99108b6f7a52bc134bc63e7c8bd1d5f32bee /activerecord/test/cases | |
parent | fcd8925f236b391d562dc504bcd901f501140c11 (diff) | |
download | rails-f8700038afdaea80cad34a4fca005e1ef068b53e.tar.gz rails-f8700038afdaea80cad34a4fca005e1ef068b53e.tar.bz2 rails-f8700038afdaea80cad34a4fca005e1ef068b53e.zip |
adding a test for no method error
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/association_proxy_test.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/association_proxy_test.rb b/activerecord/test/cases/associations/association_proxy_test.rb new file mode 100644 index 0000000000..55d8da4c4e --- /dev/null +++ b/activerecord/test/cases/associations/association_proxy_test.rb @@ -0,0 +1,52 @@ +require "cases/helper" + +module ActiveRecord + module Associations + class AsssociationProxyTest < ActiveRecord::TestCase + class FakeOwner + attr_accessor :new_record + alias :new_record? :new_record + + def initialize + @new_record = false + end + end + + class FakeReflection < Struct.new(:options, :klass) + def initialize options = {}, klass = nil + super + end + + def check_validity! + true + end + end + + class FakeTarget + end + + class FakeTargetProxy < AssociationProxy + def association_scope + true + end + + def find_target + FakeTarget.new + end + end + + def test_method_missing_error + reflection = FakeReflection.new({}, Object.new) + owner = FakeOwner.new + proxy = FakeTargetProxy.new(owner, reflection) + + exception = assert_raises(NoMethodError) do + proxy.omg + end + + assert_match('omg', exception.message) + assert_match(FakeTarget.name, exception.message) + end + end + end +end |