Class: Capybara::RackTest::Driver
Constant Summary
collapse
- DEFAULT_OPTIONS =
{
respect_data_method: false,
follow_redirects: true,
redirect_limit: 5
}.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#browser ⇒ Object
-
#current_url ⇒ Object
-
#delete(*args, &block) ⇒ Object
-
#dom ⇒ Object
-
#find_css(selector) ⇒ Object
-
#find_xpath(selector) ⇒ Object
-
#follow(method, path, **attributes) ⇒ Object
-
#follow_redirects? ⇒ Boolean
-
#get(*args, &block) ⇒ Object
-
#header(key, value) ⇒ Object
-
#html ⇒ Object
-
#initialize(app, **options) ⇒ Driver
constructor
A new instance of Driver.
-
#invalid_element_errors ⇒ Object
-
#post(*args, &block) ⇒ Object
-
#put(*args, &block) ⇒ Object
-
#redirect_limit ⇒ Object
-
#refresh ⇒ Object
-
#request ⇒ Object
-
#reset! ⇒ Object
-
#response ⇒ Object
-
#response_headers ⇒ Object
-
#status_code ⇒ Object
-
#submit(method, path, attributes) ⇒ Object
-
#title ⇒ Object
-
#visit(path, **attributes) ⇒ Object
#accept_modal, #close_window, #current_window_handle, #dismiss_modal, #evaluate_async_script, #evaluate_script, #execute_script, #frame_title, #frame_url, #fullscreen_window, #go_back, #go_forward, #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.
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
@app = app
@options = DEFAULT_OPTIONS.merge(options)
end
|
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
15
16
17
|
# File 'lib/capybara/rack_test/driver.rb', line 15
def app
@app
end
|
#options ⇒ Object
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
#current_url ⇒ Object
60
61
62
|
# File 'lib/capybara/rack_test/driver.rb', line 60
def current_url
browser.current_url
end
|
#delete(*args, &block) ⇒ Object
103
|
# File 'lib/capybara/rack_test/driver.rb', line 103
def delete(*args, &block); browser.delete(*args, &block); end
|
#dom ⇒ Object
88
89
90
|
# File 'lib/capybara/rack_test/driver.rb', line 88
def dom
browser.dom
end
|
#find_css(selector) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/capybara/rack_test/driver.rb', line 76
def find_css(selector)
browser.find(:css, selector)
rescue Nokogiri::CSS::SyntaxError
raise unless selector.include?(' i]')
raise ArgumentError, "This driver doesn't support case insensitive attribute matching when using CSS base selectors"
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
28
29
30
|
# File 'lib/capybara/rack_test/driver.rb', line 28
def follow_redirects?
@options[:follow_redirects]
end
|
#get(*args, &block) ⇒ Object
100
|
# File 'lib/capybara/rack_test/driver.rb', line 100
def get(*args, &block); browser.get(*args, &block); end
|
104
|
# File 'lib/capybara/rack_test/driver.rb', line 104
def (key, value); browser.(key, value); end
|
#html ⇒ Object
84
85
86
|
# File 'lib/capybara/rack_test/driver.rb', line 84
def html
browser.html
end
|
#invalid_element_errors ⇒ Object
#post(*args, &block) ⇒ Object
101
|
# File 'lib/capybara/rack_test/driver.rb', line 101
def post(*args, &block); browser.post(*args, &block); end
|
#put(*args, &block) ⇒ Object
102
|
# File 'lib/capybara/rack_test/driver.rb', line 102
def put(*args, &block); browser.put(*args, &block); end
|
#redirect_limit ⇒ Object
32
33
34
|
# File 'lib/capybara/rack_test/driver.rb', line 32
def redirect_limit
@options[:redirect_limit]
end
|
#refresh ⇒ Object
48
49
50
|
# File 'lib/capybara/rack_test/driver.rb', line 48
def refresh
browser.refresh
end
|
#request ⇒ Object
40
41
42
|
# File 'lib/capybara/rack_test/driver.rb', line 40
def request
browser.last_request
end
|
#reset! ⇒ Object
96
97
98
|
# File 'lib/capybara/rack_test/driver.rb', line 96
def reset!
@browser = nil
end
|
#response ⇒ Object
36
37
38
|
# File 'lib/capybara/rack_test/driver.rb', line 36
def response
browser.last_response
end
|
64
65
66
|
# File 'lib/capybara/rack_test/driver.rb', line 64
def
response.
end
|
#status_code ⇒ Object
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
|
#title ⇒ Object
92
93
94
|
# File 'lib/capybara/rack_test/driver.rb', line 92
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
|