On Aug 4, 5:16 am, Steve <[EMAIL PROTECTED]> wrote: > 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'])
That's just me being lazy I'm assigning errors I could have put that as; errors = account.errors['login'] if account.errors['login'] But it isn't the cause as it works in the wild, it is just the spec that fails. Thanks, James _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users