Class: Webrat::RailsSession

Inherits:
Session show all
Includes:
ActionController::RecordIdentifier
Defined in:
lib/webrat/rails.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Session

#current_url, #elements

Instance Method Summary collapse

Methods inherited from Session

#automate, #basic_auth, #check_for_infinite_redirects, #click_link_within, #current_dom, #current_page, #current_scope, #dom, #exception_caught?, #formatted_error, #header, #headers, #http_accept, #infinite_redirect_limit_exceeded?, #initialize, #internal_redirect?, #page_scope, #redirect?, #redirected_to, #reload, #request_page, #scopes, #simulate, #success_code?, #visit

Methods included from SaveAndOpenPage

#open_in_browser, #rewrite_css_and_image_references, #save_and_open_page

Methods included from Logging

#debug_log, #logger

Constructor Details

This class inherits a constructor from Webrat::Session

Instance Method Details

#delete(url, data, headers = nil) ⇒ Object



46
47
48
# File 'lib/webrat/rails.rb', line 46

def delete(url, data, headers = nil)
  do_request(:delete, url, data, headers)
end

#doc_rootObject



26
27
28
# File 'lib/webrat/rails.rb', line 26

def doc_root
  File.expand_path(File.join(RAILS_ROOT, 'public'))
end

#get(url, data, headers = nil) ⇒ Object



34
35
36
# File 'lib/webrat/rails.rb', line 34

def get(url, data, headers = nil)
  do_request(:get, url, data, headers)
end

#post(url, data, headers = nil) ⇒ Object



38
39
40
# File 'lib/webrat/rails.rb', line 38

def post(url, data, headers = nil)
  do_request(:post, url, data, headers)
end

#put(url, data, headers = nil) ⇒ Object



42
43
44
# File 'lib/webrat/rails.rb', line 42

def put(url, data, headers = nil)
  do_request(:put, url, data, headers)
end

#response_bodyObject



50
51
52
# File 'lib/webrat/rails.rb', line 50

def response_body
  response.body
end

#response_codeObject



54
55
56
# File 'lib/webrat/rails.rb', line 54

def response_code
  response.code.to_i
end

#saved_page_dirObject



30
31
32
# File 'lib/webrat/rails.rb', line 30

def saved_page_dir
  File.expand_path(File.join(RAILS_ROOT, "tmp"))
end

#within(selector_or_object, &block) ⇒ Object

The Rails version of within supports passing in a model and Webrat will apply a scope based on Rails’ dom_id for that model.

Example:

within User.last do
  click_link "Delete"
end


18
19
20
21
22
23
24
# File 'lib/webrat/rails.rb', line 18

def within(selector_or_object, &block)
  if selector_or_object.is_a?(String)
    super
  else
    super('#' + dom_id(selector_or_object), &block)
  end
end

#xml_content_type?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/webrat/rails.rb', line 58

def xml_content_type?
  response.headers["Content-Type"].to_s =~ /xml/
end