cloudsight 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.tool-versions +1 -0
- data/.travis.yml +3 -2
- data/cloudsight.gemspec +1 -1
- data/lib/cloudsight/request.rb +6 -0
- data/lib/cloudsight/response.rb +3 -0
- data/lib/cloudsight/version.rb +1 -1
- data/spec/cloudsight/request_spec.rb +21 -1
- data/spec/cloudsight/response_spec.rb +15 -0
- data/spec/fixtures/invalid_json.json +9 -0
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b27c9ad341947fd8365b93eeca9202c44bc6997cc153171e45528e0a4f7553e
|
4
|
+
data.tar.gz: c4a7a7de5c7b9704925edbab211097e675802937ea3d71070ddd10624c54dfe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 575f5503cee38dfd89d8f58cae1a04ee9ba994d6b0dd03f7ebdf9ee917e8c3923a40c66ffd4ceb7b6221dc4cef6bf4cc5645c14d0f2c5efab8011454418d1ed5
|
7
|
+
data.tar.gz: 439fb02ed6c5164ca146d76150832729c348260337b918205bcb753fa1220aa0fbc3f9ed9652baf596f2fc35918caf5ab1d966215d7d88078b6af7507a87ad41
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.1
|
data/.travis.yml
CHANGED
data/cloudsight.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_dependency 'json', '~> 2.1'
|
26
26
|
s.add_dependency 'rest-client', '~> 2.0'
|
27
27
|
|
28
|
-
s.add_development_dependency 'bundler', '~>
|
28
|
+
s.add_development_dependency 'bundler', '~> 2.0'
|
29
29
|
s.add_development_dependency 'rake', '~> 12.0'
|
30
30
|
s.add_development_dependency 'rspec', '~> 3.6'
|
31
31
|
s.add_development_dependency 'pry', '~> 0.10'
|
data/lib/cloudsight/request.rb
CHANGED
@@ -12,6 +12,9 @@ module Cloudsight
|
|
12
12
|
raise UnexpectedResponseException.new(response.body) unless data['token']
|
13
13
|
|
14
14
|
data
|
15
|
+
|
16
|
+
rescue JSON::ParserError
|
17
|
+
raise UnexpectedResponseException.new(response.body)
|
15
18
|
end
|
16
19
|
|
17
20
|
def repost(token, options = {})
|
@@ -25,6 +28,9 @@ module Cloudsight
|
|
25
28
|
raise UnexpectedResponseException.new(response.body) unless data['token']
|
26
29
|
|
27
30
|
data
|
31
|
+
|
32
|
+
rescue JSON::ParserError
|
33
|
+
raise UnexpectedResponseException.new(response.body)
|
28
34
|
end
|
29
35
|
|
30
36
|
def construct_params(options)
|
data/lib/cloudsight/response.rb
CHANGED
data/lib/cloudsight/version.rb
CHANGED
@@ -55,7 +55,7 @@ RSpec.describe Cloudsight::Request do
|
|
55
55
|
response: fixture_file('image_request.json')
|
56
56
|
)
|
57
57
|
|
58
|
-
response = described_class.send(params)
|
58
|
+
response = described_class.send(params)
|
59
59
|
|
60
60
|
expect(response["token"]).to eq "sample_token"
|
61
61
|
expect(response["url"]).to eq "https://example.com/image.jpg"
|
@@ -81,6 +81,16 @@ RSpec.describe Cloudsight::Request do
|
|
81
81
|
|
82
82
|
expect { described_class.send(params) }.to raise_error Cloudsight::UnexpectedResponseException
|
83
83
|
end
|
84
|
+
|
85
|
+
it 'responds correctly to an invalid JSON response' do
|
86
|
+
stub_post(
|
87
|
+
path: '/v1/images',
|
88
|
+
body: { "locale" => "en", "remote_image_url" => "test_url" },
|
89
|
+
response: fixture_file('invalid_json.json')
|
90
|
+
)
|
91
|
+
|
92
|
+
expect { described_class.send(params) }.to raise_error Cloudsight::UnexpectedResponseException
|
93
|
+
end
|
84
94
|
end
|
85
95
|
|
86
96
|
describe '#repost' do
|
@@ -119,5 +129,15 @@ RSpec.describe Cloudsight::Request do
|
|
119
129
|
|
120
130
|
expect { described_class.repost('sample_token', params) }.to raise_error Cloudsight::UnexpectedResponseException
|
121
131
|
end
|
132
|
+
|
133
|
+
it 'responds correctly to an invalid JSON response' do
|
134
|
+
stub_post(
|
135
|
+
path: '/v1/images/sample_token/repost',
|
136
|
+
body: { "locale" => "en", "remote_image_url" => "test_url" },
|
137
|
+
response: fixture_file('invalid_json.json')
|
138
|
+
)
|
139
|
+
|
140
|
+
expect { described_class.repost('sample_token', params) }.to raise_error Cloudsight::UnexpectedResponseException
|
141
|
+
end
|
122
142
|
end
|
123
143
|
end
|
@@ -36,6 +36,15 @@ RSpec.describe Cloudsight::Response do
|
|
36
36
|
|
37
37
|
expect { described_class.get('sample_token') }.to raise_error Cloudsight::UnexpectedResponseException
|
38
38
|
end
|
39
|
+
|
40
|
+
it 'responds correctly to an invalid JSON response' do
|
41
|
+
stub_get(
|
42
|
+
path: '/v1/images/sample_token',
|
43
|
+
response: fixture_file('invalid_json.json')
|
44
|
+
)
|
45
|
+
|
46
|
+
expect { described_class.get('sample_token') }.to raise_error Cloudsight::UnexpectedResponseException
|
47
|
+
end
|
39
48
|
end
|
40
49
|
|
41
50
|
describe '#retrieve' do
|
@@ -60,6 +69,12 @@ RSpec.describe Cloudsight::Response do
|
|
60
69
|
|
61
70
|
expect { described_class.retrieve('sample_token', poll_wait: 0.01) }.to raise_error Cloudsight::UnexpectedResponseException
|
62
71
|
end
|
72
|
+
|
73
|
+
it 'responds correctly to an invalid JSON response' do
|
74
|
+
stub_polling(3, 'image_request.json', 'invalid_json.json', '/v1/images/sample_token')
|
75
|
+
|
76
|
+
expect { described_class.retrieve('sample_token', poll_wait: 0.01) }.to raise_error Cloudsight::UnexpectedResponseException
|
77
|
+
end
|
63
78
|
end
|
64
79
|
end
|
65
80
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<html><head>
|
2
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
3
|
+
<title>502 Server Error</title>
|
4
|
+
</head>
|
5
|
+
<body text=#000000 bgcolor=#ffffff>
|
6
|
+
<h1>Error: Server Error</h1>
|
7
|
+
<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
|
8
|
+
<h2></h2>
|
9
|
+
</body></html>
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudsight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Folkens
|
8
8
|
- Jack McCallum
|
9
9
|
- Chris Weilemann
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-09-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -46,14 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '2.0'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '2.0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rake
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,6 +134,7 @@ extra_rdoc_files: []
|
|
134
134
|
files:
|
135
135
|
- ".gitignore"
|
136
136
|
- ".rspec"
|
137
|
+
- ".tool-versions"
|
137
138
|
- ".travis.yml"
|
138
139
|
- Gemfile
|
139
140
|
- MIT-LICENSE
|
@@ -154,13 +155,14 @@ files:
|
|
154
155
|
- spec/fixtures/completed_response.json
|
155
156
|
- spec/fixtures/error_response.json
|
156
157
|
- spec/fixtures/image_request.json
|
158
|
+
- spec/fixtures/invalid_json.json
|
157
159
|
- spec/fixtures/unexpected_response.json
|
158
160
|
- spec/spec_helper.rb
|
159
161
|
homepage: http://github.com/cloudsight/cloudsight-ruby
|
160
162
|
licenses:
|
161
163
|
- MIT
|
162
164
|
metadata: {}
|
163
|
-
post_install_message:
|
165
|
+
post_install_message:
|
164
166
|
rdoc_options: []
|
165
167
|
require_paths:
|
166
168
|
- lib
|
@@ -175,9 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
177
|
- !ruby/object:Gem::Version
|
176
178
|
version: '0'
|
177
179
|
requirements: []
|
178
|
-
|
179
|
-
|
180
|
-
signing_key:
|
180
|
+
rubygems_version: 3.1.2
|
181
|
+
signing_key:
|
181
182
|
specification_version: 4
|
182
183
|
summary: CloudSight API Client
|
183
184
|
test_files:
|
@@ -188,5 +189,6 @@ test_files:
|
|
188
189
|
- spec/fixtures/completed_response.json
|
189
190
|
- spec/fixtures/error_response.json
|
190
191
|
- spec/fixtures/image_request.json
|
192
|
+
- spec/fixtures/invalid_json.json
|
191
193
|
- spec/fixtures/unexpected_response.json
|
192
194
|
- spec/spec_helper.rb
|