Forum: RSpec Testing parameter passed to controller new method (undefined method 'stringify_keys')

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
502aedbe2f12b6245c2e1f88227dfd3e?d=identicon&s=25 Justin F. (justindfunk)
on 2012-04-18 16:06
I'm trying to test passing a parameter to the new method of my
controller and am coming up with the "undefined method 'stringify_keys'"
error when I use this code:

get "new", { :company_id => '1' }

I have seen other solutions to this issue, but they have all centered
around the create method and either using FactoryGirl.attributes_for or
making a deeper hash like { :object => { :company_id => 1 } }.  I don't
think either of these solutions are appropriate.

The logic I'm using involves CanCan, where I don't want the user to be
able to load up the 'new' page unless they've got a valid company id.

If the only way to do what I want really is to use the full object hash,
then I need an update for my view test which is validating the new link,
currently like so:

rendered.should have_selector 'a',
:content => 'Add Object',
:href => '/menus/new?company_id=' +

I'm using Rails 3.2.3 and rspec 2.9
This topic is locked and can not be replied to.