hyperion_http 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a79b181774b51de90a86b8e92af8e2283428362
4
- data.tar.gz: 86b80d5e03d10455cd04332e139d5d0df54f7f71
3
+ metadata.gz: ff839cd9280b6f5ca5629404af5eed86a6bd44e4
4
+ data.tar.gz: 4cfd0125216b32cb9c01f59cda244314a0eb0994
5
5
  SHA512:
6
- metadata.gz: e8eabe59299e06d096b2dd248f18970d614ca6aae862098c89dfa2f53b6c90c564b932e278514ca7d02ad4ccab86ec4fbbb3b9d1fa7d282fc14f9cc176b613ce
7
- data.tar.gz: 8c439f16af5b3bf31e34d81eeb74bc32630c2f7b08a303292e7c6dfce9737c83fe6caedaf07b60eec7e4524dda44ca7e5d7695e9c74bce0a383c836d896e8c91
6
+ metadata.gz: 656b2d028d48ff5d374fca0c048ef55b6e97e5aff5fede47bb2adc5bd5c840406bfca6ce587933747584003dbf71589ddda53afcce573b438742784bcf3c7bec
7
+ data.tar.gz: f1c71106ea625105e8a02fc4d8edb6c600b641e45982300c2b661132f341fd363af5f74317f3c32be8c9dfbe25bc33013a6312b4ac2109aa228e37baaf4ca2ef
@@ -1,3 +1,3 @@
1
1
  class Hyperion
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
@@ -31,6 +31,7 @@ class Hyperion
31
31
  case Formats.get_from(format)
32
32
  when :json; read_json(bytes)
33
33
  when :protobuf; bytes
34
+ when Multipart.format; bytes # currently only used for testing purposes
34
35
  else; fail "Unsupported format: #{format}"
35
36
  end
36
37
  end
@@ -27,7 +27,8 @@ class Hyperion
27
27
  end
28
28
 
29
29
  ContentTypes = [[:json, 'application/json'],
30
- [:protobuf, 'application/x-protobuf']]
30
+ [:protobuf, 'application/x-protobuf'],
31
+ [Multipart.format, Multipart.content_type]]
31
32
 
32
33
  def content_type_for(format)
33
34
  format = Hyperion::Formats.get_from(format)
@@ -36,7 +37,7 @@ class Hyperion
36
37
  end
37
38
 
38
39
  def format_for(content_type)
39
- ct = ContentTypes.detect{|x| x.last == content_type}
40
+ ct = ContentTypes.detect{|x| x.last == content_type.split(';')[0]}
40
41
  fail "Unsupported content type: #{content_type}" unless ct
41
42
  ct.first
42
43
  end
@@ -1 +1,9 @@
1
- Multipart = Struct.new(:body)
1
+ Multipart = Struct.new(:body) do
2
+ def self.format
3
+ :multipart
4
+ end
5
+
6
+ def self.content_type
7
+ 'multipart/form-data'
8
+ end
9
+ end
File without changes
@@ -82,6 +82,13 @@ class Hyperion
82
82
  it 'allows protobuf format but just passes it through' do
83
83
  expect(read('x', :protobuf)).to eql 'x'
84
84
  end
85
+ it 'allows multipart format data format but just passes it through' do
86
+ data = '--------------------------0bf18f00cf53ec0e' +
87
+ 'Content-Disposition: form-data; name="file"; filename="test"' +
88
+ 'Content-Type: application/octet-stream' +
89
+ '--------------------------0bf18f00cf53ec0e--'
90
+ expect(read(data, Multipart.format)).to eql data
91
+ end
85
92
  end
86
93
  end
87
94
  end
@@ -51,6 +51,7 @@ class Hyperion
51
51
  it 'returns the format for the given content type' do
52
52
  expect(format_for('application/json')).to eql :json
53
53
  expect(format_for('application/x-protobuf')).to eql :protobuf
54
+ expect(format_for('multipart/form-data; boundary=------------------------2b463b63688b28fa')).to eql Multipart.format
54
55
  end
55
56
  it 'raises an error if the content type is unknown' do
56
57
  expect{format_for('aaa/bbb')}.to raise_error
@@ -0,0 +1,24 @@
1
+ require 'rspec'
2
+ require 'hyperion/requestor'
3
+ require 'hyperion_test'
4
+
5
+ describe 'fake_route' do
6
+ include Hyperion::Requestor
7
+
8
+ context 'for multipart form data as a part of the body' do
9
+ let(:uri) { File.join('http://test.com', 'convert') }
10
+ let(:response_descriptor) { ResponseDescriptor.new('converted_sample', 1, :json) }
11
+ let(:route) { RestRoute.new(:post, uri, response_descriptor) }
12
+ let(:response) { {'x' => 1} }
13
+
14
+ it 'it fakes the given response' do
15
+ fake_route(route, JSON.dump(response))
16
+ expect(make_request(route)).to eql response
17
+ end
18
+
19
+ def make_request(route)
20
+ body = Multipart.new(file: File.open(File.expand_path('spec/fixtures/test'), 'r'))
21
+ request(route, body: body)
22
+ end
23
+ end
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperion_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indigo BioAutomation, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-16 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -241,6 +241,7 @@ files:
241
241
  - lib/hyperion_test/fake_server/types.rb
242
242
  - lib/hyperion_test/spec_helper.rb
243
243
  - lib/hyperion_test/test_framework_hooks.rb
244
+ - spec/fixtures/test
244
245
  - spec/lib/hyperion/aux/util_spec.rb
245
246
  - spec/lib/hyperion/formats_spec.rb
246
247
  - spec/lib/hyperion/headers_spec.rb
@@ -251,6 +252,7 @@ files:
251
252
  - spec/lib/hyperion/types/hyperion_result_spec.rb
252
253
  - spec/lib/hyperion/types/hyperion_uri_spec.rb
253
254
  - spec/lib/hyperion_spec.rb
255
+ - spec/lib/hyperion_test/fake_route_spec.rb
254
256
  - spec/lib/types_spec.rb
255
257
  - spec/spec_helper.rb
256
258
  - spec/support/core_helpers.rb
@@ -279,6 +281,7 @@ signing_key:
279
281
  specification_version: 4
280
282
  summary: Ruby REST client
281
283
  test_files:
284
+ - spec/fixtures/test
282
285
  - spec/lib/hyperion/aux/util_spec.rb
283
286
  - spec/lib/hyperion/formats_spec.rb
284
287
  - spec/lib/hyperion/headers_spec.rb
@@ -289,6 +292,7 @@ test_files:
289
292
  - spec/lib/hyperion/types/hyperion_result_spec.rb
290
293
  - spec/lib/hyperion/types/hyperion_uri_spec.rb
291
294
  - spec/lib/hyperion_spec.rb
295
+ - spec/lib/hyperion_test/fake_route_spec.rb
292
296
  - spec/lib/types_spec.rb
293
297
  - spec/spec_helper.rb
294
298
  - spec/support/core_helpers.rb