greenhouse_io 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +86 -27
  4. data/lib/greenhouse_io.rb +3 -0
  5. data/lib/greenhouse_io/api.rb +8 -61
  6. data/lib/greenhouse_io/api/client.rb +88 -0
  7. data/lib/greenhouse_io/api/job_board.rb +66 -0
  8. data/lib/greenhouse_io/configuration.rb +21 -0
  9. data/lib/greenhouse_io/error.rb +3 -15
  10. data/lib/greenhouse_io/version.rb +1 -1
  11. data/spec/fixtures/cassettes/client/activity_feed.yml +36 -0
  12. data/spec/fixtures/cassettes/client/application.yml +36 -0
  13. data/spec/fixtures/cassettes/client/applications.yml +43 -0
  14. data/spec/fixtures/cassettes/client/candidate.yml +36 -0
  15. data/spec/fixtures/cassettes/client/candidates.yml +38 -0
  16. data/spec/fixtures/cassettes/client/department.yml +36 -0
  17. data/spec/fixtures/cassettes/client/departments.yml +38 -0
  18. data/spec/fixtures/cassettes/client/job.yml +37 -0
  19. data/spec/fixtures/cassettes/client/job_post.yml +49 -0
  20. data/spec/fixtures/cassettes/client/jobs.yml +39 -0
  21. data/spec/fixtures/cassettes/client/office.yml +36 -0
  22. data/spec/fixtures/cassettes/client/offices.yml +46 -0
  23. data/spec/fixtures/cassettes/client/scheduled_interviews.yml +38 -0
  24. data/spec/fixtures/cassettes/client/scorecards.yml +37 -0
  25. data/spec/fixtures/cassettes/client/source.yml +39 -0
  26. data/spec/fixtures/cassettes/client/sources.yml +37 -0
  27. data/spec/fixtures/cassettes/client/stages.yml +36 -0
  28. data/spec/fixtures/cassettes/client/user.yml +36 -0
  29. data/spec/fixtures/cassettes/client/users.yml +38 -0
  30. data/spec/fixtures/cassettes/invalid_id.yml +1 -1
  31. data/spec/fixtures/cassettes/job.yml +1 -1
  32. data/spec/greenhouse_io/api/client_spec.rb +474 -0
  33. data/spec/{greenhouse/api_spec.rb → greenhouse_io/api/job_board_spec.rb} +10 -9
  34. data/spec/greenhouse_io/configuration_spec.rb +71 -0
  35. data/spec/{greenhouse → greenhouse_io}/error_spec.rb +0 -2
  36. data/spec/spec_helper.rb +5 -0
  37. metadata +51 -6
@@ -1,15 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe GreenhouseIo::API do
3
+ describe GreenhouseIo::JobBoard do
4
4
 
5
5
  it "should have a base url for an API endpoint" do
6
- expect(GreenhouseIo::API.base_uri).to eq("https://api.greenhouse.io/v1")
6
+ expect(GreenhouseIo::JobBoard.base_uri).to eq("https://api.greenhouse.io/v1")
7
7
  end
8
8
 
9
- context "given a GreenhouseIo::API client" do
9
+ context "given an instance of GreenhouseIo::JobBoard" do
10
10
 
11
11
  before do
12
- @client = GreenhouseIo::API.new('123FakeToken', organization: 'generalassembly')
12
+ GreenhouseIo.configuration.symbolize_keys = true
13
+ @client = GreenhouseIo::JobBoard.new('123FakeToken', organization: 'generalassembly')
13
14
  end
14
15
 
15
16
  describe "#initialize" do
@@ -21,16 +22,16 @@ describe GreenhouseIo::API do
21
22
  expect(@client.organization).to eq('generalassembly')
22
23
  end
23
24
 
24
- it "uses an enviroment variable when token is not specified" do
25
- ENV['GREENHOUSE_API_TOKEN'] = '123FakeENV'
26
- default_client = GreenhouseIo::API.new
25
+ it "uses the configuration value when token is not specified" do
26
+ GreenhouseIo.configuration.api_token = '123FakeENV'
27
+ default_client = GreenhouseIo::JobBoard.new
27
28
  expect(default_client.api_token).to eq('123FakeENV')
28
29
  end
29
30
  end
30
31
 
31
32
  context "when an organization has not been set" do
32
33
  it "raises an 'organization can't be blank' error" do
33
- no_org_client = GreenhouseIo::API.new
34
+ no_org_client = GreenhouseIo::JobBoard.new
34
35
  expect{ no_org_client.offices }.to raise_error(GreenhouseIo::Error)
35
36
  end
36
37
  end
@@ -38,7 +39,7 @@ describe GreenhouseIo::API do
38
39
  context "when an invalid organization is used" do
39
40
  it "raises an HTTP Error" do
40
41
  VCR.use_cassette('invalid_organization') do
41
- invalid_org_client = GreenhouseIo::API.new(nil, organization: 'not-real-inc')
42
+ invalid_org_client = GreenhouseIo::JobBoard.new(nil, organization: 'not-real-inc')
42
43
  expect{ invalid_org_client.offices }.to raise_error(GreenhouseIo::Error)
43
44
  end
44
45
  end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe GreenhouseIo::Configuration do
4
+ after { restore_default_config }
5
+
6
+ context "when no symbolize_keys is specified" do
7
+ before do
8
+ restore_default_config
9
+ end
10
+
11
+ it "returns the default value" do
12
+ expect(GreenhouseIo.configuration.symbolize_keys).to be_false
13
+ end
14
+ end
15
+
16
+ context "when given a symbolize_keys value" do
17
+ before do
18
+ GreenhouseIo.configure do |config|
19
+ config.symbolize_keys = true
20
+ end
21
+ end
22
+
23
+ it "returns the specified value" do
24
+ expect(GreenhouseIo.configuration.symbolize_keys).to be_true
25
+ end
26
+ end
27
+
28
+ context "when no organization is specified" do
29
+ before do
30
+ restore_default_config
31
+ end
32
+
33
+ it "returns nil" do
34
+ expect(GreenhouseIo.configuration.organization).to be_nil
35
+ end
36
+ end
37
+
38
+ context "when given an organization" do
39
+ before do
40
+ GreenhouseIo.configure do |config|
41
+ config.organization = "General Assembly"
42
+ end
43
+ end
44
+
45
+ it "returns the specified value" do
46
+ expect(GreenhouseIo.configuration.organization).to eq("General Assembly")
47
+ end
48
+ end
49
+
50
+ context "when no api token is specified" do
51
+ before do
52
+ restore_default_config
53
+ end
54
+
55
+ it "returns nil" do
56
+ expect(GreenhouseIo.configuration.api_token).to be_nil
57
+ end
58
+ end
59
+
60
+ context "when given an api token" do
61
+ before do
62
+ GreenhouseIo.configure do |config|
63
+ config.api_token = '123FakeToken'
64
+ end
65
+ end
66
+
67
+ it "returns the specified value" do
68
+ expect(GreenhouseIo.configuration.api_token).to eq('123FakeToken')
69
+ end
70
+ end
71
+ end
@@ -8,7 +8,6 @@ describe GreenhouseIo::Error do
8
8
  it "creates an error with the code" do
9
9
  http_error = GreenhouseIo::Error.new(nil, 404)
10
10
  expect(http_error.code).to eq(404)
11
- expect(http_error.inspect).to eq("GreenhouseIo::Error: 404 response from server")
12
11
  end
13
12
  end
14
13
 
@@ -16,7 +15,6 @@ describe GreenhouseIo::Error do
16
15
  it "creates an error with a message" do
17
16
  gem_error = GreenhouseIo::Error.new("organization can't be blank", nil)
18
17
  expect(gem_error.message).to eq("organization can't be blank")
19
- expect(gem_error.inspect).to eq("GreenhouseIo::Error: organization can't be blank")
20
18
  end
21
19
  end
22
20
 
data/spec/spec_helper.rb CHANGED
@@ -14,3 +14,8 @@ VCR.configure do |config|
14
14
  config.cassette_library_dir = 'spec/fixtures/cassettes'
15
15
  config.hook_into :webmock
16
16
  end
17
+
18
+ def restore_default_config
19
+ GreenhouseIo.configuration = nil
20
+ GreenhouseIo.configure {}
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greenhouse_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Bautista
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httmultiparty
@@ -124,9 +124,31 @@ files:
124
124
  - greenhouse_io.gemspec
125
125
  - lib/greenhouse_io.rb
126
126
  - lib/greenhouse_io/api.rb
127
+ - lib/greenhouse_io/api/client.rb
128
+ - lib/greenhouse_io/api/job_board.rb
129
+ - lib/greenhouse_io/configuration.rb
127
130
  - lib/greenhouse_io/error.rb
128
131
  - lib/greenhouse_io/version.rb
129
132
  - spec/fixtures/cassettes/apply_to_job.yml
133
+ - spec/fixtures/cassettes/client/activity_feed.yml
134
+ - spec/fixtures/cassettes/client/application.yml
135
+ - spec/fixtures/cassettes/client/applications.yml
136
+ - spec/fixtures/cassettes/client/candidate.yml
137
+ - spec/fixtures/cassettes/client/candidates.yml
138
+ - spec/fixtures/cassettes/client/department.yml
139
+ - spec/fixtures/cassettes/client/departments.yml
140
+ - spec/fixtures/cassettes/client/job.yml
141
+ - spec/fixtures/cassettes/client/job_post.yml
142
+ - spec/fixtures/cassettes/client/jobs.yml
143
+ - spec/fixtures/cassettes/client/office.yml
144
+ - spec/fixtures/cassettes/client/offices.yml
145
+ - spec/fixtures/cassettes/client/scheduled_interviews.yml
146
+ - spec/fixtures/cassettes/client/scorecards.yml
147
+ - spec/fixtures/cassettes/client/source.yml
148
+ - spec/fixtures/cassettes/client/sources.yml
149
+ - spec/fixtures/cassettes/client/stages.yml
150
+ - spec/fixtures/cassettes/client/user.yml
151
+ - spec/fixtures/cassettes/client/users.yml
130
152
  - spec/fixtures/cassettes/department.yml
131
153
  - spec/fixtures/cassettes/departments.yml
132
154
  - spec/fixtures/cassettes/invalid_application.yml
@@ -139,8 +161,10 @@ files:
139
161
  - spec/fixtures/cassettes/jobs_with_content.yml
140
162
  - spec/fixtures/cassettes/office.yml
141
163
  - spec/fixtures/cassettes/offices.yml
142
- - spec/greenhouse/api_spec.rb
143
- - spec/greenhouse/error_spec.rb
164
+ - spec/greenhouse_io/api/client_spec.rb
165
+ - spec/greenhouse_io/api/job_board_spec.rb
166
+ - spec/greenhouse_io/configuration_spec.rb
167
+ - spec/greenhouse_io/error_spec.rb
144
168
  - spec/spec_helper.rb
145
169
  homepage:
146
170
  licenses:
@@ -168,6 +192,25 @@ specification_version: 4
168
192
  summary: A Ruby based wrapper for Greenhouse.io API
169
193
  test_files:
170
194
  - spec/fixtures/cassettes/apply_to_job.yml
195
+ - spec/fixtures/cassettes/client/activity_feed.yml
196
+ - spec/fixtures/cassettes/client/application.yml
197
+ - spec/fixtures/cassettes/client/applications.yml
198
+ - spec/fixtures/cassettes/client/candidate.yml
199
+ - spec/fixtures/cassettes/client/candidates.yml
200
+ - spec/fixtures/cassettes/client/department.yml
201
+ - spec/fixtures/cassettes/client/departments.yml
202
+ - spec/fixtures/cassettes/client/job.yml
203
+ - spec/fixtures/cassettes/client/job_post.yml
204
+ - spec/fixtures/cassettes/client/jobs.yml
205
+ - spec/fixtures/cassettes/client/office.yml
206
+ - spec/fixtures/cassettes/client/offices.yml
207
+ - spec/fixtures/cassettes/client/scheduled_interviews.yml
208
+ - spec/fixtures/cassettes/client/scorecards.yml
209
+ - spec/fixtures/cassettes/client/source.yml
210
+ - spec/fixtures/cassettes/client/sources.yml
211
+ - spec/fixtures/cassettes/client/stages.yml
212
+ - spec/fixtures/cassettes/client/user.yml
213
+ - spec/fixtures/cassettes/client/users.yml
171
214
  - spec/fixtures/cassettes/department.yml
172
215
  - spec/fixtures/cassettes/departments.yml
173
216
  - spec/fixtures/cassettes/invalid_application.yml
@@ -180,6 +223,8 @@ test_files:
180
223
  - spec/fixtures/cassettes/jobs_with_content.yml
181
224
  - spec/fixtures/cassettes/office.yml
182
225
  - spec/fixtures/cassettes/offices.yml
183
- - spec/greenhouse/api_spec.rb
184
- - spec/greenhouse/error_spec.rb
226
+ - spec/greenhouse_io/api/client_spec.rb
227
+ - spec/greenhouse_io/api/job_board_spec.rb
228
+ - spec/greenhouse_io/configuration_spec.rb
229
+ - spec/greenhouse_io/error_spec.rb
185
230
  - spec/spec_helper.rb