Reputation: 8595
I am writing some specs for helpers that check for values in the params variable. Until now I have been doing:
helper.stub!(:params).and_return(:user => {:username => "jack"})
The problem is that while the actual params Hash has string/symbol-agnostic keys and params[:user] == params["user"]
, my implementation does not and produces various failures where it should not.
Is there a way to set the proper (key-type agnostic) params variable in helper specs?
Upvotes: 2
Views: 1676
Reputation: 50057
THe easiest way to do this is to use with_indifferent_access
.
In your case :
helper.stub!(:params).and_return({:user => {:username => "jack"}}.with_indifferent_access)
Upvotes: 5