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:
0.0.0.0
/events?title=cool
80
POST
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
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.
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.
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:inmethod_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:input’
from (irb):8:in test_test' from test/integration/api_test.rb:40:intest_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:inrun’
from /usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:31:inrun’
from /usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:31:inrun’
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:instart_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:inrun’
from /usr/lib/ruby/1.8/test/unit/autorunner.rb:200:in run' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:13:inrun’
from /usr/lib/ruby/1.8/test/unit.rb:285
delete ‘/campaigns/1.xml’, {}, headers
NoMethodError: undefined method recycle!' for #<ActionController::CgiRequest:0xb6ec6f9c> from /var/www/rails/config/../vendor/rails/actionpack/lib/action_controller/cgi_process.rb:139:inmethod_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:indelete’
from (irb):10:in test_test' from test/integration/api_test.rb:40:intest_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:inrun’
from /usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:31:inrun’
from /usr/lib/ruby/1.8/test/unit/testsuite.rb:32:in run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:31:inrun’
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:instart_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:inrun’
from /usr/lib/ruby/1.8/test/unit/autorunner.rb:200:in run' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:13:inrun’
from /usr/lib/ruby/1.8/test/unit.rb:285
from test/integration/api_test.rb:106
ed
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.