Class: Capybara::Typhoeus::Driver
- Inherits:
-
RackTest::Driver
- Object
- RackTest::Driver
- Capybara::Typhoeus::Driver
- Defined in:
- lib/capybara/typhoeus/driver.rb
Instance Attribute Summary collapse
- #as ⇒ Object
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
- #with_headers ⇒ Object
- #with_options ⇒ Object
- #with_params ⇒ Object
Instance Method Summary collapse
- #auth? ⇒ Boolean
- #authenticate_with(login, password) ⇒ Object
- #body ⇒ Object
- #browser ⇒ Object
-
#initialize(app, options = {}) ⇒ Driver
constructor
A new instance of Driver.
- #json ⇒ Object
- #needs_server? ⇒ Boolean
- #request_body ⇒ Object
- #request_body=(value) ⇒ Object
- #reset! ⇒ Object
- #reset_with! ⇒ Object
- #status_code ⇒ Object
- #timed_out? ⇒ Boolean
- #xml ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ Driver
Returns a new instance of Driver.
6 7 8 9 |
# File 'lib/capybara/typhoeus/driver.rb', line 6 def initialize(app, = {}) raise ArgumentError, "typhoeus requires a rack application, but none was given" unless app super app, {timeout: 3, forbid_reuse: true}.merge() end |
Instance Attribute Details
#as ⇒ Object
43 44 45 |
# File 'lib/capybara/typhoeus/driver.rb', line 43 def as @as ||= "application/json" end |
#login ⇒ Object (readonly)
Returns the value of attribute login.
4 5 6 |
# File 'lib/capybara/typhoeus/driver.rb', line 4 def login @login end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'lib/capybara/typhoeus/driver.rb', line 4 def password @password end |
#with_headers ⇒ Object
47 48 49 |
# File 'lib/capybara/typhoeus/driver.rb', line 47 def with_headers @with_headers ||= {} end |
#with_options ⇒ Object
55 56 57 |
# File 'lib/capybara/typhoeus/driver.rb', line 55 def @with_options ||= {} end |
#with_params ⇒ Object
51 52 53 |
# File 'lib/capybara/typhoeus/driver.rb', line 51 def with_params @with_params ||= {} end |
Instance Method Details
#auth? ⇒ Boolean
63 64 65 |
# File 'lib/capybara/typhoeus/driver.rb', line 63 def auth? login && password end |
#authenticate_with(login, password) ⇒ Object
59 60 61 |
# File 'lib/capybara/typhoeus/driver.rb', line 59 def authenticate_with(login, password) @login, @password = login, password end |
#body ⇒ Object
71 72 73 |
# File 'lib/capybara/typhoeus/driver.rb', line 71 def body browser.html end |
#browser ⇒ Object
11 12 13 |
# File 'lib/capybara/typhoeus/driver.rb', line 11 def browser @browser ||= Capybara::Typhoeus::Browser.new self end |
#json ⇒ Object
79 80 81 |
# File 'lib/capybara/typhoeus/driver.rb', line 79 def json browser.json end |
#needs_server? ⇒ Boolean
15 16 17 |
# File 'lib/capybara/typhoeus/driver.rb', line 15 def needs_server? true end |
#request_body ⇒ Object
83 84 85 |
# File 'lib/capybara/typhoeus/driver.rb', line 83 def request_body browser.request_body end |
#request_body=(value) ⇒ Object
87 88 89 |
# File 'lib/capybara/typhoeus/driver.rb', line 87 def request_body=(value) browser.request_body = value end |
#reset! ⇒ Object
26 27 28 29 30 |
# File 'lib/capybara/typhoeus/driver.rb', line 26 def reset! @login = nil @password = nil super end |
#reset_with! ⇒ Object
36 37 38 39 40 41 |
# File 'lib/capybara/typhoeus/driver.rb', line 36 def reset_with! @with_headers = {} @with_params = {} @with_options = {} @as = nil end |
#status_code ⇒ Object
67 68 69 |
# File 'lib/capybara/typhoeus/driver.rb', line 67 def status_code response.code end |
#timed_out? ⇒ Boolean
32 33 34 |
# File 'lib/capybara/typhoeus/driver.rb', line 32 def timed_out? response.timed_out? end |
#xml ⇒ Object
75 76 77 |
# File 'lib/capybara/typhoeus/driver.rb', line 75 def xml browser.json end |