Forum: RSpec Setting Request Body (in stories in particular)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3991f1dedc443618e34241312283dc60?d=identicon&s=25 Michael Sofaer (Guest)
on 2009-02-23 17:14
(Received via mailing list)
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?
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2009-02-24 10:59
(Received via mailing list)
On 19 Feb 2009, at 03:36, Michael Sofaer wrote:

>
> 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
ActionController::Integration::Session

The documentation for the #put method is here:

http://api.rubyonrails.org/classes/ActionControlle...


Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
This topic is locked and can not be replied to.