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: false,
  follow_redirects: true,
  redirect_limit: 5
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Driver::Base

#session

Instance Method Summary collapse

Methods inherited from Driver::Base

#accept_modal, #close_window, #current_window_handle, #dismiss_modal, #evaluate_async_script, #evaluate_script, #execute_script, #frame_title, #frame_url, #go_back, #go_forward, #invalid_element_errors, #maximize_window, #needs_server?, #no_such_window_error, #open_new_window, #resize_window_to, #save_screenshot, #session_options, #switch_to_frame, #switch_to_window, #wait?, #window_handles, #window_size

Constructor Details

#initialize(app, **options) ⇒ Driver

Returns a new instance of Driver.

Raises:

  • (ArgumentError)


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

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

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



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

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#browserObject



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

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

#current_urlObject



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

def current_url
  browser.current_url
end

#delete(*args, &block) ⇒ Object



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

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

#domObject



84
85
86
# File 'lib/capybara/rack_test/driver.rb', line 84

def dom
  browser.dom
end

#find_css(selector) ⇒ Object



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

def find_css(selector)
  browser.find(:css, selector)
end

#find_xpath(selector) ⇒ Object



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

def find_xpath(selector)
  browser.find(:xpath, selector)
end

#follow(method, path, **attributes) ⇒ Object



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

def follow(method, path, **attributes)
  browser.follow(method, path, attributes)
end

#follow_redirects?Boolean

Returns:

  • (Boolean)


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

def follow_redirects?
  @options[:follow_redirects]
end

#get(*args, &block) ⇒ Object



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

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

#header(key, value) ⇒ Object



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

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

#htmlObject



80
81
82
# File 'lib/capybara/rack_test/driver.rb', line 80

def html
  browser.html
end

#post(*args, &block) ⇒ Object



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

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

#put(*args, &block) ⇒ Object



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

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

#redirect_limitObject



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

def redirect_limit
  @options[:redirect_limit]
end

#refreshObject



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

def refresh
  browser.refresh
end

#requestObject



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

def request
  browser.last_request
end

#reset!Object



92
93
94
# File 'lib/capybara/rack_test/driver.rb', line 92

def reset!
  @browser = nil
end

#responseObject



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

def response
  browser.last_response
end

#response_headersObject



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

def response_headers
  response.headers
end

#status_codeObject



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

def status_code
  response.status
end

#submit(method, path, attributes) ⇒ Object



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

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

#titleObject



88
89
90
# File 'lib/capybara/rack_test/driver.rb', line 88

def title
  browser.title
end

#visit(path, **attributes) ⇒ Object



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

def visit(path, **attributes)
  browser.visit(path, attributes)
end