Sha256: 40ef9d7faeca21549fab4bb047e1ec4eb0863837a3317cb1639f3b28e84f7656

Contents?: true

Size: 933 Bytes

Versions: 17

Compression:

Stored size: 933 Bytes

Contents

require File.expand_path('../helper', __FILE__)
require 'stringio'

module Rack::Handler
  class Mock
    extend Test::Unit::Assertions

    def self.run(app, options={})
      assert(app < Sinatra::Base)
      assert_equal 9001, options[:Port]
      assert_equal 'foo.local', options[:Host]
      yield new
    end

    def stop
    end
  end

  register 'mock', 'Rack::Handler::Mock'
end

class ServerTest < Test::Unit::TestCase
  setup do
    mock_app do
      set :server, 'mock'
      set :bind, 'foo.local'
      set :port, 9001
    end
    $stderr = StringIO.new
  end

  def teardown
    $stderr = STDERR
  end

  it "locates the appropriate Rack handler and calls ::run" do
    @app.run!
  end

  it "sets options on the app before running" do
    @app.run! :sessions => true
    assert @app.sessions?
  end

  it "falls back on the next server handler when not found" do
    @app.run! :server => %w[foo bar mock]
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
sinatra-acd-1.4.5 test/server_test.rb
sinatra-1.4.5 test/server_test.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/sinatra-1.4.4/test/server_test.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/sinatra-1.4.4/test/server_test.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/sinatra-1.4.4/test/server_test.rb
sinatra-1.4.4 test/server_test.rb
sinatra-1.4.3 test/server_test.rb
sinatra-1.4.2 test/server_test.rb
sinatra-1.4.1 test/server_test.rb
sinatra-1.4.0 test/server_test.rb
sinatra-1.4.0.d test/server_test.rb
sinatra-1.4.0.c test/server_test.rb
sinatra-1.4.0.b test/server_test.rb
sinatra-1.4.0.a test/server_test.rb
devcenter-0.0.3 vendor/sinatra/test/server_test.rb
devcenter-0.0.2 vendor/sinatra/test/server_test.rb
devcenter-0.0.1 vendor/sinatra/test/server_test.rb