Class: Capybara::Mechanize::Browser
- Inherits:
-
RackTest::Browser
- Object
- RackTest::Browser
- Capybara::Mechanize::Browser
- Extended by:
- Forwardable
- Defined in:
- lib/capybara/mechanize/browser.rb
Defined Under Namespace
Classes: ResponseProxy
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
Instance Method Summary collapse
- #current_url ⇒ Object
- #find(selector) ⇒ Object
-
#initialize(driver) ⇒ Browser
constructor
A new instance of Browser.
- #last_response ⇒ Object
- #remote?(url) ⇒ Boolean
- #reset_host! ⇒ Object
Constructor Details
#initialize(driver) ⇒ Browser
Returns a new instance of Browser.
12 13 14 15 16 17 |
# File 'lib/capybara/mechanize/browser.rb', line 12 def initialize(driver) @agent = ::Mechanize.new @agent.redirect_ok = false @agent.user_agent = default_user_agent super end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
70 71 72 |
# File 'lib/capybara/mechanize/browser.rb', line 70 def agent @agent end |
Instance Method Details
#current_url ⇒ Object
25 26 27 |
# File 'lib/capybara/mechanize/browser.rb', line 25 def current_url last_request_remote? ? remote_response.current_url : super end |
#find(selector) ⇒ Object
66 67 68 |
# File 'lib/capybara/mechanize/browser.rb', line 66 def find(selector) dom.xpath(selector).map { |node| Capybara::Mechanize::Node.new(self, node) } end |
#last_response ⇒ Object
29 30 31 |
# File 'lib/capybara/mechanize/browser.rb', line 29 def last_response last_request_remote? ? remote_response : super end |
#remote?(url) ⇒ Boolean
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/capybara/mechanize/browser.rb', line 52 def remote?(url) if Capybara.app_host true else host = URI.parse(url).host if host.nil? last_request_remote? else !Capybara::Mechanize.local_hosts.include?(host) end end end |
#reset_host! ⇒ Object
19 20 21 22 23 |
# File 'lib/capybara/mechanize/browser.rb', line 19 def reset_host! @last_remote_uri = nil @last_request_remote = nil super end |