[rspec-users] Setting Request Body (in stories in particular)

Matt Wynne matt at mattwynne.net
Tue Feb 24 04:46:01 EST 2009

On 19 Feb 2009, at 03:36, Michael Sofaer wrote:

> I'm trying to set my request body in my tests (the application is a
> web service that takes large XML files in PUT requests).
> If you do this:
> put :update, :body => xml
> You get a request with an empty body, and a field in the header called
> "body" set to the XML.  You can set the body date in controller specs
> by calling
> request.env['RAW_POST_DATA'] = xml
> But that doesn't work in stories (request is nil), and it's not very
> elegant, anyway.  Does anyone know how to set a request body in a
> scenario step?

I don't know if you're aware of it, but assuming you're testing a  
Rails app, your scenario steps are running inside a Rails  

The documentation for the #put method is here:


Matt Wynne

More information about the rspec-users mailing list