Rails Recipe 44 -- Write Tests for Your Helpers

I’m having trouble getting this to work.

The recipe is simple:

def setup
@controll = 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:ininitialize_current_url’
application_helper_test.rb:20:in send' application_helper_test.rb:20:insetup_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

kevin cline wrote:

I’m having trouble getting this to work.

The recipe is simple:

def setup
@controll = 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):

your controller instance variable is named: “@controll” but then you are
using another variable by the name of “@controller” (which happens to
be nil in this case

ilan

On Dec 7, 10:38 am, Ilan B. [email protected]
wrote:

end

But with Rails 1.2.3 I’m getting this error:

  1. Error:
    test_x(ApplicationHelperTest):

your controller instance variable is named: “@controll” but then you are
using another variable by the name of “@controller” (which happens to
be nil in this case

Thanks. Unfortunately, that error is only in the post, and not in the
code.

On 7 Dec 2007, at 16:11, kevin cline wrote:

end

This looks out of date - looking at the source it would seem like the
name of the magic instance variables are now @_params and @_request
(better yet use the accessors)

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs