Class: Capybara::Mechanize::Driver
- Inherits:
-
Driver::Base
- Object
- Driver::Base
- Capybara::Mechanize::Driver
- Defined in:
- lib/capybara/mechanize/driver.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rack_server ⇒ Object
readonly
Returns the value of attribute rack_server.
Instance Method Summary collapse
- #browser ⇒ Object
- #current_url ⇒ Object
- #delete(url) ⇒ Object
- #dom ⇒ Object
- #find(selector) ⇒ Object
- #follow(_method, path) ⇒ Object
- #get(url) ⇒ Object
-
#initialize(app, options = {}) ⇒ Driver
constructor
A new instance of Driver.
- #post(url) ⇒ Object
- #put(url) ⇒ Object
- #reset! ⇒ Object
- #response_headers ⇒ Object
- #source ⇒ Object (also: #body)
- #status_code ⇒ Object
- #submit(form) ⇒ Object
- #visit(path) ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ Driver
Returns a new instance of Driver.
4 5 6 7 8 9 |
# File 'lib/capybara/mechanize/driver.rb', line 4 def initialize(app, ={}) @app = app = @rack_server = ::Server.new(@app) @rack_server.boot if .run_server end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
2 3 4 |
# File 'lib/capybara/mechanize/driver.rb', line 2 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/capybara/mechanize/driver.rb', line 2 def end |
#rack_server ⇒ Object (readonly)
Returns the value of attribute rack_server.
2 3 4 |
# File 'lib/capybara/mechanize/driver.rb', line 2 def rack_server @rack_server end |
Instance Method Details
#browser ⇒ Object
11 12 13 |
# File 'lib/capybara/mechanize/driver.rb', line 11 def browser @browser ||= ::Mechanize::Browser.new end |
#current_url ⇒ Object
33 34 35 |
# File 'lib/capybara/mechanize/driver.rb', line 33 def current_url browser.url end |
#delete(url) ⇒ Object
27 |
# File 'lib/capybara/mechanize/driver.rb', line 27 def delete(url); follow(:delete, url); end |
#dom ⇒ Object
54 55 56 |
# File 'lib/capybara/mechanize/driver.rb', line 54 def dom browser.dom end |
#find(selector) ⇒ Object
45 46 47 |
# File 'lib/capybara/mechanize/driver.rb', line 45 def find(selector) dom.search(selector).map { |node| ::Mechanize::Node.new(self, node) } end |
#follow(_method, path) ⇒ Object
19 20 21 22 |
# File 'lib/capybara/mechanize/driver.rb', line 19 def follow(_method, path) return if is_fragment?(path) browser.send(_method, make_absolute_url(path)) end |
#get(url) ⇒ Object
24 |
# File 'lib/capybara/mechanize/driver.rb', line 24 def get(url); follow(:get, url); end |
#post(url) ⇒ Object
25 |
# File 'lib/capybara/mechanize/driver.rb', line 25 def post(url); follow(:post, url); end |
#put(url) ⇒ Object
26 |
# File 'lib/capybara/mechanize/driver.rb', line 26 def put(url); follow(:put, url); end |
#reset! ⇒ Object
58 59 60 |
# File 'lib/capybara/mechanize/driver.rb', line 58 def reset! @browser = nil end |
#response_headers ⇒ Object
37 38 39 |
# File 'lib/capybara/mechanize/driver.rb', line 37 def response_headers browser.headers end |
#source ⇒ Object Also known as: body
49 50 51 |
# File 'lib/capybara/mechanize/driver.rb', line 49 def source browser.source end |
#status_code ⇒ Object
41 42 43 |
# File 'lib/capybara/mechanize/driver.rb', line 41 def status_code browser.status_code end |
#submit(form) ⇒ Object
29 30 31 |
# File 'lib/capybara/mechanize/driver.rb', line 29 def submit(form) browser.submit(form) end |
#visit(path) ⇒ Object
15 16 17 |
# File 'lib/capybara/mechanize/driver.rb', line 15 def visit(path) browser.get(url(path)) end |