Testing With Grackle

9 views
Skip to first unread message

Ben

unread,
Apr 19, 2010, 5:49:25 PM4/19/10
to Grackle Development
How are folks testing methods that call Grackle functions?

My first thought was to use something like FakeWeb that would catch
the HTTP request to a specific URL and return whatever I wanted.
However, I haven't been able to make that work (entirely possible I'm
going it wrong), so I thought I'd see what others are doing. Since
Grackle uses method_missing heavily, it feels sort of silly to stub
out a Grackle::Client object that expects a certain method call (like
you would with other objects you didn't actually want to call in your
tests). Is my instinct wrong with this, or... what are other people
doing that tests your use of Grackle, rather than testing Grackle its
self? Thanks!


Ben


--
Subscription settings: http://groups.google.com/group/gracklerb/subscribe?hl=en

Hayes Davis

unread,
Apr 19, 2010, 7:24:15 PM4/19/10
to Grackle Development
Ben,

Though I've not done it personally, the FakeWeb approach sounds pretty
reasonable. That seems like you'd be ensuring the most realistic use
of Grackle. What I do to test Grackle itself is to fake out the
Grackle::Transport. You can pretty readily subclass this and implement
your own request method to intercept everything that Grackle is
actually sending and receiving (or you can just mock it). You can tell
Grackle::Client to use your transport by saying client.transport =
foo_transport. Take a look at MockTransport in the test_client.rb unit
test case to see how I've done it.

Hayes
Reply all
Reply to author
Forward
0 new messages