In one of my project we were reading the cookies so that we could do the processing accordingly. Now reading the cookie is easy but writing a unit test case for that action was little bit tricky for me because I wanted to test the behavior in case of when I find the cookie and when there is no desired cookie in the request. So the question was how to add cookie into the mocked request.
To do this I did the following in my unit test setup
[java]
Cookie cookie = new Cookie("APPNAME", "ABCD")
mockRequest.cookies = [cookie].toArray()
[/java]
Now I can test my action easily :).
Hope it helps
Uday Pratap Singh
uday@intelligrape.com
thanks for the post. but how to check for a value of a cookie?
I think we get something like response.cookies after calling controller action in spec