spec/grape/middleware/formatter_spec.rb in grape-0.16.2 vs spec/grape/middleware/formatter_spec.rb in grape-0.17.0
- old
+ new
@@ -15,22 +15,22 @@
it 'calls #to_json since default format is json' do
@body = ['foo']
@body.instance_eval do
def to_json
- "\"bar\""
+ '"bar"'
end
end
subject.call('PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/json').to_a.last.each { |b| expect(b).to eq('"bar"') }
end
it 'calls #to_json if the content type is jsonapi' do
@body = { 'foos' => [{ 'bar' => 'baz' }] }
@body.instance_eval do
def to_json
- "{\"foos\":[{\"bar\":\"baz\"}] }"
+ '{"foos":[{"bar":"baz"}] }'
end
end
subject.call('PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/vnd.api+json').to_a.last.each { |b| expect(b).to eq('{"foos":[{"bar":"baz"}] }') }
end
@@ -52,18 +52,18 @@
before do
allow(Grape::Formatter).to receive(:formatter_for) { formatter }
end
it 'rescues formatter-specific exceptions' do
- allow(formatter).to receive(:call) { fail Grape::Exceptions::InvalidFormatter.new(String, 'xml') }
+ allow(formatter).to receive(:call) { raise Grape::Exceptions::InvalidFormatter.new(String, 'xml') }
expect do
catch(:error) { subject.call('PATH_INFO' => '/somewhere.xml', 'HTTP_ACCEPT' => 'application/json') }
end.to_not raise_error
end
it 'does not rescue other exceptions' do
- allow(formatter).to receive(:call) { fail StandardError }
+ allow(formatter).to receive(:call) { raise StandardError }
expect do
catch(:error) { subject.call('PATH_INFO' => '/somewhere.xml', 'HTTP_ACCEPT' => 'application/json') }
end.to raise_error(StandardError)
end