Integration test api call with xml body

I have implemented an API to be used like

curl -X POST -H ‘Content-type: application/xml’ -d ‘john</
login>123456’
http://0.0.0.0:3000/users/register

and the above call works like charm. However, I can’t figure out how
to test this. The best I could come up with is using an integration
test like:

def test_user_registration

assert_difference(‘User.count’) do
xml = ‘
phibo
[email protected]
somesecret

post_via_redirect 'users/register', :user => xml, :content_type =>

‘application/xml’
end
end

This test actually calls the correct method on the users_controller,
however, the params[:user] yields unparsed XML instead of the usual
hash. Any idea how to do this?

(Yes, I do plan to use cucumber, rspec and webrat in the future, but
for now I have to do it the hard way…)

ok, solved it myself using an integration test like this:

assert_difference('User.count') do
  xml = "<user>
          <login>phibo</login>
          <email>[email protected]</email>
          <password>somesecret</password>
         </user>"

  post 'api/users/register', xml, :content_type => 'application/

xml’
end

assert_response :created