Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewland committed Feb 9, 2009
1 parent 6d40422 commit 6280b4f
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions spec/spec_helper.rb
Expand Up @@ -6,6 +6,7 @@
require 'spec/interop/test'
require 'stringio'
require 'webrick'
require File.expand_path(File.dirname(__FILE__) + "/../lib/rack_rubygems.rb")

Sinatra::Default.set(
:environment => :test,
Expand All @@ -14,16 +15,14 @@
:logging => true
)

require File.expand_path(File.dirname(__FILE__) + "/../lib/rack_rubygems.rb")

module RackRubygemsTestHelpers

def should_match_webrick_behavior(url, server_method, method = :get)
#webrick
data = StringIO.new "#{method.to_s.capitalize} #{url} HTTP/1.0\r\n\r\n"
@webrick_request.parse data

@webrick.send(server_method, @webrick_request, @webrick_response)

#sinatra
send(method, url)
@response.should be_ok
Expand All @@ -40,10 +39,6 @@ def should_match_webrick_behavior(url, server_method, method = :get)
}
end

def process_based_port
@@process_based_port ||= 8000 + $$ % 1000
end

end

Spec::Runner.configure do |config|
Expand All @@ -53,10 +48,10 @@ def process_based_port
use Rack::Compress
run RackRubygems.new
}
@webrick = Gem::Server.new Gem.dir, process_based_port, false
@webrick = Gem::Server.new Gem.dir, (8000 + $$ % 1000), false
@webrick_request = WEBrick::HTTPRequest.new :Logger => nil
@webrick_response = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
}
config.include Sinatra::Test
config.include RackRubygemsTestHelpers
end
end

0 comments on commit 6280b4f

Please sign in to comment.