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

Posted by 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.