Class: Capybara::RackTest::Driver

Inherits:
Driver::Base show all
Defined in:
lib/capybara/rack_test/driver.rb

Constant Summary

DEFAULT_OPTIONS =
{
  :respect_data_method => false,
  :follow_redirects => true,
  :redirect_limit => 5
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Driver::Base

#accept_modal, #close_window, #current_window_handle, #dismiss_modal, #evaluate_script, #execute_script, #go_back, #go_forward, #invalid_element_errors, #maximize_window, #needs_server?, #no_such_window_error, #open_new_window, #resize_window_to, #save_screenshot, #switch_to_window, #wait?, #window_handles, #window_size, #within_frame, #within_window

Constructor Details

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

Returns a new instance of Driver

Raises:

  • (ArgumentError)


15
16
17
18
19
# File 'lib/capybara/rack_test/driver.rb', line 15

def initialize(app, options={})
  raise ArgumentError, "rack-test requires a rack application, but none was given" unless app
  @app = app
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app



13
14
15
# File 'lib/capybara/rack_test/driver.rb', line 13

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options



13
14
15
# File 'lib/capybara/rack_test/driver.rb', line 13

def options
  @options
end

Instance Method Details

#browserObject



21
22
23
# File 'lib/capybara/rack_test/driver.rb', line 21

def browser
  @browser ||= Capybara::RackTest::Browser.new(self)
end

#browser_initialized?Boolean



89
90
91
# File 'lib/capybara/rack_test/driver.rb', line 89

def browser_initialized?
  !@browser.nil?
end

#current_urlObject



53
54
55
# File 'lib/capybara/rack_test/driver.rb', line 53

def current_url
  browser.current_url
end

#delete(*args, &block) ⇒ Object



96
# File 'lib/capybara/rack_test/driver.rb', line 96

def delete(*args, &block); browser.delete(*args, &block); end

#domObject



77
78
79
# File 'lib/capybara/rack_test/driver.rb', line 77

def dom
  browser.dom
end

#find_css(selector) ⇒ Object



69
70
71
# File 'lib/capybara/rack_test/driver.rb', line 69

def find_css(selector)
  browser.find(:css,selector)
end

#find_xpath(selector) ⇒ Object



65
66
67
# File 'lib/capybara/rack_test/driver.rb', line 65

def find_xpath(selector)
  browser.find(:xpath, selector)
end

#follow(method, path, attributes = {}) ⇒ Object



49
50
51
# File 'lib/capybara/rack_test/driver.rb', line 49

def follow(method, path, attributes = {})
  browser.follow(method, path, attributes)
end

#follow_redirects?Boolean



25
26
27
# File 'lib/capybara/rack_test/driver.rb', line 25

def follow_redirects?
  @options[:follow_redirects]
end

#get(*args, &block) ⇒ Object



93
# File 'lib/capybara/rack_test/driver.rb', line 93

def get(*args, &block); browser.get(*args, &block); end

#header(key, value) ⇒ Object



97
# File 'lib/capybara/rack_test/driver.rb', line 97

def header(key, value); browser.header(key, value); end

#htmlObject



73
74
75
# File 'lib/capybara/rack_test/driver.rb', line 73

def html
  browser.html
end

#post(*args, &block) ⇒ Object



94
# File 'lib/capybara/rack_test/driver.rb', line 94

def post(*args, &block); browser.post(*args, &block); end

#put(*args, &block) ⇒ Object



95
# File 'lib/capybara/rack_test/driver.rb', line 95

def put(*args, &block); browser.put(*args, &block); end

#redirect_limitObject



29
30
31
# File 'lib/capybara/rack_test/driver.rb', line 29

def redirect_limit
  @options[:redirect_limit]
end

#requestObject



37
38
39
# File 'lib/capybara/rack_test/driver.rb', line 37

def request
  browser.last_request
end

#reset!Object



85
86
87
# File 'lib/capybara/rack_test/driver.rb', line 85

def reset!
  @browser = nil
end

#responseObject



33
34
35
# File 'lib/capybara/rack_test/driver.rb', line 33

def response
  browser.last_response
end

#response_headersObject



57
58
59
# File 'lib/capybara/rack_test/driver.rb', line 57

def response_headers
  response.headers
end

#status_codeObject



61
62
63
# File 'lib/capybara/rack_test/driver.rb', line 61

def status_code
  response.status
end

#submit(method, path, attributes) ⇒ Object



45
46
47
# File 'lib/capybara/rack_test/driver.rb', line 45

def submit(method, path, attributes)
  browser.submit(method, path, attributes)
end

#titleObject



81
82
83
# File 'lib/capybara/rack_test/driver.rb', line 81

def title
  browser.title
end

#visit(path, attributes = {}) ⇒ Object



41
42
43
# File 'lib/capybara/rack_test/driver.rb', line 41

def visit(path, attributes = {})
  browser.visit(path, attributes)
end