[rspec-users] Low level HTTP server mocking

Ian Vaughan ianrvaughan at gmail.com
Sat Jan 14 16:57:28 EST 2012


I have a class which creates a WEBrick::HTTPServer, and in my tests I 
obviously do not want to instantiate/open this server, as (a) its a 
resource waste (b) would hang the test (c) is not under-test.

So :-

1. How can I stub it out?

2. How can I mock the call to #mount_proc, such that, when my dir/route 
gets hit, the real code runs?
Or put another way, I want to test that my mapping/routing is correct, such 
that if I get "/", my HTTPServer, I get "hello" back.

I want to use as least amount of external libs as possible, so to learn 
whats going on. (ie not yet use webmock/fakeweb/etc)
Code : http://pastie.org/3186140
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120114/de22b340/attachment.html>

More information about the rspec-users mailing list