kevin cline
2007-Dec-07 16:47 UTC
Rails Recipe 44 -- Write Tests for Your Helpers [Corrected]
I''m having trouble getting this to work. The recipe is simple: def setup @controller = SomeController.new request = ActionController::TestRequest.new @controller.instance_eval { @params = {}, @request = request } @controller.send(:initialize_current_url) end But with Rails 1.2.3 I''m getting this error: 1) Error: test_x(ApplicationHelperTest): TypeError: can''t clone NilClass C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:1082:in `clone'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:1082:in `initialize_current_url'' application_helper_test.rb:20:in `send'' application_helper_test.rb:20:in `setup_without_fixtures'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/ lib/active_record/fixtures.rb:576:in `setup'' Any ideas? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
clarkware
2007-Dec-07 16:58 UTC
Re: Rails Recipe 44 -- Write Tests for Your Helpers [Corrected]
On Dec 7, 9:47 am, kevin cline <kevin.cl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m having trouble getting this to work. > > The recipe is simple: > > def setup > @controller = SomeController.new > request = ActionController::TestRequest.new > @controller.instance_eval { @params = {}, @request = request } > @controller.send(:initialize_current_url) > end > > But with Rails 1.2.3 I''m getting this error: > > 1) Error: > test_x(ApplicationHelperTest): > > TypeError: can''t clone NilClass > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ > action_controller/base.rb:1082:in `clone'' > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ > action_controller/base.rb:1082:in `initialize_current_url''I think that''s changed to since the original Recipes book was published, and it''s now: @controller.instance_variable_set(:@url, (ActionController::UrlRewriter.new @request, {})) A setup that works for me is: def setup super @request = ActionController::TestRequest.new @controller = StubController.new @controller.request = @request @controller.instance_variable_set(:@url, (ActionController::UrlRewriter.new @request, {})) ActionView::Helpers::AssetTagHelper::reset_javascript_include_default end Cheers, Mike --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---