brynary / testjour

Distributed test running with autodiscovery via Bonjour (for Cucumber first)

This URL has Read+Write access

commit  f5e5c3060225725430d880dd2442c14c25e3716a
tree    45da8c3e5a563e229251037847705231e78ea7f3
parent  b97b9741f61b2d68fb37f03ab206cdc7b06c3259
testjour / spec / spec_helper.rb
100644 50 lines (38 sloc) 1.048 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require "rubygems"
require "spec"
require "fileutils"
require "net/http"
 
require File.expand_path(File.dirname(__FILE__) + "/../lib/testjour")
require "testjour/http_queue"
 
Spec::Runner.configure do |config|
 
  def start_queue
    $tjqueue_pid = fork do
      Dir.chdir(File.join(File.dirname(__FILE__), "..", "bin"))
      
      silence_stream(STDOUT) do
        silence_stream(STDERR) do
          exec "ruby httpq"
        end
      end
    end
    
    Testjour::HttpQueue.wait_for_service
  end
  
  def shutdown_queue
    Process.kill 9, $tjqueue_pid
    Process.wait($tjqueue_pid)
  end
  
  def get(path)
    require "curb"
    
    @response = Curl::Easy.new("http://0.0.0.0:#{Testjour::HttpQueue.port}" + path)
    @response.perform
    @response_code = @response.response_code
  end
  
  def post(path)
    require "curb"
    
    @response = Curl::Easy.http_post("http://0.0.0.0:#{Testjour::HttpQueue.port}" + path)
    @response.perform
    @response_code = @response.response_code
  end
  
  def response
    @response
  end
  
end