tijuana_client 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +3 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +84 -79
- data/README.md +3 -1
- data/VERSION +1 -1
- data/lib/tijuana_client.rb +1 -0
- data/lib/tijuana_client/client.rb +1 -1
- data/lib/tijuana_client/error_middleware.rb +24 -0
- data/spec/client_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -6
- data/spec/tijuana_spec.rb +2 -2
- data/spec/user_spec.rb +22 -4
- data/tijuana_client.gemspec +13 -11
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bb1dbe9e00346de49536c7cb6e548426035d8e7
|
4
|
+
data.tar.gz: b4a29258b1a2c379990efbeca670a4d25624436d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0ff7de8a5e482d6a1ac1282d4879ef6e407ade651420f1c5835db7fa0b82a00d409bb359f734581b1338f0f0060693bf19381e97536461260fc7299749d271b
|
7
|
+
data.tar.gz: 873c81447a873554ed4aa30b2dbbcfce591e8c722bcd1cda2e2d964b83a875f8c0b0a90e5f887eef8b5810b6ed55b73f2f35f6374516dbec3d1cb8610aa5fa3f
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0-p645
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,98 +1,100 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (4.
|
5
|
-
i18n (~> 0.
|
6
|
-
|
7
|
-
|
8
|
-
thread_safe (~> 0.
|
9
|
-
tzinfo (~>
|
10
|
-
addressable (2.3.
|
11
|
-
atomic (1.1.10)
|
4
|
+
activesupport (4.2.3)
|
5
|
+
i18n (~> 0.7)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
addressable (2.3.8)
|
12
11
|
builder (3.2.2)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
nokogiri (~> 1.5.2)
|
12
|
+
byebug (4.0.5)
|
13
|
+
columnize (= 0.9.0)
|
14
|
+
coderay (1.1.0)
|
15
|
+
columnize (0.9.0)
|
16
|
+
crack (0.4.2)
|
17
|
+
safe_yaml (~> 1.0.0)
|
18
|
+
descendants_tracker (0.0.4)
|
19
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
20
|
+
diff-lcs (1.2.5)
|
21
|
+
faraday (0.9.1)
|
22
|
+
multipart-post (>= 1.2, < 3)
|
23
|
+
faraday_middleware (0.10.0)
|
24
|
+
faraday (>= 0.7.4, < 0.10)
|
25
|
+
git (1.2.9.1)
|
26
|
+
github_api (0.12.3)
|
27
|
+
addressable (~> 2.3)
|
28
|
+
descendants_tracker (~> 0.0.4)
|
29
|
+
faraday (~> 0.8, < 0.10)
|
30
|
+
hashie (>= 3.3)
|
31
|
+
multi_json (>= 1.7.5, < 2.0)
|
32
|
+
nokogiri (~> 1.6.3)
|
35
33
|
oauth2
|
36
|
-
hashie (
|
37
|
-
highline (1.
|
38
|
-
|
39
|
-
|
40
|
-
jeweler (1.8.6)
|
34
|
+
hashie (3.4.2)
|
35
|
+
highline (1.7.2)
|
36
|
+
i18n (0.7.0)
|
37
|
+
jeweler (2.0.1)
|
41
38
|
builder
|
42
|
-
bundler (
|
39
|
+
bundler (>= 1.0)
|
43
40
|
git (>= 1.2.5)
|
44
|
-
github_api
|
41
|
+
github_api
|
45
42
|
highline (>= 1.6.15)
|
46
|
-
nokogiri (
|
43
|
+
nokogiri (>= 1.5.10)
|
47
44
|
rake
|
48
45
|
rdoc
|
49
|
-
json (1.8.
|
50
|
-
jwt (
|
51
|
-
|
52
|
-
|
53
|
-
minitest (
|
54
|
-
multi_json (1.
|
55
|
-
multi_xml (0.5.
|
56
|
-
multipart-post (
|
57
|
-
nokogiri (1.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
jwt (~>
|
62
|
-
multi_json (~> 1.
|
46
|
+
json (1.8.3)
|
47
|
+
jwt (1.5.1)
|
48
|
+
method_source (0.8.2)
|
49
|
+
mini_portile (0.6.2)
|
50
|
+
minitest (5.7.0)
|
51
|
+
multi_json (1.11.2)
|
52
|
+
multi_xml (0.5.5)
|
53
|
+
multipart-post (2.0.0)
|
54
|
+
nokogiri (1.6.6.2)
|
55
|
+
mini_portile (~> 0.6.0)
|
56
|
+
oauth2 (1.0.0)
|
57
|
+
faraday (>= 0.8, < 0.10)
|
58
|
+
jwt (~> 1.0)
|
59
|
+
multi_json (~> 1.3)
|
63
60
|
multi_xml (~> 0.5)
|
64
61
|
rack (~> 1.2)
|
65
|
-
pry (0.
|
66
|
-
coderay (~> 1.0
|
67
|
-
method_source (~> 0.8)
|
62
|
+
pry (0.10.1)
|
63
|
+
coderay (~> 1.1.0)
|
64
|
+
method_source (~> 0.8.1)
|
68
65
|
slop (~> 3.4)
|
69
|
-
pry-
|
70
|
-
|
71
|
-
pry (~> 0.
|
72
|
-
rack (1.
|
73
|
-
rake (10.
|
74
|
-
rdoc (4.0
|
66
|
+
pry-byebug (3.1.0)
|
67
|
+
byebug (~> 4.0)
|
68
|
+
pry (~> 0.10)
|
69
|
+
rack (1.6.4)
|
70
|
+
rake (10.4.2)
|
71
|
+
rdoc (4.2.0)
|
75
72
|
json (~> 1.4)
|
76
|
-
rspec (
|
77
|
-
rspec-core (~>
|
78
|
-
rspec-expectations (~>
|
79
|
-
rspec-mocks (~>
|
80
|
-
rspec-core (
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
73
|
+
rspec (3.3.0)
|
74
|
+
rspec-core (~> 3.3.0)
|
75
|
+
rspec-expectations (~> 3.3.0)
|
76
|
+
rspec-mocks (~> 3.3.0)
|
77
|
+
rspec-core (3.3.1)
|
78
|
+
rspec-support (~> 3.3.0)
|
79
|
+
rspec-expectations (3.3.0)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.3.0)
|
82
|
+
rspec-mocks (3.3.1)
|
83
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
+
rspec-support (~> 3.3.0)
|
85
|
+
rspec-support (3.3.0)
|
86
|
+
safe_yaml (1.0.4)
|
87
|
+
slop (3.6.0)
|
88
|
+
thread_safe (0.3.5)
|
89
|
+
tzinfo (1.2.2)
|
90
|
+
thread_safe (~> 0.1)
|
91
|
+
vertebrae (0.2.11)
|
90
92
|
activesupport
|
91
93
|
faraday
|
92
94
|
faraday_middleware
|
93
95
|
hashie
|
94
|
-
webmock (1.
|
95
|
-
addressable (>= 2.
|
96
|
+
webmock (1.21.0)
|
97
|
+
addressable (>= 2.3.6)
|
96
98
|
crack (>= 0.3.2)
|
97
99
|
|
98
100
|
PLATFORMS
|
@@ -100,9 +102,12 @@ PLATFORMS
|
|
100
102
|
|
101
103
|
DEPENDENCIES
|
102
104
|
bundler
|
103
|
-
jeweler (~>
|
105
|
+
jeweler (~> 2.0.0)
|
104
106
|
pry
|
105
|
-
pry-
|
107
|
+
pry-byebug
|
106
108
|
rspec
|
107
109
|
vertebrae
|
108
110
|
webmock
|
111
|
+
|
112
|
+
BUNDLED WITH
|
113
|
+
1.10.5
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/tijuana_client.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
module TijuanaClient
|
2
|
+
class ValidationError < ::Faraday::Error::ClientError ; end
|
3
|
+
class EmailValidationError < ::Faraday::Error::ClientError ; end
|
4
|
+
|
5
|
+
class ErrorMiddleware < ::Faraday::Response::RaiseError
|
6
|
+
def on_complete(env)
|
7
|
+
case env[:status]
|
8
|
+
when 400
|
9
|
+
if env.body.present?
|
10
|
+
response = JSON.parse(env.body)
|
11
|
+
if response['email'] && response['email'].include?('is invalid')
|
12
|
+
raise TijuanaClient::EmailValidationError, response_values(env).to_s
|
13
|
+
else
|
14
|
+
raise TijuanaClient::ValidationError, response_values(env).to_s
|
15
|
+
end
|
16
|
+
else
|
17
|
+
raise TijuanaClient::ValidationError, response_values(env).to_s
|
18
|
+
end
|
19
|
+
when ClientErrorStatuses
|
20
|
+
raise Faraday::Error::ClientError, response_values(env).to_s
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe TijuanaClient::Client do
|
4
|
-
specify { subject.
|
4
|
+
specify { expect(subject).to respond_to :user }
|
5
5
|
|
6
6
|
describe "instantiated" do
|
7
7
|
subject { described_class.new(options) }
|
@@ -9,8 +9,8 @@ describe TijuanaClient::Client do
|
|
9
9
|
context 'process_basic_auth' do
|
10
10
|
let(:options) { { :basic_auth => 'login:password' } }
|
11
11
|
let(:config) { subject.connection.configuration }
|
12
|
-
specify { config.username.
|
13
|
-
specify { config.password.
|
12
|
+
specify { expect(config.username).to eq 'login' }
|
13
|
+
specify { expect(config.password).to eq 'password' }
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -10,21 +10,18 @@ require 'webmock/rspec'
|
|
10
10
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
|
-
config.
|
13
|
+
config.color = true
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
16
|
RSpec.configure do |config|
|
18
17
|
config.include WebMock::API
|
19
18
|
|
20
|
-
|
21
19
|
config.before(:each) do
|
22
20
|
WebMock.reset!
|
23
21
|
end
|
24
22
|
config.after(:each) do
|
25
23
|
WebMock.reset!
|
26
24
|
end
|
27
|
-
|
28
25
|
end
|
29
26
|
|
30
27
|
def stub_get(path)
|
@@ -40,8 +37,6 @@ def stub_tijuana_request(method, path)
|
|
40
37
|
stub_request(method, "https://test.com" + prefix + path)
|
41
38
|
end
|
42
39
|
|
43
|
-
|
44
|
-
|
45
40
|
def fixture_path
|
46
41
|
File.expand_path("../fixtures", __FILE__)
|
47
42
|
end
|
data/spec/tijuana_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe TijuanaClient do
|
4
|
-
specify { subject.
|
5
|
-
specify { subject.new.
|
4
|
+
specify { expect(subject).to respond_to :user }
|
5
|
+
specify { expect(subject.new).to be_a(TijuanaClient::Client)}
|
6
6
|
end
|
data/spec/user_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe TijuanaClient::User do
|
|
5
5
|
|
6
6
|
describe 'configuration' do
|
7
7
|
it 'should propagate the host' do
|
8
|
-
subject.user.client.connection.configuration.host.
|
8
|
+
expect(subject.user.client.connection.configuration.host).to eq('test.com')
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -16,7 +16,7 @@ describe TijuanaClient::User do
|
|
16
16
|
let(:params) { {first_name: 'Nathan'} }
|
17
17
|
|
18
18
|
it 'should jsonify params' do
|
19
|
-
client.
|
19
|
+
expect(client).to receive(:post_request).with('/foo', {'data' => JSON.generate({ first_name: 'Nathan'}) } )
|
20
20
|
client.post_json_request(path, params)
|
21
21
|
end
|
22
22
|
end
|
@@ -42,8 +42,26 @@ describe TijuanaClient::User do
|
|
42
42
|
describe 'an error' do
|
43
43
|
let(:status) { 500 }
|
44
44
|
|
45
|
+
it 'should raise' do
|
46
|
+
expect { subject.user.create(first_name: 'Nathan') }.to raise_exception(StandardError)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'generic validation error' do
|
51
|
+
let(:status) { 400 }
|
52
|
+
let(:body) { '{"foo":["is bar"]}' }
|
53
|
+
|
54
|
+
it 'should return nil' do
|
55
|
+
expect { subject.user.create(first_name: 'Nathan') }.to raise_exception(TijuanaClient::ValidationError)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'email validation error' do
|
60
|
+
let(:status) { 400 }
|
61
|
+
let(:body) { '{"email":["is invalid"]}' }
|
62
|
+
|
45
63
|
it 'should return nil' do
|
46
|
-
|
64
|
+
expect { subject.user.create(first_name: 'Nathan') }.to raise_exception(TijuanaClient::EmailValidationError)
|
47
65
|
end
|
48
66
|
end
|
49
67
|
end
|
@@ -72,7 +90,7 @@ describe TijuanaClient::User do
|
|
72
90
|
let(:status) { 401 }
|
73
91
|
|
74
92
|
it "should return nil" do
|
75
|
-
|
93
|
+
expect { subject.user.create(first_name: 'Nathan') }.to raise_exception(StandardError)
|
76
94
|
end
|
77
95
|
end
|
78
96
|
end
|
data/tijuana_client.gemspec
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: tijuana_client 0.2.
|
5
|
+
# stub: tijuana_client 0.2.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "tijuana_client"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
12
13
|
s.authors = ["Nathan Woodhull"]
|
13
|
-
s.date = "
|
14
|
+
s.date = "2015-07-09"
|
14
15
|
s.description = "An API client for the code that runs Getup.org.au"
|
15
16
|
s.email = "nathan@controlshiftlabs.com"
|
16
17
|
s.extra_rdoc_files = [
|
@@ -20,6 +21,7 @@ Gem::Specification.new do |s|
|
|
20
21
|
s.files = [
|
21
22
|
".ruby-gemset",
|
22
23
|
".ruby-version",
|
24
|
+
".travis.yml",
|
23
25
|
"Gemfile",
|
24
26
|
"Gemfile.lock",
|
25
27
|
"LICENSE.txt",
|
@@ -29,6 +31,7 @@ Gem::Specification.new do |s|
|
|
29
31
|
"lib/tijuana_client.rb",
|
30
32
|
"lib/tijuana_client/base.rb",
|
31
33
|
"lib/tijuana_client/client.rb",
|
34
|
+
"lib/tijuana_client/error_middleware.rb",
|
32
35
|
"lib/tijuana_client/user.rb",
|
33
36
|
"spec/client_spec.rb",
|
34
37
|
"spec/spec_helper.rb",
|
@@ -38,8 +41,7 @@ Gem::Specification.new do |s|
|
|
38
41
|
]
|
39
42
|
s.homepage = "http://github.com/controlshift/tijuana_client"
|
40
43
|
s.licenses = ["MIT"]
|
41
|
-
s.
|
42
|
-
s.rubygems_version = "2.1.10"
|
44
|
+
s.rubygems_version = "2.4.6"
|
43
45
|
s.summary = "API client for Tijuana"
|
44
46
|
|
45
47
|
if s.respond_to? :specification_version then
|
@@ -50,26 +52,26 @@ Gem::Specification.new do |s|
|
|
50
52
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
51
53
|
s.add_development_dependency(%q<webmock>, [">= 0"])
|
52
54
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
53
|
-
s.add_development_dependency(%q<pry-
|
55
|
+
s.add_development_dependency(%q<pry-byebug>, [">= 0"])
|
54
56
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
55
|
-
s.add_development_dependency(%q<jeweler>, ["~>
|
57
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.0"])
|
56
58
|
else
|
57
59
|
s.add_dependency(%q<vertebrae>, [">= 0"])
|
58
60
|
s.add_dependency(%q<rspec>, [">= 0"])
|
59
61
|
s.add_dependency(%q<webmock>, [">= 0"])
|
60
62
|
s.add_dependency(%q<pry>, [">= 0"])
|
61
|
-
s.add_dependency(%q<pry-
|
63
|
+
s.add_dependency(%q<pry-byebug>, [">= 0"])
|
62
64
|
s.add_dependency(%q<bundler>, [">= 0"])
|
63
|
-
s.add_dependency(%q<jeweler>, ["~>
|
65
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
|
64
66
|
end
|
65
67
|
else
|
66
68
|
s.add_dependency(%q<vertebrae>, [">= 0"])
|
67
69
|
s.add_dependency(%q<rspec>, [">= 0"])
|
68
70
|
s.add_dependency(%q<webmock>, [">= 0"])
|
69
71
|
s.add_dependency(%q<pry>, [">= 0"])
|
70
|
-
s.add_dependency(%q<pry-
|
72
|
+
s.add_dependency(%q<pry-byebug>, [">= 0"])
|
71
73
|
s.add_dependency(%q<bundler>, [">= 0"])
|
72
|
-
s.add_dependency(%q<jeweler>, ["~>
|
74
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tijuana_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Woodhull
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vertebrae
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry-
|
70
|
+
name: pry-byebug
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '>='
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.0.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 2.0.0
|
111
111
|
description: An API client for the code that runs Getup.org.au
|
112
112
|
email: nathan@controlshiftlabs.com
|
113
113
|
executables: []
|
@@ -118,6 +118,7 @@ extra_rdoc_files:
|
|
118
118
|
files:
|
119
119
|
- .ruby-gemset
|
120
120
|
- .ruby-version
|
121
|
+
- .travis.yml
|
121
122
|
- Gemfile
|
122
123
|
- Gemfile.lock
|
123
124
|
- LICENSE.txt
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- lib/tijuana_client.rb
|
128
129
|
- lib/tijuana_client/base.rb
|
129
130
|
- lib/tijuana_client/client.rb
|
131
|
+
- lib/tijuana_client/error_middleware.rb
|
130
132
|
- lib/tijuana_client/user.rb
|
131
133
|
- spec/client_spec.rb
|
132
134
|
- spec/spec_helper.rb
|
@@ -153,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
155
|
version: '0'
|
154
156
|
requirements: []
|
155
157
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.4.6
|
157
159
|
signing_key:
|
158
160
|
specification_version: 4
|
159
161
|
summary: API client for Tijuana
|