-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error in @dispatch_cache default value #188
base: master
Are you sure you want to change the base?
Conversation
How about this test? diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb
index 40702bc..d05ca85 100644
--- a/test/psych/visitors/test_yaml_tree.rb
+++ b/test/psych/visitors/test_yaml_tree.rb
@@ -116,6 +116,15 @@ module Psych
assert_cycle 1...2
end
+ def test_basic_object
+ assert_raises(TypeError) do
+ @v.accept Class.new(BasicObject) {
+ def object_id; 9001; end
+ def respond_to?(*args); false; end
+ }.new
+ end
+ end
+
def test_anon_class
assert_raises(TypeError) do
@v.accept Class.new |
Ah ha, clever. I can add to the PR. |
@srawlins please add it, and I'll merge. Thanks! |
Actually, @tenderlove that test doesn't work. >> BasicObject.new.class
NoMethodError: undefined method `class' for #<BasicObject:0x007f8e23899a78> and adding I don't see how its possible to force the accessor of |
I'm not sure whether you are trying to test my error - but this is what I get:
when I try to (well actually it's delayed_job trying but anyhow) serialize an ActiveRecord class method like this:
and the file descriptor gets built like this:
[ I know that pushing temporary file descriptors into serialized objects are not necessarily the best design option - but if you were looking for a use case .... here you have it (that is - if this is at all, what you are trying to test) ] :) |
The exception in @dispatch_cache's default value has an error(
target
is not a thing; raises "undefined local variable or method `target' for... "). This fixes that. (Also, the other exceptions in this file have a lowercase "can't".)What was really fun is trying to test this. That exception should never ever ever be raised, unless Ruby does something crazy to force the accessor of
@dispatch_cache
to somehow returnnil
. The only way I could do it is with a crazy test:Which I'm sure you don't want to commit. So only the fix is in this PR.