OSDN Git Service

Replaced mongrel with thin
[redminele/redminele.git] / ruby / lib / ruby / gems / 1.8 / gems / thin-1.2.11-x86-mswin32 / spec / server / swiftiply_spec.rb
1 require File.dirname(__FILE__) + '/../spec_helper'
2
3 if SWIFTIPLY_PATH.empty?
4   warn "Ignoring Server on Swiftiply specs, gem install swiftiply to run"
5 else
6   describe Server, 'on Swiftiply' do
7     before do
8       @swiftiply = fork do
9         exec "#{SWIFTIPLY_PATH} -c #{File.dirname(__FILE__)}/swiftiply.yml"
10       end
11       wait_for_socket('0.0.0.0', 3333)
12       sleep 2 # HACK ooh boy, I wish I knew how to make those specs more stable...
13       start_server('0.0.0.0', 5555, :backend => Backends::SwiftiplyClient, :wait_for_socket => false) do |env|
14         body = env.inspect + env['rack.input'].read
15         [200, { 'Content-Type' => 'text/html' }, body]
16       end
17     end
18     
19     it 'should GET from Net::HTTP' do
20       Net::HTTP.get(URI.parse("http://0.0.0.0:3333/?cthis")).should include('cthis')
21     end
22   
23     it 'should POST from Net::HTTP' do
24       Net::HTTP.post_form(URI.parse("http://0.0.0.0:3333/"), :arg => 'pirate').body.should include('arg=pirate')
25     end
26   
27     after do
28       stop_server
29       Process.kill(9, @swiftiply)
30     end
31   end
32 end