[rspec-users] Rspec doesn't pickup the status code correctly.
Steve
vertebrate at gmail.com
Mon Aug 4 00:16:42 EDT 2008
J2M wrote:
> I'm setting the status code on a controller action but rspec doesn't
> seem to be catching it in my spec. It works in the browser.
>
> This is the controller method, called via xhr with header Accept:
> 'application/json'
>
> def validate
> account = Account.new(:login => params[:login])
> account.valid?
> unless (errors = account.errors['login'])
> url = ['http:','', request.host, params[:login]].join('/')
> respond_to do |format|
> format.json { render :json => { :url => url } }
> end
> else
> url = ['http:','', request.host].join('/')
> respond_to do |format|
> format.json { render :json => {:errors => errors, :url =>
> url }, :status => 409}
> end
> end
> end
I don't know if it's the cause, but your unless statement is an
assignment, and not an equality comparison:
unless (errors = account.errors['login'])
Steve
More information about the rspec-users
mailing list