1up4developers logo

1up4developers

Nadando contra o Waterfall. tail -f /mind/realworld >> /blog

MinionServer - a Real Server to Mock Servers!

| | Comments


MinionServer is a ruby gem to help you with integration tests. You can create an app using Rack Builder and start a tiny server very easy. Let me show you some code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'minion_server'

# build your integration app
IntegrationApp = Rack::Builder.new do
  map "/" do
    run lambda { |env|
      [200, {"Content-Type" => "text/plain"}, ["Be happy!"]]
    }
  end
end

server = MinionServer.new(IntegrationApp)
server.start("localhost", 1620)  # default: localhost, 4000

# do your calls
system "curl http://localhost:1620" # => "Be happy!"

server.shutdown

You can see more examples at http_monkey’s integration tests. Hope that helps!

pt-br moment: Está em inglês porque eu publiquei no coderwall e depois tive a idéia brilhante de postar aqui, com a preguiça mais brilhante ainda de traduzir em pt-br.

Comments