[LRUG] Serialising a struct

Stephen Nelson-Smith sanelson at gmail.com
Mon Apr 14 07:07:09 PDT 2014


I'm working with some code that makes use of the new AWS SDK (
https://github.com/aws/aws-sdk-core-ruby) to retrieve data from (and make
calls into) AWS.

My responsibility (ie the stuff I want to test) is once I've got the data,
which I get from the aws-sdk-core library in the form of structs.
Obviously I don't want to keep calling AWS when testing, so I'm using a
test double.

What's the best way to make a struct available as canned data?  I can view
the data I want as a struct using pry... or I can dump the API response
using VCR, but neither really helps.  The API is actually just XML, and I
can't work out how to serialise the struct so I can get it back again as a
struct... Marshal doesn't support dumping from a Struct, JSON gives me a
string representation, and YAML gives me a Psych::Nodes::Document object...

Any ideas?

S.

-- 
Stephen Nelson-Smith
Technical Director
Atalanta Systems Ltd
www.atalanta-systems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140414/26ac4d80/attachment.html>


More information about the Chat mailing list