Here is the error for update in rspec:
4) CustomersController GET customer page 'update' should be successful
Failure/Error: post 'update', customer
NoMethodError:
undefined method `symbolize_keys' for "1":String
# ./spec/controllers/customers_controller_spec.rb:38:in `block (3 levels) in <top (required)>'
The rspec code:
it "'update' should be successful" do
customer = Factory(:customer)
post 'update', customer
response.should be_success
end
The update in customers controller:
def update
@customer = Customer.find(params[:id])
if @customer.update_attributes(params[:customer], :as => :roles_new_update)
if @customer.changed
@message = 'The following info have been changed\n' + @customer.changes.to_s
@subject ='Customer info was changed BY' + session[:user_name]
notify_all_in_sales_eng(@message,@subject)
end
redirect_to session[('page'+session[:page_step].to_s).to_sym], :notice => 'Customer was updated successfaully!'
else
render 'edit', :notice => 'Customer was not updated!'
end
end
Any thoughts about the error? Thanks.
I will not enter into details on RSpec, but I just met the same error and this is how I would correct it for your code:
I think you can’t provide your object directly to the
postmethod, you must pass it’sidas in aHashinstead.(Please note too that this code assumes your customer exists in the test database, so your Factory must
createit.)