Search code examples
rubywebrick

How do I test a crawler? ie: mock web requests


So I'm testing the individual parts of my crawler and now I've hit a stump: mocking the actual requests.

I don't want to make a request every time I run a spec.

Anyone ever tried starting a webrick server in the test helper?

Something like

myserver = SomeServerLib.start('localhost', some_port)
myserver.serve_directory(a_directory_with_some_html_files)

Thanks!


Solution

  • You can mock the HTTP request and use expectations. See Webmock project.