I know I didn't post my response too long ago but after a bit of sleep
I've decided that if I can't get some sort of testing for AMF done
then I can't really use it right now. I'm happy to spend the time
creating the test helper and will release anything I create under the
same licence as RubyAMF. But it would be really helpful if some of you
guys who have more knowledge about how RubyAMF works internally could
give me a pointer here and there that would be great.
But firstly is what I want to do even possible. I gave up in the early
hours of the morning when I had something like this to try and
serialize an example request:
amfobj = AMFObject.new
amfbody = AMFBody.new( "", "", obj[:body] )
amfobj.add_body( amfbody )
AMFSerializer.new(amfobj).run
But that didn't work out very well.
I could do with knowing what the absolute minimum is for an amfobj for
the Serializer to do it's work, and how to create stuff like the body
-- e.g. what is the AMFBody.new expecting as it's value param?
On Feb 28, 1:58 am, David Spurr <david.sp...@gmail.com> wrote:
> Well I'm trying to knock together some sort of helper that would aid
> functional testing with RubyAMF.
> My idea goes along the lines of this:
> Have a helper that defines a post_amf method, using this from your
> functional tests would be just like using the standard post method.
> Inside the post_amf method it switches out the controller your testing
> for the amf controller and sets things up e.g.:
> amf_post :index, [ :param = 'something' ]
> 1. Serializes the request, with the source set to the name of the
> controller your testing & the method name to the one you passed in and
> the params put into the body.
> 2. Switches out the @controller for the amf controller
> 3. Set anything else up set as the content type on the request
> 4. Calls the gateway method on the amf controller with the params
> (which should now be serialized to amf)
> 5. Switches back the @controller to what it was
> If that works then that 'should' be calling the amf gateway with
> exactly what it needs and everything 'should' be doing things as if
> they were a normal request.
> Then you would also need a helper method to test that the response was
> AMF (e.g. used the format.amf) and something to convert that (or do it
> after the end of the send) back to something you can test.
> I know I'm over-simplifying things there (as I have spent the past
> couple of hours trying to get my head around how Rails functional
> tests mock out the requests and RubyAMF works to do the above) and I
> haven't gotten very far see the pastie code:http://pastie.caboo.se/158549
> That code has it calling the gateway how I envisioned it, but I'm
> really stuck on trying to serialize something that the gateway would
> accept as a valid amf request.