spec/grape/middleware/formatter_spec.rb in grape-0.2.0 vs spec/grape/middleware/formatter_spec.rb in grape-0.2.1

- old
+ new

@@ -8,11 +8,11 @@ context 'serialization' do it 'should look at the bodies for possibly serializable data' do @body = {"abc" => "def"} status, headers, bodies = *subject.call({'PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/json'}) - bodies.each{|b| b.should == MultiJson.encode(@body) } + bodies.each{|b| b.should == MultiJson.dump(@body) } end it 'should call #to_json first if it is available' do @body = ['foo'] @body.instance_eval do @@ -80,15 +80,10 @@ it 'should use the file extension format if provided before headers' do subject.call({'PATH_INFO' => '/info.txt', 'HTTP_ACCEPT' => 'application/json'}) subject.env['api.format'].should == :txt end - - it 'should throw an error on an unrecognized format' do - err = catch(:error){ subject.call({'PATH_INFO' => '/info.barklar'}) } - err.should == {:status => 406, :message => "The requested format is not supported."} - end end context 'Accept header detection' do it 'should detect from the Accept header' do subject.call({'PATH_INFO' => '/info', 'HTTP_ACCEPT' => 'application/xml'}) @@ -118,9 +113,14 @@ end it 'should properly parse headers with vendor and api version' do subject.call({'PATH_INFO' => '/info', 'HTTP_ACCEPT' => 'application/vnd.test-v1+xml'}) subject.env['api.format'].should == :xml + end + + it 'should properly parse headers with symbols as hash keys' do + subject.call({'PATH_INFO' => '/info', 'http_accept' => 'application/xml', :system_time => '091293'}) + subject.env[:system_time].should == '091293' end end context 'Content-type' do it 'should be set for json' do