diff --git a/lib/fog/rackspace/files.rb b/lib/fog/rackspace/files.rb index 9647082de..778574349 100644 --- a/lib/fog/rackspace/files.rb +++ b/lib/fog/rackspace/files.rb @@ -107,7 +107,7 @@ module Fog :host => @cdn_host, :path => "#{@cdn_path}/#{params[:path]}", })) - unless response.body.empty? + if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json} response.body = JSON.parse(response.body) end response @@ -122,7 +122,7 @@ module Fog :host => @storage_host, :path => "#{@storage_path}/#{params[:path]}", }), &block) - if !response.body.empty? && parse_json && response.headers['Content-Type'] == 'application/json' + if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json} response.body = JSON.parse(response.body) end response diff --git a/spec/rackspace/requests/files/get_container_spec.rb b/spec/rackspace/requests/files/get_container_spec.rb index db1220202..72432a7f3 100644 --- a/spec/rackspace/requests/files/get_container_spec.rb +++ b/spec/rackspace/requests/files/get_container_spec.rb @@ -25,8 +25,10 @@ describe 'Rackspace::Files.get_container' do end describe 'failure' do - it "should not raise an if the container does not exist" do - Rackspace[:files].get_container('container_name') + it "should raise a NotFound error if the container does not exist" do + lambda do + Rackspace[:files].get_container('container_name') + end.should raise_error(Excon::Errors::NotFound) end end