@@ -69,29 +69,29 @@ def to_xml
6969
7070 context 'Accept header detection' do
7171 it 'should detect from the Accept header' do
72- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/xml' } )
72+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/xml' } )
7373 subject . env [ 'api.format' ] . should == :xml
7474 end
7575
7676 it 'should look for case-indifferent headers' do
77- subject . call ( { 'PATH_INFO' => '/info' , 'accept ' => 'application/xml' } )
77+ subject . call ( { 'PATH_INFO' => '/info' , 'http_accept ' => 'application/xml' } )
7878 subject . env [ 'api.format' ] . should == :xml
7979 end
8080
8181 it 'should use quality rankings to determine formats' do
82- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json; q=0.3,application/xml; q=1.0' } )
82+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json; q=0.3,application/xml; q=1.0' } )
8383 subject . env [ 'api.format' ] . should == :xml
84- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json; q=1.0,application/xml; q=0.3' } )
84+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json; q=1.0,application/xml; q=0.3' } )
8585 subject . env [ 'api.format' ] . should == :json
8686 end
8787
8888 it 'should handle quality rankings mixed with nothing' do
89- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json,application/xml; q=1.0' } )
89+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json,application/xml; q=1.0' } )
9090 subject . env [ 'api.format' ] . should == :xml
9191 end
9292
9393 it 'should properly parse headers with other attributes' do
94- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json; abc=2.3; q=1.0,application/xml; q=0.7' } )
94+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json; abc=2.3; q=1.0,application/xml; q=0.7' } )
9595 subject . env [ 'api.format' ] . should == :json
9696 end
9797 end
@@ -137,16 +137,16 @@ def to_xml
137137
138138 context 'Input' do
139139 it 'should parse the body from a POST/PUT and put the contents into rack.request.form_hash' do
140- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json' , 'rack.input' => StringIO . new ( '{"is_boolean":true,"string":"thing"}' ) } )
140+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json' , 'rack.input' => StringIO . new ( '{"is_boolean":true,"string":"thing"}' ) } )
141141 subject . env [ 'rack.request.form_hash' ] [ 'is_boolean' ] . should be_true
142142 subject . env [ 'rack.request.form_hash' ] [ 'string' ] . should == 'thing'
143143 end
144144 it 'should parse the body from an xml POST/PUT and put the contents into rack.request.from_hash' do
145- subject . call ( { 'PATH_INFO' => '/info.xml' , 'Accept ' => 'application/xml' , 'rack.input' => StringIO . new ( '<thing><name>Test</name></thing>' ) } )
145+ subject . call ( { 'PATH_INFO' => '/info.xml' , 'HTTP_ACCEPT ' => 'application/xml' , 'rack.input' => StringIO . new ( '<thing><name>Test</name></thing>' ) } )
146146 subject . env [ 'rack.request.form_hash' ] [ 'thing' ] [ 'name' ] . should == 'Test'
147147 end
148148 it 'should be able to fail gracefully if the body is regular POST content' do
149- subject . call ( { 'PATH_INFO' => '/info' , 'Accept ' => 'application/json' , 'rack.input' => StringIO . new ( 'name=Other+Test+Thing' ) } )
149+ subject . call ( { 'PATH_INFO' => '/info' , 'HTTP_ACCEPT ' => 'application/json' , 'rack.input' => StringIO . new ( 'name=Other+Test+Thing' ) } )
150150 subject . env [ 'rack.request.form_hash' ] . should be_nil
151151 end
152152 end
0 commit comments