Skip to content
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

Activesupport dependencies failing test #19897

Closed

Conversation

amatsuda
Copy link
Member

I found a test case that doesn't start with test_ in AS/test. So I renamed it, then I found that it's actually not passing.
The test case expects a NameError when AS tries to autoload ModuleFolder::NestedClass::Object, but in fact it autoloads ModuleFolder::NestedClass and returns ::Object with warning: toplevel constant Object referenced by ModuleFolder::NestedClass::Object.
I'm not sure what is the desired fix here. What do you think, @fxn?

Accessing `ModuleFolder::NestedClass::Object` does not raise NameError but returns ::Object with
warning: toplevel constant Object referenced by ModuleFolder::NestedClass::Object
@pixeltrix
Copy link
Contributor

@amatsuda I'm pretty sure that @seckar knew this was a failing test when he wrote it (hence the failing_ prefix) because at the time and still today there is no way to make the test fully pass. It's checking that top level constants are not being returned by autoloading, which works for the case when the parent constant is a module but not for when the parent is a class. This is because the ancestor chain for a class includes Object but a module's ancestor chain doesn't, e.g:

>> module Foo; end
>> Foo.ancestors
=> [Foo]

vs.

>> class Bar; end
>> Bar.ancestors
=> [Bar, Object, Kernel, BasicObject]

Unfortunately, Ruby returns Object before calling const_missing so there's no way we can hook into anything to prevent it happening. Maybe we should speak to the Ruby core team to see if they can suggest something.

@amatsuda amatsuda closed this in 6b7bfec Jan 30, 2017
@amatsuda amatsuda deleted the activesupport_dependencies_failing_test branch January 30, 2017 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants