Hi everybody I have some basic problems with my functional tests. In my controller, I have the method "index" and "list". def index list render :action => ''list'' end def list @person_pages, @persons = paginate :persons, :per_page => 200 end Now I would like to test the controller. So I wrote the test-method like the following: def setup @controller = CurrencyController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_index get :index assert_response :success assert_template ''list'' end But it doesn''t work! Why? I receive only these error message:>NoMethodError: You have a nil object when you didn''t expect it!You might have expected an instance of Array. The error occured while evaluating nil.- -- 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 -~----------~----~----~----~------~----~------~--~---
We''ll need more information, as what you''ve posted looks fine. What line is the NoMethodError thrown from? Jason On 12/12/06, M. R. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi everybody > > I have some basic problems with my functional tests. In my controller, I > have the method "index" and "list". > > def index > list > render :action => ''list'' > end > > def list > @person_pages, @persons = paginate :persons, :per_page => 200 > end > > > Now I would like to test the controller. So I wrote the test-method like > the following: > > def setup > @controller = CurrencyController.new > @request = ActionController::TestRequest.new > @response = ActionController::TestResponse.new > end > > def test_index > get :index > assert_response :success > assert_template ''list'' > end > > But it doesn''t work! Why? I receive only these error message: > >NoMethodError: You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.- > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs wrote:> We''ll need more information, as what you''ve posted looks fine. What line > is > the NoMethodError thrown from? > > Jason/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/transactions.rb:112:in `unlock_mutex'' /ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/fixtures.rb:534:in `teardown'' -- 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 -~----------~----~----~----~------~----~------~--~---
Are you properly pulling in fixtures into your tests (fixtures :persons)? Is your data schema in working order (migrations, fixture YAML files, etc)? Jason On 12/12/06, M. R. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Jason Roelofs wrote: > > We''ll need more information, as what you''ve posted looks fine. What line > > is > > the NoMethodError thrown from? > > > > Jason > > /ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4 > /lib/active_record/transactions.rb:112:in > `unlock_mutex'' > > /ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4 > /lib/active_record/fixtures.rb:534:in > `teardown'' > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs wrote:> Are you properly pulling in fixtures into your tests (fixtures > :persons)? > > Is your data schema in working order (migrations, fixture YAML files, > etc)? > > JasonYes, I pulling fixtures into my tests. About my data schema. I clone with rake the whole structure to the test environment. -- 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 -~----------~----~----~----~------~----~------~--~---