Ian Connor
2006-May-07 07:31 UTC
[Rails] NoMethodError trying to get ApplicationHelper method from a functional test
I am a little confused by the includes I suspect. In the book, it states
that runtime environment will load the directories app, app/models,
app/controllers, app/helpers, app/apis, components, config, lib, vendor and
vendor/rails/*.
However, when I try to access my "current_project" public method, it
fails
with a NoMethodError.
What is even stranger is that I can use reflection to find that the method
is indeed there. For instance, this code:
def test_should_login_and_redirect
ApplicationHelper.public_instance_methods.each do |method|
if method == "current_project"
puts "calling " + method
puts ApplicationHelper.send(method)
end
end
...
Will find the method but then when it is called, it will still complain
yeilding:
Loaded suite test/functional/account_controller_test
Started
..calling current_project
E
Finished in 0.172 seconds.
1) Error:
test_should_login_and_redirect(AccountControllerTest):
NoMethodError: undefined method `current_project'' for
ApplicationHelper:Module
test/functional/account_controller_test.rb:31:in `send''
test/functional/account_controller_test.rb:31:in
`test_should_login_and_redirect''
test/functional/account_controller_test.rb:28:in `each''
test/functional/account_controller_test.rb:28:in
`test_should_login_and_redirect''
3 tests, 4 assertions, 0 failures, 1 errors
So I am really confused how it can know the module is there, be able to find
the method in question and then claim to not know the method at all. If
anyone knows the trick to getting the helpers to be called from the tests,
that would be really appreciated.
--
Regards,
Ian Connor
-----
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=aWFuLmNvbm5vcjEwNTM%3D
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060507/10539330/attachment-0001.html
