Sha256: 21d4d2b0e4b25df34e41a1b9c062beabfaa1ef73ceea30c748548abffdc93095

Contents?: true

Size: 1.68 KB

Versions: 3

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

require 'capybara/spec/test_app'

class ExtendedTestApp < TestApp
  set :environment, :production # so we don't get debug info that makes our test pass!
  disable :protection

  get %r{/redirect_to/(.*)} do
    redirect params[:captures].first
  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 '/subsite/relative_link_to_host' do
    %(<a href="/subsite/request_info2/host">host</a>)
  end

  get '/subsite/local_link_to_host' do
    %(<a href="request_info2/host">host</a>)
  end

  get '/subsite/request_info2/*' do
    'subsite: ' + current_request_info
  end

  get '/redirect_with_http_param' do
    redirect '/redirect_target?foo=http'
  end

  get '/redirect_target' do
    %(correct redirect)
  end

  get %r{/form_posts_to/(.*)} do
    %(
      <form action="#{params[:captures].first}" method="post">
        <input type="submit" value="submit" />
      </form>
    )
  end

  post '/get_referer' do
    request.referer.nil? ? 'No referer' : "Got referer: #{request.referer}"
  end

  @form_post_count = 0

  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

Version Path
capybara-mechanize-1.13.0 lib/capybara/spec/extended_test_app.rb
capybara-mechanize-1.12.1 lib/capybara/spec/extended_test_app.rb
capybara-mechanize-1.12.0 lib/capybara/spec/extended_test_app.rb