Class: Capybara::Typhoeus::Browser
- Inherits:
-
RackTest::Browser
- Object
- RackTest::Browser
- Capybara::Typhoeus::Browser
- Defined in:
- lib/capybara/typhoeus/browser.rb
Defined Under Namespace
Classes: LastRequest
Instance Attribute Summary collapse
-
#last_request ⇒ Object
readonly
Returns the value of attribute last_request.
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#request_body ⇒ Object
Returns the value of attribute request_body.
Instance Method Summary collapse
- #current_url ⇒ Object
- #dom ⇒ Object
- #html ⇒ Object
- #json ⇒ Object
- #refresh ⇒ Object
- #reset_cache! ⇒ Object
- #xml ⇒ Object
Instance Attribute Details
#last_request ⇒ Object (readonly)
Returns the value of attribute last_request.
24 25 26 |
# File 'lib/capybara/typhoeus/browser.rb', line 24 def last_request @last_request end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
25 26 27 |
# File 'lib/capybara/typhoeus/browser.rb', line 25 def last_response @last_response end |
#request_body ⇒ Object
Returns the value of attribute request_body.
23 24 25 |
# File 'lib/capybara/typhoeus/browser.rb', line 23 def request_body @request_body end |
Instance Method Details
#current_url ⇒ Object
38 39 40 |
# File 'lib/capybara/typhoeus/browser.rb', line 38 def current_url last_response ? last_response.effective_url : "" end |
#dom ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/capybara/typhoeus/browser.rb', line 42 def dom @dom ||= begin content_type = if last_response last_response.headers["Content-Type"].to_s[/\A[^;]+/] else "" end if content_type.include? "/xml" xml else Capybara::HTML html end end end |
#html ⇒ Object
57 58 59 |
# File 'lib/capybara/typhoeus/browser.rb', line 57 def html last_response ? last_response.body : "" end |
#json ⇒ Object
65 66 67 |
# File 'lib/capybara/typhoeus/browser.rb', line 65 def json @json ||= JSON.parse html end |
#refresh ⇒ Object
33 34 35 36 |
# File 'lib/capybara/typhoeus/browser.rb', line 33 def refresh reset_cache! send(last_request.method, last_request.url, last_request.params, last_request.headers) end |
#reset_cache! ⇒ Object
27 28 29 30 31 |
# File 'lib/capybara/typhoeus/browser.rb', line 27 def reset_cache! @xml = nil @json = nil super end |
#xml ⇒ Object
61 62 63 |
# File 'lib/capybara/typhoeus/browser.rb', line 61 def xml @xml ||= Nokogiri::XML html end |