[Mongrel] Testing custom mongrel handlers?
Zed A. Shaw
zedshaw at zedshaw.com
Sun Nov 5 19:33:45 EST 2006
On Sun, 5 Nov 2006 13:29:00 -0800
Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:
> Hey Folks-
> I'm trying to setup a new test/spec harness for testing Merb. I was
> wondering if there is a way to mock the Mongrel request, response
> objects easily to test my handler without actually running a server?
> I can easily do the env hash but I'm not entirely sure what needs to
> go in the request StringIO object that gets passed into my mongrel
> handler's #process method. Is there a good way to do this? Or should
> I just fire up a server and use net/http to test it?
It's pretty easy until you get to the StringIO. Basically, you put whatever encoded data would go into the body of the request. So, multipart mime, form posts, etc.
You *might* be able to steal some of that from say RFuzz and then do an internal mock kind of thing.
Normally though, I just use rfuzz to write an external testing setup and skip the mock stuff completely.
Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu
http://safari.oreilly.com/0321483502 -- The Mongrel Book
http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
More information about the Mongrel-users