Class: Webrat::RailsAdapter
- Includes:
- ActionController::RecordIdentifier
- Defined in:
- lib/webrat/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.
13 14 15 |
# File 'lib/webrat/rails.rb', line 13 def initialize(session) @integration_session = session end |
Instance Attribute Details
#integration_session ⇒ Object (readonly)
Returns the value of attribute integration_session.
11 12 13 |
# File 'lib/webrat/rails.rb', line 11 def integration_session @integration_session end |
Instance Method Details
#delete(url, data, headers = nil) ⇒ Object
52 53 54 |
# File 'lib/webrat/rails.rb', line 52 def delete(url, data, headers = nil) do_request(:delete, url, data, headers) end |
#doc_root ⇒ Object
32 33 34 |
# File 'lib/webrat/rails.rb', line 32 def doc_root File.(File.join(RAILS_ROOT, 'public')) end |
#get(url, data, headers = nil) ⇒ Object
40 41 42 |
# File 'lib/webrat/rails.rb', line 40 def get(url, data, headers = nil) do_request(:get, url, data, headers) end |
#post(url, data, headers = nil) ⇒ Object
44 45 46 |
# File 'lib/webrat/rails.rb', line 44 def post(url, data, headers = nil) do_request(:post, url, data, headers) end |
#put(url, data, headers = nil) ⇒ Object
48 49 50 |
# File 'lib/webrat/rails.rb', line 48 def put(url, data, headers = nil) do_request(:put, url, data, headers) end |
#response_body ⇒ Object
56 57 58 |
# File 'lib/webrat/rails.rb', line 56 def response_body response.body end |
#response_code ⇒ Object
60 61 62 |
# File 'lib/webrat/rails.rb', line 60 def response_code response.code.to_i end |
#saved_page_dir ⇒ Object
36 37 38 |
# File 'lib/webrat/rails.rb', line 36 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
24 25 26 27 28 29 30 |
# File 'lib/webrat/rails.rb', line 24 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
64 65 66 |
# File 'lib/webrat/rails.rb', line 64 def xml_content_type? response.headers["Content-Type"].to_s =~ /xml/ end |