Class: Webrat::RailsAdapter

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ RailsAdapter

Returns a new instance of RailsAdapter.



9
10
11
# File 'lib/webrat/rails.rb', line 9

def initialize(session)
  @integration_session = session
end

Instance Attribute Details

#integration_sessionObject (readonly)

Returns the value of attribute integration_session.



7
8
9
# File 'lib/webrat/rails.rb', line 7

def integration_session
  @integration_session
end

Instance Method Details

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



48
49
50
# File 'lib/webrat/rails.rb', line 48

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

#doc_rootObject



28
29
30
# File 'lib/webrat/rails.rb', line 28

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

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



36
37
38
# File 'lib/webrat/rails.rb', line 36

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

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



40
41
42
# File 'lib/webrat/rails.rb', line 40

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

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



44
45
46
# File 'lib/webrat/rails.rb', line 44

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

#response_bodyObject



52
53
54
# File 'lib/webrat/rails.rb', line 52

def response_body
  response.body
end

#response_codeObject



56
57
58
# File 'lib/webrat/rails.rb', line 56

def response_code
  response.code.to_i
end

#saved_page_dirObject



32
33
34
# File 'lib/webrat/rails.rb', line 32

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


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

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)


60
61
62
# File 'lib/webrat/rails.rb', line 60

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