[I sent this before, but didn''t see it on the list. Sorry if this repeats for anyone..] I''m having a bit of trouble getting functional tests running on Rails 0.11.1. On a freshly generated controller, with the default test class, and when running a pretty simple test (get :new), I get the following failure (file paths shortened for clarity): 1) Error: test_new(TaskControllerTest): NoMethodError: undefined method `controller_path'' for TaskController:Class actionpack-1.7.0/lib/action_controller/test_process.rb:257:in `process'' (eval):3:in `get'' efforttrack-dev/test/functional/task_controller_test.rb:20:in `test_new'' If I remove the reopened TaskController at the top of the test, the stack makes it pretty clear that the framework can''t find my controller: 1) Error: test_new(TaskControllerTest): NameError: uninitialized constant Controllers::TaskController activesupport-1.0.3/lib/active_support/dependencies.rb:69:in `const_missing'' activesupport-1.0.3/lib/active_support/dependencies.rb:175:in `const_get'' activesupport-1.0.3/lib/active_support/dependencies.rb:175:in `const_missing'' efforttrack-dev/test/functional/task_controller_test.rb:9:in `setup_without_fixtures'' activerecord-1.9.1/lib/active_record/fixtures.rb:450:in `setup'' activerecord-1.9.1/lib/active_record/fixtures.rb:448:in `setup'' The code for this particular test is: require File.dirname(__FILE__) + ''/../test_helper'' require ''task_controller'' # Re-raise errors caught by the controller. #class TaskController; def rescue_action(e) raise e end; end class TaskControllerTest < Test::Unit::TestCase def setup @controller = TaskController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_truth assert true end def test_new get :new assert_success end end Unit tests run fine. Just having trouble with even the simplest functional tests. The application also runs fine, seemingly finding the controllers (although it doesn''t do much, as I''m attempting to go test-driven, and thus I''m not driving very fast right now). -- David Naseby http://homepages.ihug.com.au/~naseby/
In your taskcontroller you have a method called ''new'' defined? David Naseby wrote:>[I sent this before, but didn''t see it on the list. Sorry if this >repeats for anyone..] > >I''m having a bit of trouble getting functional tests running on Rails >0.11.1. On a freshly generated controller, with the default test >class, and when running a pretty simple test (get :new), I get the >following failure (file paths shortened for clarity): > > 1) Error: > test_new(TaskControllerTest): > NoMethodError: undefined method `controller_path'' for >TaskController:Class >actionpack-1.7.0/lib/action_controller/test_process.rb:257:in >`process'' > (eval):3:in `get'' > efforttrack-dev/test/functional/task_controller_test.rb:20:in `test_new'' > >If I remove the reopened TaskController at the top of the test, the >stack makes it pretty clear that the framework can''t find my >controller: > > 1) Error: >test_new(TaskControllerTest): >NameError: uninitialized constant Controllers::TaskController > activesupport-1.0.3/lib/active_support/dependencies.rb:69:in `const_missing'' > activesupport-1.0.3/lib/active_support/dependencies.rb:175:in `const_get'' > activesupport-1.0.3/lib/active_support/dependencies.rb:175:in >`const_missing'' > efforttrack-dev/test/functional/task_controller_test.rb:9:in >`setup_without_fixtures'' > activerecord-1.9.1/lib/active_record/fixtures.rb:450:in `setup'' > activerecord-1.9.1/lib/active_record/fixtures.rb:448:in `setup'' > >The code for this particular test is: > > require File.dirname(__FILE__) + ''/../test_helper'' > require ''task_controller'' > > # Re-raise errors caught by the controller. > #class TaskController; def rescue_action(e) raise e end; end > > class TaskControllerTest < Test::Unit::TestCase > def setup > @controller = TaskController.new > @request = ActionController::TestRequest.new > @response = ActionController::TestResponse.new > end > > def test_truth > assert true > end > > def test_new > get :new > assert_success > end > end > >Unit tests run fine. Just having trouble with even the simplest >functional tests. The application also runs fine, seemingly finding >the controllers (although it doesn''t do much, as I''m attempting to go >test-driven, and thus I''m not driving very fast right now). > >
On Apr 11, 2005 7:48 AM, Tim Case <bk-itakfFKLDA/2IRrHB3mpnw@public.gmane.org> wrote:> In your taskcontroller you have a method called ''new'' defined?My TaskController is default, as generated by script/generate Task new list delete So, yes, it has a #new method. The problem isn''t the class itself, it''s the test framework failing to find the class in $: (I think) I''m running on XP, if that helps anyone.. David
On Apr 10, 2005 9:26 PM, David Naseby <naseby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The problem isn''t the class itself, > it''s the test framework failing to find the class in $: (I think)Have you seen this? http://rubyurl.com/86SDQ This will be fixed in Ruby 1.8.3. Unfortunately, it appears that Tiger ships with 1.8.2, so I bet we''re going to get to answer this question a lot... :-/ -- Nathaniel <:((><
I had this problem, and it was due to a syntax error in my controller class. Try running ruby -c on your controller class and see if it produces any errors. HTH, Chris On Apr 11, 2005 2:26 AM, David Naseby <naseby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 11, 2005 7:48 AM, Tim Case <bk-itakfFKLDA/2IRrHB3mpnw@public.gmane.org> wrote: > > In your taskcontroller you have a method called ''new'' defined? > > My TaskController is default, as generated by > script/generate Task new list delete > > So, yes, it has a #new method. The problem isn''t the class itself, > it''s the test framework failing to find the class in $: (I think) > > I''m running on XP, if that helps anyone.. > > David > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 4/11/05, David Naseby <naseby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m having a bit of trouble getting functional tests running on Rails > 0.11.1. On a freshly generated controller, with the default test > class, and when running a pretty simple test (get :new), I get the > following failure (file paths shortened for clarity): > > 1) Error: > test_new(TaskControllerTest): > NoMethodError: undefined method `controller_path'' for > TaskController:Class > actionpack-1.7.0/lib/action_controller/test_process.rb:257:in > `process'' > (eval):3:in `get'' > efforttrack-dev/test/functional/task_controller_test.rb:20:in `test_new'' > > If I remove the reopened TaskController at the top of the test, the > stack makes it pretty clear that the framework can''t find my > controller:For the benefit of anyone else as silly as me, I''ll just send the list the resolution of this error: turned out, I had a model class called Application. It was modelling applications for positions, so the name wasn''t bad.. but of course, it had a file "application.rb" in the require path. The same name as the file for the ApplicationController class. So ApplicationController was never found. This was made difficult to track down because of the amount of fiddling Rails does behind the scenes with require paths and auto-require for models. I doubt there is much that can be done to prevent this by the framework, but it would be nice if the ApplicationController resided in a file called "application_controller.rb", or a mangled "__application_controller.rb", to stay out of the way a bit. -- David Naseby http://homepages.ihug.com.au/~naseby/