cc-terminal 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/terminal/client.rb +4 -1
- data/lib/terminal/response/raise_error_from_json.rb +1 -1
- data/lib/terminal/version.rb +1 -1
- data/spec/fixtures/error_response.json +1 -1
- data/spec/helper.rb +7 -0
- data/spec/terminal/client_spec.rb +5 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 824b6749992e88f74e46ca0a771d3b3a5e4737a5
|
4
|
+
data.tar.gz: 2680c8d7ba9f1b40f58d771a28ae250b40c9da8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d26804f2f147a260d9520103e7f17a050d2beada6ed5d7a14980c9a90631b7bc39f608a6b9ef05ee816f66e9c4f090b60989e6695eaeae3d467da00a302b682
|
7
|
+
data.tar.gz: cfbce493620884723fdf480033e24a249b5e80fe67efc1668e75d40ae4408253a1bfa19b5f5ce0ee865757c7a7c036262e275d5816082908b05d453db6b08c4e
|
data/lib/terminal/client.rb
CHANGED
@@ -29,8 +29,11 @@ module Terminal
|
|
29
29
|
@connection ||= Faraday.new(API_URL, options) do | conn |
|
30
30
|
conn.request :encode_json
|
31
31
|
conn.adapter :net_http
|
32
|
-
|
32
|
+
|
33
|
+
# This ordering is important don't change
|
33
34
|
conn.response :raise_error_from_json
|
35
|
+
conn.response :parse_json
|
36
|
+
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
@@ -9,7 +9,7 @@ module Terminal
|
|
9
9
|
# Terminal.com always returns 200
|
10
10
|
code = response.status.to_i
|
11
11
|
|
12
|
-
if code == 200 && response.body[
|
12
|
+
if code == 200 && response.body[:success] == false || !response.body[:error].nil?
|
13
13
|
fail(Terminal::APIResponseError.new(response))
|
14
14
|
else
|
15
15
|
# How did we get here?
|
data/lib/terminal/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"error":"No such user"}
|
1
|
+
{"status": "failed", "error":"No such user"}
|
data/spec/helper.rb
CHANGED
@@ -9,7 +9,7 @@ describe Terminal::Client do
|
|
9
9
|
|
10
10
|
context 'when bad access_token,user_token are provided' do
|
11
11
|
it 'raises a configuration exception' do
|
12
|
-
|
12
|
+
expect { Terminal::Client.new(:access_token => 12121, :user_token => 12111111) }.to raise_exception(Terminal::APIConfigurationError)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
context 'when no access_token,user_token are provided' do
|
@@ -33,7 +33,10 @@ describe Terminal::Client do
|
|
33
33
|
|
34
34
|
it 'raises an API error from a response containing error JSON' do
|
35
35
|
stub_post('/path').to_return(:body => fixture('error_response.json'), :headers => {:content_type => 'application/json'})
|
36
|
-
expect { @client.send(:request, :post, '/path')}.to raise_error
|
36
|
+
expect { @client.send(:request, :post, '/path') }.to raise_error { |e|
|
37
|
+
e.should be_a(Terminal::APIResponseError)
|
38
|
+
e.response.body[:status].should equal?('failed')
|
39
|
+
}
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cc-terminal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timor Tsentsiper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|