Class: Capybara::RackTest::Driver

Inherits:
Driver::Base show all
Defined in:
lib/capybara/rack_test/driver.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :respect_data_method => true
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Driver::Base

#evaluate_script, #execute_script, #has_shortcircuit_timeout?, #invalid_element_errors, #wait?, #wait_until, #within_frame, #within_window

Constructor Details

#initialize(app, options = {}) ⇒ Driver

Returns a new instance of Driver.

Raises:

  • (ArgumentError)


13
14
15
16
17
# File 'lib/capybara/rack_test/driver.rb', line 13

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

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



11
12
13
# File 'lib/capybara/rack_test/driver.rb', line 11

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/capybara/rack_test/driver.rb', line 11

def options
  @options
end

Instance Method Details

#bodyObject



59
60
61
# File 'lib/capybara/rack_test/driver.rb', line 59

def body
  browser.body
end

#browserObject



19
20
21
# File 'lib/capybara/rack_test/driver.rb', line 19

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

#current_urlObject



43
44
45
# File 'lib/capybara/rack_test/driver.rb', line 43

def current_url
  browser.current_url
end

#delete(*args, &block) ⇒ Object



78
# File 'lib/capybara/rack_test/driver.rb', line 78

def delete(*args, &block); browser.delete(*args, &block); end

#domObject



67
68
69
# File 'lib/capybara/rack_test/driver.rb', line 67

def dom
  browser.dom
end

#find(selector) ⇒ Object



55
56
57
# File 'lib/capybara/rack_test/driver.rb', line 55

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

#follow(method, path, attributes = {}) ⇒ Object



39
40
41
# File 'lib/capybara/rack_test/driver.rb', line 39

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

#get(*args, &block) ⇒ Object



75
# File 'lib/capybara/rack_test/driver.rb', line 75

def get(*args, &block); browser.get(*args, &block); end

#header(key, value) ⇒ Object



79
# File 'lib/capybara/rack_test/driver.rb', line 79

def header(key, value); browser.header(key, value); end

#post(*args, &block) ⇒ Object



76
# File 'lib/capybara/rack_test/driver.rb', line 76

def post(*args, &block); browser.post(*args, &block); end

#put(*args, &block) ⇒ Object



77
# File 'lib/capybara/rack_test/driver.rb', line 77

def put(*args, &block); browser.put(*args, &block); end

#requestObject



27
28
29
# File 'lib/capybara/rack_test/driver.rb', line 27

def request
  browser.last_request
end

#reset!Object



71
72
73
# File 'lib/capybara/rack_test/driver.rb', line 71

def reset!
  @browser = nil
end

#responseObject



23
24
25
# File 'lib/capybara/rack_test/driver.rb', line 23

def response
  browser.last_response
end

#response_headersObject



47
48
49
# File 'lib/capybara/rack_test/driver.rb', line 47

def response_headers
  response.headers
end

#sourceObject



63
64
65
# File 'lib/capybara/rack_test/driver.rb', line 63

def source
  browser.source
end

#status_codeObject



51
52
53
# File 'lib/capybara/rack_test/driver.rb', line 51

def status_code
  response.status
end

#submit(method, path, attributes) ⇒ Object



35
36
37
# File 'lib/capybara/rack_test/driver.rb', line 35

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

#visit(path, attributes = {}) ⇒ Object



31
32
33
# File 'lib/capybara/rack_test/driver.rb', line 31

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