Sha256: 5cfbe7e2baa1997a5fa633398a03a56fd3d84ba63cfd2a840982a4c0b1b0a654

Contents?: true

Size: 1.49 KB

Versions: 17

Compression:

Stored size: 1.49 KB

Contents

require 'rack/test'
require 'rack/utils'
require 'mime/types'
require 'nokogiri'
require 'cgi'

class Capybara::RackTest::Driver < Capybara::Driver::Base
  DEFAULT_OPTIONS = {
    :respect_data_method => true
  }
  attr_reader :app, :options

  def initialize(app, options={})
    raise ArgumentError, "rack-test requires a rack application, but none was given" unless app
    @app = app
    @options = DEFAULT_OPTIONS.merge(options)
  end

  def browser
    @browser ||= Capybara::RackTest::Browser.new(self)
  end

  def response
    browser.last_response
  end

  def request
    browser.last_request
  end

  def visit(path, attributes = {})
    browser.visit(path, attributes)
  end

  def submit(method, path, attributes)
    browser.submit(method, path, attributes)
  end

  def follow(method, path, attributes = {})
    browser.follow(method, path, attributes)
  end

  def current_url
    browser.current_url
  end

  def response_headers
    response.headers
  end

  def status_code
    response.status
  end

  def find(selector)
    browser.find(selector)
  end

  def body
    browser.body
  end

  def source
    browser.source
  end

  def dom
    browser.dom
  end

  def reset!
    @browser = nil
  end

  def get(*args, &block); browser.get(*args, &block); end
  def post(*args, &block); browser.post(*args, &block); end
  def put(*args, &block); browser.put(*args, &block); end
  def delete(*args, &block); browser.delete(*args, &block); end
  def header(key, value); browser.header(key, value); end
end

Version data entries

17 entries across 17 versions & 5 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/capybara-1.1.4/lib/capybara/rack_test/driver.rb
capybara-1.1.4 lib/capybara/rack_test/driver.rb
capybara-1.1.3 lib/capybara/rack_test/driver.rb
nimboids-capybara-1.1.2 lib/capybara/rack_test/driver.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/capybara-1.1.2/lib/capybara/rack_test/driver.rb
bbc-capybara-1.1.2 lib/capybara/rack_test/driver.rb
capybara-1.1.2 lib/capybara/rack_test/driver.rb
capybara-1.1.1 lib/capybara/rack_test/driver.rb