Q:

How can I test a Rails RESTful API post request with xml as input?

I am adding a RESTful API to the Rails Tutorial sample app. The controller actions should take XML as input and respond with XML. I am trying to follow a TDD approach but have been unable to find a definitive method of making a post request. Here are my tests, as best as I've written them so far:
it "should increment the Relationship count" do
  expect do
    # valid_xml = "<xml><:followed_id>#{other_user.id}</:followed_id></xml>"
    valid_xml = { followed_id: other_user.id }.to_xml
    post :create, relationship: valid_xml, format: 'xml', content_type: 'application/xml'
  end.to change(Relationship, :count).by(1)
end

it "should respond with success" do
  # valid_xml = "<xml><:followed_id>#{other_user.id}</:followed_id></xml>"
  valid_xml = { followed_id: other_user.id }.to_xml
  post :create, relationship: valid_xml, format: :xml, content_type: 'application/xml'
  expect(response).to be_success
end

This particular test is verifying that posting XML will create a new Relationship. As you can see, I have tried several ways to specify that the input is XML. Here is the controller action:
class RelationshipsController < ApplicationController
  before_action :signed_in_user
  respond_to :html, :js, :xml 

  def create
    # Problem is that the xml is not being read as such; it's a string
    relationship = params[:relationship]
    puts relationship
    puts relationship[:followed_id]
    @user = User.find(relationship[:followed_id])
    current_user.follow!(@user)
    respond_with @user 
  end

For the given tests, the controller prints out relationship as XML but errors on the following line, where it attempts to get the value of key :followed_id. The error is TypeError: no implicit conversion of Symbol into Integer for both tests. 
I assume that this means that the type of relationship is a string, not a hash, and Ruby thinks that the bracket is supposed to be an index. Does anyone know where I am going wrong, either in the test or the controller action?
Are there any better ways to test a RESTful API or gems I should use?

A:

The XML parameters parser was removed from core in Rails 4.0. This was due to several vulnerabilities and the fact that most API´s worth using today are JSON or moving towards JSON.
The removed functionality is available from the actionpack-xml_parser gem.

