Module: ThoughtBot::Shoulda::Controller::XML
- Defined in:
- lib/shoulda/controller/formats/xml.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(other) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#assert_xml_response ⇒ Object
Asserts that the controller’s response was ‘application/xml’.
-
#request_xml ⇒ Object
Sets the next request’s format to ‘application/xml’.
Class Method Details
.included(other) ⇒ Object
:nodoc:
5 6 7 8 9 |
# File 'lib/shoulda/controller/formats/xml.rb', line 5 def self.included(other) #:nodoc: other.class_eval do extend ThoughtBot::Shoulda::Controller::XML::ClassMethods end end |
Instance Method Details
#assert_xml_response ⇒ Object
Asserts that the controller’s response was ‘application/xml’
157 158 159 160 161 162 163 164 165 |
# File 'lib/shoulda/controller/formats/xml.rb', line 157 def assert_xml_response content_type = (@response.headers["Content-Type"] || @response.headers["type"]).to_s regex = %r{\bapplication/xml\b} msg = "Content Type '#{content_type.inspect}' doesn't match '#{regex.inspect}'\n" msg += "Body: #{@response.body.first(100).chomp} ..." assert_match regex, content_type, msg end |
#request_xml ⇒ Object
Sets the next request’s format to ‘application/xml’
152 153 154 |
# File 'lib/shoulda/controller/formats/xml.rb', line 152 def request_xml @request.accept = "application/xml" end |