I have implemented an API to be used like
curl -X POST -H ''Content-type: application/xml'' -d
''<user><login>john</
login><password>123456</password></user>''
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 = ''<user>
<login>phibo</login>
<email>phibo-3Fe+ZXUaJ0F2KDkfy0k2sw@public.gmane.org</email>
<password>somesecret</password>
</user>''
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..)