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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users