@@ -81,29 +81,29 @@ def to_xml
8181
8282 context 'Accept header detection' do
8383 it 'should detect from the Accept header' do
84- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/xml' } )
84+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/xml' } )
8585 subject . env [ 'api.format' ] . should == :xml
8686 end
8787
8888 it 'should look for case-indifferent headers' do
89- subject . call ( { 'PATH_INFO' => '/info' , 'accept ' => 'application/xml' } )
89+ subject . call ( { 'PATH_INFO' => '/info' , 'http_accept ' => 'application/xml' } )
9090 subject . env [ 'api.format' ] . should == :xml
9191 end
9292
9393 it 'should use quality rankings to determine formats' do
94- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json; q=0.3,application/xml; q=1.0' } )
94+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json; q=0.3,application/xml; q=1.0' } )
9595 subject . env [ 'api.format' ] . should == :xml
96- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json; q=1.0,application/xml; q=0.3' } )
96+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json; q=1.0,application/xml; q=0.3' } )
9797 subject . env [ 'api.format' ] . should == :json
9898 end
9999
100100 it 'should handle quality rankings mixed with nothing' do
101- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json,application/xml; q=1.0' } )
101+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json,application/xml; q=1.0' } )
102102 subject . env [ 'api.format' ] . should == :xml
103103 end
104104
105105 it 'should properly parse headers with other attributes' do
106- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json; abc=2.3; q=1.0,application/xml; q=0.7' } )
106+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json; abc=2.3; q=1.0,application/xml; q=0.7' } )
107107 subject . env [ 'api.format' ] . should == :json
108108 end
109109 end
@@ -149,16 +149,16 @@ def to_xml
149149
150150 context 'Input' do
151151 it 'should parse the body from a POST/PUT and put the contents into rack.request.form_hash' do
152- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json' , 'rack.input' => StringIO . new ( '{"is_boolean":true,"string":"thing"}' ) } )
152+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json' , 'rack.input' => StringIO . new ( '{"is_boolean":true,"string":"thing"}' ) } )
153153 subject . env [ 'rack.request.form_hash' ] [ 'is_boolean' ] . should be_true
154154 subject . env [ 'rack.request.form_hash' ] [ 'string' ] . should == 'thing'
155155 end
156156 it 'should parse the body from an xml POST/PUT and put the contents into rack.request.from_hash' do
157- subject . call ( { 'PATH_INFO' => '/info.xml' , 'Accept ' => 'application/xml' , 'rack.input' => StringIO . new ( '<thing><name>Test</name></thing>' ) } )
157+ subject . call ( { 'PATH_INFO' => '/info.xml' , 'HTTP_ACCEPT ' => 'application/xml' , 'rack.input' => StringIO . new ( '<thing><name>Test</name></thing>' ) } )
158158 subject . env [ 'rack.request.form_hash' ] [ 'thing' ] [ 'name' ] . should == 'Test'
159159 end
160160 it 'should be able to fail gracefully if the body is regular POST content' do
161- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json' , 'rack.input' => StringIO . new ( 'name=Other+Test+Thing' ) } )
161+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json' , 'rack.input' => StringIO . new ( 'name=Other+Test+Thing' ) } )
162162 subject . env [ 'rack.request.form_hash' ] . should be_nil
163163 end
164164 end
0 commit comments