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)


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

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



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

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options



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

def options
  @options
end

Instance Method Details

#browserObject



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

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

#browser_initialized?Boolean



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

def browser_initialized?
  !@browser.nil?
end

#current_urlObject



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

def current_url
  browser.current_url
end

#delete(*args, &block) ⇒ Object



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

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

#domObject



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

def dom
  browser.dom
end

#find_css(selector) ⇒ Object



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

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

#find_xpath(selector) ⇒ Object



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

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

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



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

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

#follow_redirects?Boolean



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

def follow_redirects?
  @options[:follow_redirects]
end

#get(*args, &block) ⇒ Object



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

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

#header(key, value) ⇒ Object



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

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

#htmlObject



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

def html
  browser.html
end

#post(*args, &block) ⇒ Object



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

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

#put(*args, &block) ⇒ Object



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

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

#redirect_limitObject



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

def redirect_limit
  @options[:redirect_limit]
end

#requestObject



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

def request
  browser.last_request
end

#reset!Object



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

def reset!
  @browser = nil
end

#responseObject



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

def response
  browser.last_response
end

#response_headersObject



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

def response_headers
  response.headers
end

#status_codeObject



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

def status_code
  response.status
end

#submit(method, path, attributes) ⇒ Object



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

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

#titleObject



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

def title
  browser.title
end

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



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

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