Sha256: dd4789f123c209b4f15f8770dce3680528d8c17c7bb5eccc698d3ce0386ff2c1
Contents?: true
Size: 789 Bytes
Versions: 2
Compression:
Stored size: 789 Bytes
Contents
require "dock_test/version" require "dock_test/methods" require "dock_test/assertions" module DockTest class << self attr_writer :port def port @port ||= 9999 end attr_reader :url # sets the test url # also creates a new webrick server process def url=(value) @url = value if localhost? require "rack" require 'webrick' server = WEBrick::HTTPServer.new(:Port => port).tap do |server| server.mount '/', Rack::Handler::WEBrick, Rack::Server.new.app end t = Thread.new { server.start } trap('INT') do server.shutdown exit end end end def localhost? @url && ['127.0.0.1', 'localhost'].include?(URI.parse(@url).host) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dock_test-0.0.2 | lib/dock_test.rb |
dock_test-0.0.1 | lib/dock_test.rb |