[rspec-users] How to set cookies before request spec?

George Dinwiddie lists at iDIAcomputing.com
Thu Feb 16 12:58:14 EST 2012


Meltemi,

On 2/15/12 9:36 PM, Meltemi wrote:
> I can't seem to figure out how to set a cookie for a Request spec? Tried:
>
> before(:each) do
> @user = Fabricate(:user)
> request.cookies[:id_token] = @user.id
> end
>
> but that gives a NoMethodError errors: undefined method `cookies' for
> nil:NilClass

In that snippit, "request" has not been constructed and therefore is nil.

  - George

-- 
  ----------------------------------------------------------------------
   * George Dinwiddie *                      http://blog.gdinwiddie.com
   Software Development                    http://www.idiacomputing.com
   Consultant and Coach                    http://www.agilemaryland.org
  ----------------------------------------------------------------------



More information about the rspec-users mailing list