Class: Webrat::RailsAdapter

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ RailsAdapter

Returns a new instance of RailsAdapter.



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

def initialize(session)
  @integration_session = session
end

Instance Attribute Details

#integration_sessionObject (readonly)

Returns the value of attribute integration_session.



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

def integration_session
  @integration_session
end

Instance Method Details

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



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

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

#doc_rootObject



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

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

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



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

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

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



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

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

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



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

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

#response_bodyObject



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

def response_body
  response.body
end

#response_codeObject



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

def response_code
  response.code.to_i
end

#saved_page_dirObject



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

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


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

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)


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

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