File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ module Formats
5454 FORMATTERS = {
5555 :json => :encode_json ,
5656 :txt => :encode_txt ,
57+ :xml => :encode_xml
5758 }
5859 PARSERS = {
5960 :json => :decode_json
@@ -120,6 +121,10 @@ def encode_json(object)
120121 def encode_txt ( object )
121122 object . respond_to? ( :to_txt ) ? object . to_txt : object . to_s
122123 end
124+
125+ def encode_xml ( object )
126+ object . respond_to? ( :to_xml ) ? object . to_xml : object . to_s
127+ end
123128 end
124129
125130 end
Original file line number Diff line number Diff line change @@ -35,6 +35,17 @@ def serializable_hash
3535
3636 subject . call ( { 'PATH_INFO' => '/somewhere' } ) . last . each { |b | b . should == '{"abc":"def"}' }
3737 end
38+
39+ it 'should call #to_xml if the content type is xml' do
40+ @body = "string"
41+ @body . instance_eval do
42+ def to_xml
43+ "<bar/>"
44+ end
45+ end
46+
47+ subject . call ( { 'PATH_INFO' => '/somewhere.xml' } ) . last . each { |b | b . should == '<bar/>' }
48+ end
3849 end
3950
4051 context 'detection' do
You can’t perform that action at this time.
0 commit comments