Sha256: 3b5a3206a02cf5ac250caf1c0f070abe2bc6bf1860992fd69aac1a8cfcf1717e

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 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 < aldebaran::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 {
      set :server, 'mock'
      set :bind, 'foo.local'
      set :port, 9001
    }
    $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

1 entries across 1 versions & 1 rubygems

Version Path
aldebaran-1.0.1 test/server_test.rb