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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13d0097abbdb86d6c257a1fbe08cbed627d9db50
4
- data.tar.gz: b78b2a64cdccd464830d6f3ec9ed70d3357cd9a1
3
+ metadata.gz: 0bb1dbe9e00346de49536c7cb6e548426035d8e7
4
+ data.tar.gz: b4a29258b1a2c379990efbeca670a4d25624436d
5
5
  SHA512:
6
- metadata.gz: 20b76d3ecb99880560ba979d6a391e4982331214fa8f276b10b9dc13c0ab61304cdfd0690139ded24387f050266a2bb89ecc7090a46014f33148d0a1570b0d78
7
- data.tar.gz: a0b922b65db203e7f49886411dba1cdde897f887ef2c252b13b49479d0b59d2e0ce6573d3a192b77dd2be1a224c193cbfcf8924713b73c6c3e9ba949db430a68
6
+ metadata.gz: e0ff7de8a5e482d6a1ac1282d4879ef6e407ade651420f1c5835db7fa0b82a00d409bb359f734581b1338f0f0060693bf19381e97536461260fc7299749d271b
7
+ data.tar.gz: 873c81447a873554ed4aa30b2dbbcfce591e8c722bcd1cda2e2d964b83a875f8c0b0a90e5f887eef8b5810b6ed55b73f2f35f6374516dbec3d1cb8610aa5fa3f
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.0.0-p247
1
+ 2.0.0-p645
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.0.0"
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ group :development do
8
8
  gem "rspec"
9
9
  gem 'webmock'
10
10
  gem 'pry'
11
- gem 'pry-debugger'
11
+ gem 'pry-byebug'
12
12
  gem "bundler"
13
- gem "jeweler", "~> 1.8.4"
13
+ gem "jeweler", "~> 2.0.0"
14
14
  end
data/Gemfile.lock CHANGED
@@ -1,98 +1,100 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (4.0.0)
5
- i18n (~> 0.6, >= 0.6.4)
6
- minitest (~> 4.2)
7
- multi_json (~> 1.3)
8
- thread_safe (~> 0.1)
9
- tzinfo (~> 0.3.37)
10
- addressable (2.3.5)
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
- coderay (1.0.9)
14
- columnize (0.3.6)
15
- crack (0.4.0)
16
- safe_yaml (~> 0.9.0)
17
- debugger (1.6.1)
18
- columnize (>= 0.3.1)
19
- debugger-linecache (~> 1.2.0)
20
- debugger-ruby_core_source (~> 1.2.3)
21
- debugger-linecache (1.2.0)
22
- debugger-ruby_core_source (1.2.3)
23
- diff-lcs (1.2.4)
24
- faraday (0.8.8)
25
- multipart-post (~> 1.2.0)
26
- faraday_middleware (0.9.0)
27
- faraday (>= 0.7.4, < 0.9)
28
- git (1.2.5)
29
- github_api (0.10.1)
30
- addressable
31
- faraday (~> 0.8.1)
32
- hashie (>= 1.2)
33
- multi_json (~> 1.4)
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 (2.0.5)
37
- highline (1.6.19)
38
- httpauth (0.2.0)
39
- i18n (0.6.4)
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 (~> 1.0)
39
+ bundler (>= 1.0)
43
40
  git (>= 1.2.5)
44
- github_api (= 0.10.1)
41
+ github_api
45
42
  highline (>= 1.6.15)
46
- nokogiri (= 1.5.10)
43
+ nokogiri (>= 1.5.10)
47
44
  rake
48
45
  rdoc
49
- json (1.8.0)
50
- jwt (0.1.8)
51
- multi_json (>= 1.5)
52
- method_source (0.8.1)
53
- minitest (4.7.5)
54
- multi_json (1.7.7)
55
- multi_xml (0.5.4)
56
- multipart-post (1.2.0)
57
- nokogiri (1.5.10)
58
- oauth2 (0.9.2)
59
- faraday (~> 0.8)
60
- httpauth (~> 0.2)
61
- jwt (~> 0.1.4)
62
- multi_json (~> 1.0)
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.9.12.2)
66
- coderay (~> 1.0.5)
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-debugger (0.2.2)
70
- debugger (~> 1.3)
71
- pry (~> 0.9.10)
72
- rack (1.5.2)
73
- rake (10.1.0)
74
- rdoc (4.0.1)
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 (2.14.1)
77
- rspec-core (~> 2.14.0)
78
- rspec-expectations (~> 2.14.0)
79
- rspec-mocks (~> 2.14.0)
80
- rspec-core (2.14.2)
81
- rspec-expectations (2.14.0)
82
- diff-lcs (>= 1.1.3, < 2.0)
83
- rspec-mocks (2.14.1)
84
- safe_yaml (0.9.4)
85
- slop (3.4.5)
86
- thread_safe (0.1.2)
87
- atomic
88
- tzinfo (0.3.37)
89
- vertebrae (0.2.0)
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.13.0)
95
- addressable (>= 2.2.7)
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 (~> 1.8.4)
105
+ jeweler (~> 2.0.0)
104
106
  pry
105
- pry-debugger
107
+ pry-byebug
106
108
  rspec
107
109
  vertebrae
108
110
  webmock
111
+
112
+ BUNDLED WITH
113
+ 1.10.5
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- tijuana_client_
1
+ tijuana_client
2
2
  =========================
3
3
 
4
+ [![Build Status](https://travis-ci.org/controlshift/tijuana_client.svg)](https://travis-ci.org/controlshift/tijuana_client)
5
+
4
6
  An exceptionally simple client for Getup's Tijuana
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -1,4 +1,5 @@
1
1
  require 'vertebrae'
2
+ require 'tijuana_client/error_middleware'
2
3
  require 'tijuana_client/base'
3
4
  require 'tijuana_client/user'
4
5
  require 'tijuana_client/client'
@@ -48,7 +48,7 @@ module TijuanaClient
48
48
 
49
49
  builder.use Faraday::Response::Logger if ENV['DEBUG']
50
50
 
51
- builder.use Vertebrae::Response::RaiseError
51
+ builder.use TijuanaClient::ErrorMiddleware
52
52
  builder.adapter connection.configuration.adapter
53
53
  end
54
54
  end
@@ -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.should respond_to :user }
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.should eq 'login' }
13
- specify { config.password.should eq '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.color_enabled = true
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.should respond_to :user }
5
- specify { subject.new.should be_a(TijuanaClient::Client)}
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.should == 'test.com'
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.should_receive(:post_request).with('/foo', {'data' => JSON.generate({ first_name: 'Nathan'}) } )
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
- lambda { subject.user.create(first_name: 'Nathan') }.should raise_exception
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
- lambda { subject.user.create(first_name: 'Nathan') }.should raise_exception
93
+ expect { subject.user.create(first_name: 'Nathan') }.to raise_exception(StandardError)
76
94
  end
77
95
  end
78
96
  end
@@ -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.1 ruby lib
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.1"
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 = "2014-02-28"
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.require_paths = ["lib"]
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-debugger>, [">= 0"])
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>, ["~> 1.8.4"])
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-debugger>, [">= 0"])
63
+ s.add_dependency(%q<pry-byebug>, [">= 0"])
62
64
  s.add_dependency(%q<bundler>, [">= 0"])
63
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
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-debugger>, [">= 0"])
72
+ s.add_dependency(%q<pry-byebug>, [">= 0"])
71
73
  s.add_dependency(%q<bundler>, [">= 0"])
72
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
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.1
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: 2014-02-28 00:00:00.000000000 Z
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-debugger
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: 1.8.4
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: 1.8.4
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.1.10
158
+ rubygems_version: 2.4.6
157
159
  signing_key:
158
160
  specification_version: 4
159
161
  summary: API client for Tijuana