Sha256: 62cf9273abffee08da4aa90471789e2c489d875dc64663e7bf24484999048f31
Contents?: true
Size: 1.4 KB
Versions: 3
Compression:
Stored size: 1.4 KB
Contents
require 'capybara/spec/test_app' class ExtendedTestApp < TestApp#< Sinatra::Base set :environment, :production # so we don't get debug info that makes our test pass! helpers do def protected! unless authorized? response['WWW-Authenticate'] = %(Basic realm="Restricted Area") throw(:halt, [401, "Not authorized\n"]) end end def authorized? @auth ||= Rack::Auth::Basic::Request.new(request.env) @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == ['admin', 'password'] end end get %r{/redirect_to/(.*)} do redirect params[:captures] end get '/form_with_relative_action_to_host' do %{<form action="/request_info/host" method="post"> <input type="submit" value="submit" /> </form>} end get '/request_info/form_with_no_action' do %{<form method="post"> <input type="submit" value="submit" /> </form>} end get '/relative_link_to_host' do %{<a href="/request_info/host">host</a>} end get '/request_info/user_agent' do request.user_agent end get '/request_info/*' do current_request_info end post '/request_info/*' do current_request_info end get '/basic_auth/' do protected! %{Successfully authenticated} end private def current_request_info "Current host is #{request.url}, method #{request.request_method.downcase}" end end
Version data entries
3 entries across 3 versions & 1 rubygems