I have a problem testing an invalid situation, the valid situation without merging params (or merging valid ones) works fine.
Controller: # @user is setted with a filter
def update if @user.update_attributes(params[:user]) redirect_to(user_path(@user)) else render :action => :show end end
Test:
def test_should_not_update_user # Set session values session_company :one login_as :emilio # I choose a name that invalid (is too short) update_user(:name => 's') assert !users(:emilio).errors.empty?, users(:emilio).errors.full_messages assert_response :success end
protected def update_user(options = {}) put :update, :user => { :name => 'Testing name', :street => 'test street', :city => 'Testing City', :zipcode => '556678', :state => 'Testing State', :country => 'Argentina', :password_actual => 'test', :password => 'testing', :password_confirmation => 'testing' }.merge(options) end
Test Output: Started E... Finished in 0.214897 seconds.
1) Error: test_should_not_update_user(UsersControllerTest): TypeError: can't convert nil into String
.....
Why i get an error on invalid name if the controller just render the same page passing user errors...
Thanks in advance!