So I have a working site and have a good amount of experience with Rails
from building it. I recently decided it was time to start writing
tests. Yeah, thanks, I know I should have done it earlier.
I''m jumping straight into integration tests because that''s
what I need
right now. I''ll write other tests later.
I am really struggling with getting a simple test working. There seem
to be strange class loading issues, a subject that I''m not an expert
in.
First it took me a while to figure out I had to have this line at the
head of my tests:
require "#{File.dirname(__FILE__)}/../test_helper"
I''m passed that now though. Some tests work. For instance, I can do
this:
get("/foo")
# assert_redirected_to "http://www.foobar.com"
follow_redirect!
assert_response :success
But when I uncomment that assert_redirected_to line, I get an exception
(with abbreviated stack trace):
NameError: uninitialized constant ApplicationController
...
my_controller.rb
...
my_test.rb
I also get an exception when I try to load one of my models, e.g.
User.find_by_username("foobar")
This one is even stranger as my exception looks like this:
NoMethodError: undefined method `foobar'' for #<User:0x362a324>
Where foobar is a method in my User class which is always used in my
application (it''s a low level permissions thing) and is most definitely
defined.
What is going on here? It''s driving me nuts.
Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---