Sha256: 9c6fae4d8458e2751b30fc8db7b2674136cdcdb79be1cb5e79c231d1e8d4dc85
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require 'rails_helper' describe LHC do context 'multipart' do let(:file) do ActionDispatch::Http::UploadedFile.new( tempfile: Tempfile.new, filename: 'image.jpg', type: 'image/jpeg', head: %q{Content-Disposition: form-data; name="files[]"; filename="image.jpg"\r\nContent-Type: image/jpeg\r\n} ) end let(:body) { { size: 2231 }.to_json } let(:location) { 'http://local.ch/uploads/image.jpg' } it 'leaves plains requests unformatted' do stub_request(:post, 'http://local.ch/') do |request| raise 'Content-Type header wrong' unless request.headers['Content-Type'] == 'multipart/form-data' raise 'Body wrongly formatted' unless request.body.match(/file=%23%3CActionDispatch%3A%3AHttp%3A%3AUploadedFile%3A.*%3E&type=Image/) end.to_return(status: 200, body: body, headers: { 'Location' => location }) response = LHC.multipart.post( 'http://local.ch', body: { file: file, type: 'Image' } ) expect(response.body).to eq body expect(response.headers['Location']).to eq location end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lhc-10.1.2 | spec/formats/multipart_spec.rb |
lhc-10.1.1 | spec/formats/multipart_spec.rb |
lhc-10.1.0 | spec/formats/multipart_spec.rb |