spec/spec_helper.rb in browsermob-proxy-0.1.4 vs spec/spec_helper.rb in browsermob-proxy-0.1.5
- old
+ new
@@ -7,11 +7,11 @@
module BrowserMob
module Proxy
module SpecHelper
def self.httpd
- @httpd ||= HttpServer.new(Rack::File.new(fixture_dir))
+ @httpd ||= HttpServer.new(SpecApp.new(Rack::File.new(fixture_dir)))
end
def self.fixture_dir
@fixture_dir ||= File.join(File.expand_path("../", __FILE__), "fixtures")
end
@@ -66,9 +66,25 @@
host = ENV['TRAVIS'] ? Selenium::WebDriver::Platform.ip : '0.0.0.0'
"http://#{host}:#{@port}/#{page}"
end
end
+ class SpecApp
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ case env['REQUEST_PATH']
+ when '/slow'
+ sleep 0.1
+ [200, {}, []]
+ else
+ @app.call(env)
+ end
+ end
+
+ end
end
end
end
RSpec.configure do |c|