Felix Elliger
2009-Feb-13 12:16 UTC
[rspec-users] [Cucumber] Http Post just returns status code and not Response-object
Hi, I''m really new to cucumber-testing. I want to use an HTTP Post in my step-definitions using the post-method. When I execute response = post ''/controller/action'' response is of type Fixnum and contains only the status code returned by the post. In rspec it returns an HTTPResponse-instance. Why is it different? I really need the body of the response. Hope somebody can help me.
aslak hellesoy
2009-Feb-13 14:11 UTC
[rspec-users] [Cucumber] Http Post just returns status code and not Response-object
On Fri, Feb 13, 2009 at 1:16 PM, Felix Elliger <felix.elliger at student.hpi.uni-potsdam.de> wrote:> Hi, > > I''m really new to cucumber-testing. I want to use an HTTP Post in my > step-definitions using the post-method. > When I execute > > response = post ''/controller/action'' >I''m guessing you''re using Cucumber with Rails. Cucumber step definitions (when used with Rails) run in an instance of Rails'' ActionController::IntegrationTest. If you read that API you''ll see that the #response method gives you access to what you need. If you haven''t used WebRat, I strongly recommend you check it out. It''s a thin DSL on top of ActionController::IntegrationTest that Cucumber supports out of the box. It lets you write steps on the HTML level rather than the HTTP level. Aslak> response is of type Fixnum and contains only the status code returned by the > post. In rspec it returns an HTTPResponse-instance. > > Why is it different? I really need the body of the response. > > Hope somebody can help me. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Aslak (::)
Felix Elliger
2009-Feb-13 14:37 UTC
[rspec-users] [Cucumber] Http Post just returns status code and not Response-object
aslak hellesoy schrieb:> On Fri, Feb 13, 2009 at 1:16 PM, Felix Elliger > <felix.elliger at student.hpi.uni-potsdam.de> wrote: > >> Hi, >> >> I''m really new to cucumber-testing. I want to use an HTTP Post in my >> step-definitions using the post-method. >> When I execute >> >> response = post ''/controller/action'' >> >> > > I''m guessing you''re using Cucumber with Rails. Cucumber step > definitions (when used with Rails) run in an instance of Rails'' > ActionController::IntegrationTest. If you read that API you''ll see > that the #response method gives you access to what you need. > > If you haven''t used WebRat, I strongly recommend you check it out. > It''s a thin DSL on top of ActionController::IntegrationTest that > Cucumber supports out of the box. It lets you write steps on the HTML > level rather than the HTTP level. > > Aslak > > >> response is of type Fixnum and contains only the status code returned by the >> post. In rspec it returns an HTTPResponse-instance. >> >> Why is it different? I really need the body of the response. >> >> Hope somebody can help me. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > > >Thanks, that helped a lot.