spec/grape/middleware/formatter_spec.rb in grape-0.14.0 vs spec/grape/middleware/formatter_spec.rb in grape-0.15.0
- old
+ new
@@ -48,11 +48,11 @@
end
context 'error handling' do
let(:formatter) { double(:formatter) }
before do
- allow(Grape::Formatter::Base).to receive(:formatter_for) { formatter }
+ 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') }
@@ -64,11 +64,11 @@
it 'does not rescue other exceptions' do
allow(formatter).to receive(:call) { fail StandardError }
expect do
catch(:error) { subject.call('PATH_INFO' => '/somewhere.xml', 'HTTP_ACCEPT' => 'application/json') }
- end.to raise_error
+ end.to raise_error(StandardError)
end
end
context 'detection' do
it 'uses the xml extension if one is provided' do
@@ -278,8 +278,18 @@
'CONTENT_LENGTH' => io.length
)
expect(subject.env['rack.request.form_hash']).to be_nil
end
end
+ end
+ end
+
+ context 'send file' do
+ let(:app) { ->(_env) { [200, {}, @body] } }
+
+ it 'returns Grape::Uril::SendFileReponse' do
+ @body = Grape::Util::FileResponse.new('file')
+ env = { 'PATH_INFO' => '/somewhere', 'HTTP_ACCEPT' => 'application/json' }
+ expect(subject.call(env)).to be_a(Grape::Util::SendfileResponse)
end
end
end