Class: Capybara::Typhoeus::Driver

Inherits:
RackTest::Driver
  • Object
show all
Defined in:
lib/capybara/typhoeus/driver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Driver

Returns a new instance of Driver.

Raises:

  • (ArgumentError)


6
7
8
9
# File 'lib/capybara/typhoeus/driver.rb', line 6

def initialize(app, options = {})
  raise ArgumentError, "typhoeus requires a rack application, but none was given" unless app
  super app, {timeout: 3, forbid_reuse: true}.merge(options)
end

Instance Attribute Details

#asObject



43
44
45
# File 'lib/capybara/typhoeus/driver.rb', line 43

def as
  @as ||= "application/json"
end

#loginObject (readonly)

Returns the value of attribute login.



4
5
6
# File 'lib/capybara/typhoeus/driver.rb', line 4

def 
  @login
end

#passwordObject (readonly)

Returns the value of attribute password.



4
5
6
# File 'lib/capybara/typhoeus/driver.rb', line 4

def password
  @password
end

#with_headersObject



47
48
49
# File 'lib/capybara/typhoeus/driver.rb', line 47

def with_headers
  @with_headers ||= {}
end

#with_optionsObject



55
56
57
# File 'lib/capybara/typhoeus/driver.rb', line 55

def with_options
  @with_options ||= {}
end

#with_paramsObject



51
52
53
# File 'lib/capybara/typhoeus/driver.rb', line 51

def with_params
  @with_params ||= {}
end

Instance Method Details

#auth?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/capybara/typhoeus/driver.rb', line 63

def auth?
   && password
end

#authenticate_with(login, password) ⇒ Object



59
60
61
# File 'lib/capybara/typhoeus/driver.rb', line 59

def authenticate_with(, password)
  @login, @password = , password
end

#bodyObject



71
72
73
# File 'lib/capybara/typhoeus/driver.rb', line 71

def body
  browser.html
end

#browserObject



11
12
13
# File 'lib/capybara/typhoeus/driver.rb', line 11

def browser
  @browser ||= Capybara::Typhoeus::Browser.new self
end

#jsonObject



79
80
81
# File 'lib/capybara/typhoeus/driver.rb', line 79

def json
  browser.json
end

#needs_server?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/capybara/typhoeus/driver.rb', line 15

def needs_server?
  true
end

#request_bodyObject



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_codeObject



67
68
69
# File 'lib/capybara/typhoeus/driver.rb', line 67

def status_code
  response.code
end

#timed_out?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/capybara/typhoeus/driver.rb', line 32

def timed_out?
  response.timed_out?
end

#xmlObject



75
76
77
# File 'lib/capybara/typhoeus/driver.rb', line 75

def xml
  browser.json
end