# TypeError while doing tests

**URL:** <https://www.ruby-forum.com/t/typeerror-while-doing-tests/109250>\
**Category:** Rails\
**Created:** [July 12, 2007, 6:57pm UTC](https://www.ruby-forum.com/t/typeerror-while-doing-tests/109250 "2007-07-12T18:57:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![visaolive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/57b2e6/32.png) [@visaolive](https://www.ruby-forum.com/u/visaolive)\
**Post date:** [July 12, 2007, 6:57pm UTC](https://www.ruby-forum.com/t/typeerror-while-doing-tests/109250/1 "2007-07-12T18:57:51Z")

</div>

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!
