1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/lib/capybara/rack_test/driver.rb
2011-04-05 17:42:12 +02:00

75 lines
1.3 KiB
Ruby

require 'rack/test'
require 'rack/utils'
require 'mime/types'
require 'nokogiri'
require 'cgi'
class Capybara::RackTest::Driver < Capybara::Driver::Base
attr_reader :app
def initialize(app)
raise ArgumentError, "rack-test requires a rack application, but none was given" unless app
@app = app
end
def browser
@browser ||= Capybara::RackTest::Browser.new(app)
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
end