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

160aea3e8d6463bd2c38a32a7496a1f2?d=identicon&s=25 Justin Funk (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=' + company.id.to_s

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