Sha256: 7dbcfb661586d048b4d7b195a54099ad1eefd5738c59dc840a8275639ce0334a

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

require 'webrick/https'

# This context runs a WEBRick server that is accessible to tests.
# The `webserver_port` and `webserver_path` will need to be specified before
# this context is included:
#
#     let(:webserver_port) { ... }
#     let(:webserver_path) { ... }
#     include 'webserver'
shared_context 'webserver' do
  before(:each) do
    mime_types = {
      'gz'  => 'application/gzip',
      'zip' => 'application/zip',
      'tar' => 'application/x-tar',
    }

    @server = WEBrick::HTTPServer.new(
      AccessLog: [],
      Port: webserver_port,
      DocumentRoot: webserver_path,
      MimeTypes: mime_types)
    @thr = Thread.new { @server.start }
  end

  after(:each) do
    @server.shutdown rescue nil
    @thr.join rescue nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-pe_build-0.10.1 spec/shared/helpers/webserver_context.rb