Sha256: 61ad30aed48957bc6f27dd69888c2ee46ba802e961963f3f59103dc13d2766e8

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'sinatra/base'
require 'rack'
require 'yaml'

class TestApp < Sinatra::Base
  set :root, File.dirname(__FILE__)
  set :static, true

  get '/' do
    'Hello world!'
  end

  get '/foo' do
    'Another World'
  end
  
  get '/redirect' do
    redirect '/redirect_again'
  end

  get '/redirect_again' do
    redirect '/landed'
  end

  get '/landed' do
    "You landed"
  end

  get '/with-quotes' do
    %q{"No," he said, "you can't do that."}
  end

  get '/form/get' do
    '<pre id="results">' + params[:form].to_yaml + '</pre>'
  end
  
  get '/favicon.ico' do
    nil
  end

  get '/:view' do |view|
    erb view.to_sym
  end

  post '/redirect' do
    redirect '/redirect_again'
  end

  post '/form' do
    '<pre id="results">' + params[:form].to_yaml + '</pre>'
  end

  post '/upload' do
    begin
      buffer = []
      buffer << "Content-type: #{params[:form][:document][:type]}"
      buffer << "File content: #{params[:form][:document][:tempfile].read}"
      buffer.join(' | ')
    rescue
      'No file uploaded'
    end
  end
end

if __FILE__ == $0
  Rack::Handler::Mongrel.run TestApp, :Port => 8070
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capybara-0.3.0 spec/test_app.rb