Sha256: 2b4373ca790d4ae02adf12b39a6afa25daf060420ebaf32a02a7aff76d72ec4c

Contents?: true

Size: 1.88 KB

Versions: 55

Compression:

Stored size: 1.88 KB

Contents

# encoding: utf-8
require 'sinatra/base'

class WatirSpec::Server < ::Sinatra::Base

  set :app_file,    __FILE__
  set :root,        File.dirname(__FILE__)
  set :public,      lambda { File.join(root, 'fixtures')}
  set :static,      true
  set :run,         false
  set :environment, :production
  set :bind,        'localhost'
  set :port,        2000
  set :server,      %w[thin mongrel webrick]

  get '/' do
    self.class.name
  end

  get '/big' do
    Class.new do
      def each(&blk)
        yield "<html><head><title>Big Content</title></head><body>"
        string = "hello "*205
        300.times { yield string }
        yield "</body></html>"
      end
    end.new
  end

  post '/post_to_me' do
    "You posted the following content:\n#{ env['rack.input'].read }"
  end

  get '/plain_text' do
    content_type 'text/plain'
    'This is text/plain'
  end

  get '/ajax' do
    sleep 10
    "A slooow ajax response"
  end

  get '/charset_mismatch' do
    content_type 'text/html; charset=UTF-8'
    %{
      <html>
        <head>
          <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
        </head>
        <body>
          <h1>ΓΈ</h1>
        </body>
      </html>
    }
  end

  get '/octet_stream' do
    content_type 'application/octet-stream'
    'This is application/octet-stream'
  end

  get '/set_cookie' do
    content_type 'text/plain'
    headers 'Set-Cookie' => "monster=/"

    "C is for cookie, it's good enough for me"
  end

  get '/header_echo' do
    content_type 'text/plain'
    env.inspect
  end

  get '/authentication' do
    auth = Rack::Auth::Basic::Request.new(env)

    unless auth.provided? && auth.credentials == %w[foo bar]
      headers 'WWW-Authenticate' => %(Basic realm="localhost")
      halt 401, 'Authorization Required'
    end

    "ok"
  end

  get '/encodable_<stuff>' do
    'page with characters in URI that need encoding'
  end

end

Version data entries

55 entries across 25 versions & 1 rubygems

Version Path
operawatir-0.7.pre4-jruby spec/watir2/server.rb
operawatir-0.7.pre3-jruby spec/watir2/server.rb
operawatir-0.7.pre2-jruby spec/watir2/server.rb
operawatir-0.7.pre1-jruby spec/watir2/server.rb
operawatir-0.6.pre1-jruby spec/watir2/server.rb
operawatir-0.6.pre1-jruby spec/operawatir/server.rb
operawatir-0.5.1-jruby spec/operawatir/server.rb
operawatir-0.5.1-jruby spec/watir2/server.rb
operawatir-0.5-jruby spec/operawatir/server.rb
operawatir-0.5-jruby spec/watir2/server.rb
operawatir-0.5.pre3-jruby spec/watir2/server.rb
operawatir-0.5.pre3-jruby spec/operawatir/server.rb
operawatir-0.5.pre2-jruby spec/operawatir/server.rb
operawatir-0.5.pre2-jruby spec/watir2/server.rb
operawatir-0.5.pre1-jruby spec/watir2/server.rb
operawatir-0.5.pre1-jruby spec/operawatir/server.rb
operawatir-0.4.3.pre1-jruby spec/operawatir/server.rb
operawatir-0.4.3.pre1-jruby spec/watir2/server.rb
operawatir-0.4.3.pre1-jruby spec/watir3/server.rb
operawatir-0.4.2-jruby spec/operawatir/server.rb