HttpMock Post Parameters

Does anyone know how you can specify the body of an HttpMock post as
well as the body of the response?

I’m trying to test a restful API where the parameters are posted in in
the body of the post as XML and the response is XML in the response
body.

As far as I can tell, you can only specify one body in a mock object?

Thanks,
Tom

I never got a reply, so either I’m crazy or other people have just
lived with the issue. In any event, I wanted to post my work around.
Rather than creating my mock request/response pairs using the
ActiveResource::HttpMock.respond_to method, I actually had to create
both the request and the response individually and then add them to
the ActiveResource::HttpMock.responses. Here is what I did:

Created my mock request:

request = ActiveResource::Request.new(:post,
path = “/my/path.xml”,
body =
my_request_body_xml_string,
request_headers =
request_headers_hash)

Created my mock response:

response = ActiveResource::Response.new(body =
my_response_body_xml_string,
status = 200,
response_header_hash)

Add the pair to the mock responses:

ActiveResource::HttpMock.responses << [request, response]