Ben Taitelbaum Ben Taitelbaum - 1 year ago 60
Ruby Question

Launching a web server inside ruby tests

I'm writing a library to wrap tsung's functionality in a way that can be better used by rails applications. I want to write some integration tests that boil down to the following:

  1. launch a simple web server

  2. run tsung-recorder via the library

  3. launch selenium, with a firefox profile configured to use the tsung proxy, and have this fetch a page from the server launched in step 1

  4. examine the recorded library (it exists, it's in the correct location, etc.)

For step 1, while I could launch a vanilla rails app externally (e.g.,
%x{rails s}
), I'm pretty sure there's a better way to programmatically create a simple web server suitable for testing.

tl;dr - What's a way to programmatically launch a simple web server inside a test?

Answer Source

capybara uses an ad-hoc Rack server for its specs:

Any Rack app (including Rails applications) can be served using this system, though the Rails configuration might get a bit tricky.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download