How are people testing REST webservices that require you to POST xml data? Are you using the post and get shortcuts in your tests, or net::http? With the post shortcut is there any way to specify you want to send xml instead of regular old parameters? I tried this in one of my controller tests for creating a thing post :create, {:title => "cool"}, {''Content-Type'' => ''application/ xml''} puts @request.env.to_xml puts @response.headers.to_xml And sadly the request env didn''t include Content-Type. It only has: <REMOTE-ADDR>0.0.0.0</REMOTE-ADDR> <REQUEST-URI>/events?title=cool</REQUEST-URI> <SERVER-PORT type="integer">80</SERVER-PORT> <REQUEST-METHOD>POST</REQUEST-METHOD> So I''m not sure what I''m doing wrong with sending headers. And also I''d like to specify some xml to send instead of URL params. According to the rdocs post takes these parameters: path, parameters, headers Thanks! Andy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
you can set these: @request.env[''Content-Type''] = ''application/xml'' @request.env["HTTP_ACCEPT"] = ''application/xml'' as for posting XML, I just use the to_xml methods, but it''s not as slick as I''d like it to be either. anyone else? ed On 2/12/07, Andy Triboletti <andy-kRVt9sEkMUDQT0dZR+AlfA@public.gmane.org> wrote:> > > How are people testing REST webservices that require you to POST xml > data? Are you using the post and get shortcuts in your tests, or > net::http? > > With the post shortcut is there any way to specify you want to send > xml instead of regular old parameters? > > I tried this in one of my controller tests for creating a thing > post :create, {:title => "cool"}, {''Content-Type'' => ''application/ > xml''} > puts @request.env.to_xml > puts @response.headers.to_xml > > And sadly the request env didn''t include Content-Type. It only has: > <REMOTE-ADDR>0.0.0.0</REMOTE-ADDR> > <REQUEST-URI>/events?title=cool</REQUEST-URI> > <SERVER-PORT type="integer">80</SERVER-PORT> > <REQUEST-METHOD>POST</REQUEST-METHOD> > > > So I''m not sure what I''m doing wrong with sending headers. And also > I''d like to specify some xml to send instead of URL params. > > According to the rdocs post takes these parameters: > path, parameters, headers > > > Thanks! > Andy > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2/12/07, Ed Hickey <bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> you can set these: > @request.env[''Content-Type''] = ''application/xml'' > @request.env["HTTP_ACCEPT"] = ''application/xml'':format => :xml. Much easier :)> as for posting XML, I just use the to_xml methods, but it''s not as slick as > I''d like it to be either.I use integration tests to post XML. Functional tests bypass the param parsers IIRC. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Can you elaborate on how you''re using to_xml to post the data? What do you put as the name on that value? post :create, {"RAW_POST_DATA" => things.to_xml} , :format => :xml On Feb 12, 2007, at 4:06 PM, Ed Hickey wrote:> you can set these: > @request.env[''Content-Type''] = ''application/xml'' > @request.env["HTTP_ACCEPT"] = ''application/xml'' > > as for posting XML, I just use the to_xml methods, but it''s not as > slick as I''d like it to be either. > > anyone else? > > ed > > On 2/12/07, Andy Triboletti <andy-kRVt9sEkMUDQT0dZR+AlfA@public.gmane.org> wrote: > > How are people testing REST webservices that require you to POST xml > data? Are you using the post and get shortcuts in your tests, or > net::http? > > With the post shortcut is there any way to specify you want to send > xml instead of regular old parameters? > > I tried this in one of my controller tests for creating a thing > post :create, {:title => "cool"}, {''Content-Type'' => ''application/ > xml''} > puts @request.env.to_xml > puts @response.headers.to_xml > > And sadly the request env didn''t include Content-Type. It only has: > <REMOTE-ADDR>0.0.0.0</REMOTE-ADDR> > <REQUEST-URI>/events?title=cool</REQUEST-URI> > <SERVER-PORT type="integer">80</SERVER-PORT> > <REQUEST-METHOD>POST</REQUEST-METHOD> > > > So I''m not sure what I''m doing wrong with sending headers. And also > I''d like to specify some xml to send instead of URL params. > > According to the rdocs post takes these parameters: > path, parameters, headers > > > Thanks! > Andy > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > I use integration tests to post XML. Functional tests bypass the > param parsers IIRC.Would you mind posting or linking to a snippet of an intergration test that posts/puts XML? I''ve been messing with it for awhile and can''t get the rails to parse the XML into a params hash. It works if I pass a hash, but not an XML string. thanks, ed --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2/16/07, Ed Hickey <bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I use integration tests to post XML. Functional tests bypass the > > param parsers IIRC. > > Would you mind posting or linking to a snippet of an intergration test that > posts/puts XML? I''ve been messing with it for awhile and can''t get the > rails to parse the XML into a params hash. It works if I pass a hash, but > not an XML string.sess.post ''/foos.xml'', Foo.new(...).to_xml, :content_type => ''application/xml'' -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
it seems like that only works for get and post...or am i missing something? eg:>> headers = {:content_type=>"application/xml", :http_authorization=>"BasiccXVlbnRpbjp0ZXM0\n"}>> get ''/campaigns/1.xml'', {}, headers=> 200>> post ''/campaigns.xml'', {:name => "test 123"}.to_xml(:root => "campaign"),headers => 201>> put ''/campaigns/1.xml'', {:name => "test 123"}.to_xml(:root =>"campaign"), headers NoMethodError: undefined method `recycle!'' for #<ActionController::CgiRequest:0xb6f928a4> from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/cgi_process.rb:139:in `method_missing'' from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:370:in `process'' from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:353:in `put'' from (irb):8:in `test_test'' from test/integration/api_test.rb:40:in `test_test'' from /usr/lib/ruby/1.8/test/unit/testcase.rb:70:in `run'' from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:453:in `run'' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in `run'' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:31:in `run'' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in `run'' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:31:in `run'' from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:44:in `run_suite'' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:65:in `start_mediator'' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:39:in `start'' from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:27:in `run'' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:200:in `run'' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:13:in `run'' from /usr/lib/ruby/1.8/test/unit.rb:285>> delete ''/campaigns/1.xml'', {}, headersNoMethodError: undefined method `recycle!'' for #<ActionController::CgiRequest:0xb6ec6f9c> from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/cgi_process.rb:139:in `method_missing'' from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:370:in `process'' from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:353:in `delete'' from (irb):10:in `test_test'' from test/integration/api_test.rb:40:in `test_test'' from /usr/lib/ruby/1.8/test/unit/testcase.rb:70:in `run'' from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/integration.rb:453:in `run'' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in `run'' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:31:in `run'' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in `run'' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:31:in `run'' from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:44:in `run_suite'' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:65:in `start_mediator'' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:39:in `start'' from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:27:in `run'' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:200:in `run'' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:13:in `run'' from /usr/lib/ruby/1.8/test/unit.rb:285 from test/integration/api_test.rb:106 ed On 2/16/07, Rick Olson <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 2/16/07, Ed Hickey <bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I use integration tests to post XML. Functional tests bypass the > > > param parsers IIRC. > > > > Would you mind posting or linking to a snippet of an intergration test > that > > posts/puts XML? I''ve been messing with it for awhile and can''t get the > > rails to parse the XML into a params hash. It works if I pass a hash, > but > > not an XML string. > > > sess.post ''/foos.xml'', Foo.new(...).to_xml, :content_type => > ''application/xml'' > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---