Class: Webrat::RailsAdapter
- Includes:
- ActionController::RecordIdentifier
- Defined in:
- lib/webrat/adapters/rails.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#integration_session ⇒ Object
readonly
Returns the value of attribute integration_session.
Instance Method Summary collapse
- #delete(url, data, headers = nil) ⇒ Object
- #doc_root ⇒ Object
- #get(url, data, headers = nil) ⇒ Object
-
#initialize(session) ⇒ RailsAdapter
constructor
A new instance of RailsAdapter.
- #post(url, data, headers = nil) ⇒ Object
- #put(url, data, headers = nil) ⇒ Object
- #response_body ⇒ Object
- #response_code ⇒ Object
- #saved_page_dir ⇒ Object
-
#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.
- #xml_content_type? ⇒ Boolean
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_session ⇒ Object (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_root ⇒ Object
29 30 31 |
# File 'lib/webrat/adapters/rails.rb', line 29 def doc_root File.(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_body ⇒ Object
53 54 55 |
# File 'lib/webrat/adapters/rails.rb', line 53 def response_body response.body end |
#response_code ⇒ Object
57 58 59 |
# File 'lib/webrat/adapters/rails.rb', line 57 def response_code response.code.to_i end |
#saved_page_dir ⇒ Object
33 34 35 |
# File 'lib/webrat/adapters/rails.rb', line 33 def saved_page_dir File.(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
61 62 63 |
# File 'lib/webrat/adapters/rails.rb', line 61 def xml_content_type? response.headers["Content-Type"].to_s =~ /xml/ end |