Class: Capybara::Driver::RackTest

Inherits:
Base
  • Object
show all
Includes:
Rack::Test::Methods
Defined in:
lib/capybara/driver/rack_test_driver.rb

Defined Under Namespace

Classes: Form, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#cleanup!, #evaluate_script, #wait?

Constructor Details

#initialize(app) ⇒ RackTest

Returns a new instance of RackTest.



183
184
185
# File 'lib/capybara/driver/rack_test_driver.rb', line 183

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



177
178
179
# File 'lib/capybara/driver/rack_test_driver.rb', line 177

def app
  @app
end

#bodyObject (readonly) Also known as: source

Returns the value of attribute body.



177
178
179
# File 'lib/capybara/driver/rack_test_driver.rb', line 177

def body
  @body
end

#htmlObject (readonly)

Returns the value of attribute html.



177
178
179
# File 'lib/capybara/driver/rack_test_driver.rb', line 177

def html
  @html
end

Instance Method Details

#current_urlObject



194
195
196
# File 'lib/capybara/driver/rack_test_driver.rb', line 194

def current_url
  request.url rescue ""
end

#find(selector) ⇒ Object



209
210
211
# File 'lib/capybara/driver/rack_test_driver.rb', line 209

def find(selector)
  html.xpath(selector).map { |node| Node.new(self, node) }
end

#response_headersObject



198
199
200
# File 'lib/capybara/driver/rack_test_driver.rb', line 198

def response_headers
  response.headers
end

#submit(method, path, attributes) ⇒ Object



202
203
204
205
206
207
# File 'lib/capybara/driver/rack_test_driver.rb', line 202

def submit(method, path, attributes)
  path = current_path if not path or path.empty? 
  send(method, path, attributes, env)
  follow_redirects!
  cache_body
end

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



187
188
189
190
191
192
# File 'lib/capybara/driver/rack_test_driver.rb', line 187

def visit(path, attributes = {})
  return if path.gsub(/^#{current_path}/, '') =~ /^#/
  get(path, attributes, env)
  follow_redirects!
  cache_body
end