greenhouse_io 1.0.0

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.
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.greenhouse.io/v1/boards/generalassembly/embed/office?id=0
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Cache-Control:
16
+ - max-age=0, private, must-revalidate
17
+ Content-Type:
18
+ - text/html; charset=utf-8
19
+ Date:
20
+ - Mon, 16 Sep 2013 16:04:17 GMT
21
+ Etag:
22
+ - ! '"8cbe966f113629b0ab3e59aadf42ff0f"'
23
+ Status:
24
+ - 200 OK
25
+ Vary:
26
+ - Accept-Encoding
27
+ X-Request-Id:
28
+ - a15edfde1538bab59946b9a03f10c674
29
+ X-Runtime:
30
+ - '0.155822'
31
+ X-Ua-Compatible:
32
+ - IE=Edge,chrome=1
33
+ Content-Length:
34
+ - '521'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: US-ASCII
39
+ string: ! '{"id":0,"name":"No Office","departments":[{"id":187,"name":"Engineering","jobs":[]},{"id":188,"name":"Finance","jobs":[{"id":722,"title":"Finance
40
+ Analyst","updated_at":"2013-09-12T21:01:50Z","location":{"name":"New York"},"absolute_url":"http://boards.greenhouse.io/generalassembly/jobs/722"}]},{"id":0,"name":"No
41
+ Department","jobs":[{"id":721,"title":"Application developer","updated_at":"2013-09-12T21:01:50Z","location":{"name":"New
42
+ York, NY"},"absolute_url":"http://boards.greenhouse.io/generalassembly/jobs/721"}]}]}'
43
+ http_version:
44
+ recorded_at: Mon, 16 Sep 2013 16:04:22 GMT
45
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.greenhouse.io/v1/boards/generalassembly/embed/offices
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Cache-Control:
16
+ - max-age=0, private, must-revalidate
17
+ Content-Type:
18
+ - text/html; charset=utf-8
19
+ Date:
20
+ - Mon, 16 Sep 2013 16:04:17 GMT
21
+ Etag:
22
+ - ! '"80777909660bca19af3cbefaa6840719"'
23
+ Status:
24
+ - 200 OK
25
+ Vary:
26
+ - Accept-Encoding
27
+ X-Request-Id:
28
+ - 01860b0b55d4de4c1de3efff5ea66d4b
29
+ X-Runtime:
30
+ - '0.009176'
31
+ X-Ua-Compatible:
32
+ - IE=Edge,chrome=1
33
+ Content-Length:
34
+ - '535'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: US-ASCII
39
+ string: ! '{"offices":[{"id":0,"name":"No Office","departments":[{"id":187,"name":"Engineering","jobs":[]},{"id":188,"name":"Finance","jobs":[{"id":722,"title":"Finance
40
+ Analyst","updated_at":"2013-09-12T21:01:50Z","location":{"name":"New York"},"absolute_url":"http://boards.greenhouse.io/generalassembly/jobs/722"}]},{"id":0,"name":"No
41
+ Department","jobs":[{"id":721,"title":"Application developer","updated_at":"2013-09-12T21:01:50Z","location":{"name":"New
42
+ York, NY"},"absolute_url":"http://boards.greenhouse.io/generalassembly/jobs/721"}]}]}]}'
43
+ http_version:
44
+ recorded_at: Mon, 16 Sep 2013 16:04:21 GMT
45
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,186 @@
1
+ require 'spec_helper'
2
+
3
+ describe GreenhouseIo::API do
4
+
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")
7
+ end
8
+
9
+ context "given a GreenhouseIo::API client" do
10
+
11
+ before do
12
+ @client = GreenhouseIo::API.new('123FakeToken', organization: 'generalassembly')
13
+ end
14
+
15
+ describe "#initialize" do
16
+ it "has an api_token" do
17
+ expect(@client.api_token).to eq('123FakeToken')
18
+ end
19
+
20
+ it "has an organization" do
21
+ expect(@client.organization).to eq('generalassembly')
22
+ end
23
+
24
+ it "uses an enviroment variable when token is not specified" do
25
+ ENV['GREENHOUSE_API_TOKEN'] = '123FakeENV'
26
+ default_client = GreenhouseIo::API.new
27
+ expect(default_client.api_token).to eq('123FakeENV')
28
+ end
29
+ end
30
+
31
+ context "when an organization has not been set" do
32
+ it "raises an 'organization can't be blank' error" do
33
+ no_org_client = GreenhouseIo::API.new
34
+ expect{ no_org_client.offices }.to raise_error(GreenhouseIo::Error)
35
+ end
36
+ end
37
+
38
+ context "when an invalid organization is used" do
39
+ it "raises an HTTP Error" do
40
+ VCR.use_cassette('invalid_organization') do
41
+ invalid_org_client = GreenhouseIo::API.new(nil, organization: 'not-real-inc')
42
+ expect{ invalid_org_client.offices }.to raise_error(GreenhouseIo::Error)
43
+ end
44
+ end
45
+ end
46
+
47
+ context "when an invalid id is used" do
48
+ it "raises an HTTP Error" do
49
+ VCR.use_cassette('invalid_id') do
50
+ expect{ @client.job(123) }.to raise_error(GreenhouseIo::Error)
51
+ end
52
+ end
53
+ end
54
+
55
+ describe "#offices" do
56
+ it "grabs the latest jobs and departments for an organization by each office" do
57
+ VCR.use_cassette('offices') do
58
+ offices_hash_response = @client.offices
59
+ expect(offices_hash_response).to_not be_nil
60
+ expect(offices_hash_response[:offices]).to be_an_instance_of(Array)
61
+ end
62
+ end
63
+ end
64
+
65
+ describe "#office" do
66
+ it "grabs the latest jobs and deparments for a specific office" do
67
+ VCR.use_cassette('office') do
68
+ office_hash_response = @client.office(0)
69
+ expect(office_hash_response).to_not be_nil
70
+ expect(office_hash_response).to include(:id => 0)
71
+ expect(office_hash_response).to include(:name => 'No Office')
72
+ expect(office_hash_response[:departments]).to be_an_instance_of(Array)
73
+ end
74
+ end
75
+ end
76
+
77
+ describe "#departments" do
78
+ it "returns a list of an organization's departments and jobs" do
79
+ VCR.use_cassette('departments') do
80
+ departments_hash_response = @client.departments
81
+ expect(departments_hash_response).to_not be_nil
82
+ expect(departments_hash_response[:departments]).to be_an_instance_of(Array)
83
+ end
84
+ end
85
+ end
86
+
87
+ describe "#department" do
88
+ it "returns a list of jobs for a specific department" do
89
+ VCR.use_cassette('department') do
90
+ department_hash_response = @client.department(187)
91
+ expect(department_hash_response).to_not be_nil
92
+ expect(department_hash_response).to include(:id => 187)
93
+ expect(department_hash_response).to include(:name => 'Engineering')
94
+ expect(department_hash_response[:jobs]).to be_an_instance_of(Array)
95
+ end
96
+ end
97
+ end
98
+
99
+ describe "#jobs" do
100
+ it "returns the list of all jobs" do
101
+ VCR.use_cassette('jobs') do
102
+ jobs_hash_response = @client.jobs
103
+ expect(jobs_hash_response).to_not be_nil
104
+ expect(jobs_hash_response[:jobs]).to be_an_instance_of(Array)
105
+ end
106
+ end
107
+
108
+ it "returns a list of jobs and their job descriptions" do
109
+ VCR.use_cassette('jobs_with_content') do
110
+ jobs_description_hash_response = @client.jobs(:content => true)
111
+ expect(jobs_description_hash_response).to_not be_nil
112
+ expect(jobs_description_hash_response[:jobs]).to be_an_instance_of(Array)
113
+ expect(jobs_description_hash_response[:jobs].first).to include(:content)
114
+ end
115
+ end
116
+ end
117
+
118
+ describe "#job" do
119
+ it "returns the details for a specific job by ID" do
120
+ VCR.use_cassette('job') do
121
+ job_hash_response = @client.job(721)
122
+ expect(job_hash_response).to_not be_nil
123
+ expect(job_hash_response).to include(:id => 721)
124
+ expect(job_hash_response).to include(:content)
125
+ end
126
+ end
127
+
128
+ it "returns the details for a specific job and its application questions" do
129
+ VCR.use_cassette('job_with_questions') do
130
+ job_with_questions_hash_response = @client.job(721, :questions => true)
131
+ expect(job_with_questions_hash_response).to_not be_nil
132
+ expect(job_with_questions_hash_response).to include(:id => 721)
133
+ expect(job_with_questions_hash_response).to include(:content)
134
+ expect(job_with_questions_hash_response[:questions]).to be_an_instance_of(Array)
135
+ end
136
+ end
137
+ end
138
+
139
+ describe "#apply_to_job" do
140
+ it "posts an application to a specified job" do
141
+ VCR.use_cassette('apply_to_job') do
142
+ apply_to_job = @client.apply_to_job(
143
+ {
144
+ :id => 721,
145
+ :first_name => 'Richard',
146
+ :last_name => 'Feynman',
147
+ :email => 'richard123@test.ga.co'
148
+ }
149
+ )
150
+ expect(apply_to_job).to_not be_nil
151
+ expect(apply_to_job).to include(:success => 'Candidate saved successfully')
152
+ end
153
+ end
154
+
155
+ it "errors when missing required fields" do
156
+ VCR.use_cassette('invalid_application') do
157
+ expect {
158
+ @client.apply_to_job(
159
+ {
160
+ :id => 721,
161
+ :question_2720 => 'not_required'
162
+ }
163
+ )
164
+ }.to raise_error(GreenhouseIo::Error)
165
+ end
166
+ end
167
+
168
+ it "errors when given an invalid ID" do
169
+ VCR.use_cassette('invalid_application_id') do
170
+ expect {
171
+ @client.apply_to_job(
172
+ {
173
+ :id => 456,
174
+ :first_name => 'Gob',
175
+ :last_name => 'Bluth',
176
+ :email => 'gob@bluth.com'
177
+ }
178
+ )
179
+ }.to raise_error(GreenhouseIo::Error)
180
+ end
181
+ end
182
+ end
183
+
184
+ end
185
+
186
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe GreenhouseIo::Error do
4
+
5
+ describe "#inspect" do
6
+
7
+ context "when http error code is present" do
8
+ it "creates an error with the code" do
9
+ http_error = GreenhouseIo::Error.new(nil, 404)
10
+ expect(http_error.code).to eq(404)
11
+ expect(http_error.inspect).to eq("GreenhouseIo::Error: 404 response from server")
12
+ end
13
+ end
14
+
15
+ context "when its an internal gem error" do
16
+ it "creates an error with a message" do
17
+ gem_error = GreenhouseIo::Error.new("organization can't be blank", nil)
18
+ 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
+ end
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'webmock/rspec'
4
+ require 'vcr'
5
+ require 'greenhouse_io'
6
+
7
+ require 'coveralls'
8
+ Coveralls.wear!
9
+
10
+ RSpec.configure do |config|
11
+ end
12
+
13
+ VCR.configure do |config|
14
+ config.cassette_library_dir = 'spec/fixtures/cassettes'
15
+ config.hook_into :webmock
16
+ end
metadata ADDED
@@ -0,0 +1,207 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: greenhouse_io
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adrian Bautista
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.8.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.8.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 2.14.1
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.14.1
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.8.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.8.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: vcr
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 2.5.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 2.5.0
126
+ description: A Ruby based wrapper for Greenhouse.io API
127
+ email:
128
+ - adrianbautista8@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .travis.yml
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - greenhouse_io.gemspec
140
+ - lib/greenhouse_io.rb
141
+ - lib/greenhouse_io/api.rb
142
+ - lib/greenhouse_io/error.rb
143
+ - lib/greenhouse_io/version.rb
144
+ - spec/fixtures/cassettes/apply_to_job.yml
145
+ - spec/fixtures/cassettes/department.yml
146
+ - spec/fixtures/cassettes/departments.yml
147
+ - spec/fixtures/cassettes/invalid_application.yml
148
+ - spec/fixtures/cassettes/invalid_application_id.yml
149
+ - spec/fixtures/cassettes/invalid_id.yml
150
+ - spec/fixtures/cassettes/invalid_organization.yml
151
+ - spec/fixtures/cassettes/job.yml
152
+ - spec/fixtures/cassettes/job_with_questions.yml
153
+ - spec/fixtures/cassettes/jobs.yml
154
+ - spec/fixtures/cassettes/jobs_with_content.yml
155
+ - spec/fixtures/cassettes/office.yml
156
+ - spec/fixtures/cassettes/offices.yml
157
+ - spec/greenhouse/api_spec.rb
158
+ - spec/greenhouse/error_spec.rb
159
+ - spec/spec_helper.rb
160
+ homepage:
161
+ licenses:
162
+ - MIT
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ none: false
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ segments:
174
+ - 0
175
+ hash: -4105880940564324566
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ segments:
183
+ - 0
184
+ hash: -4105880940564324566
185
+ requirements: []
186
+ rubyforge_project:
187
+ rubygems_version: 1.8.25
188
+ signing_key:
189
+ specification_version: 3
190
+ summary: A Ruby based wrapper for Greenhouse.io API
191
+ test_files:
192
+ - spec/fixtures/cassettes/apply_to_job.yml
193
+ - spec/fixtures/cassettes/department.yml
194
+ - spec/fixtures/cassettes/departments.yml
195
+ - spec/fixtures/cassettes/invalid_application.yml
196
+ - spec/fixtures/cassettes/invalid_application_id.yml
197
+ - spec/fixtures/cassettes/invalid_id.yml
198
+ - spec/fixtures/cassettes/invalid_organization.yml
199
+ - spec/fixtures/cassettes/job.yml
200
+ - spec/fixtures/cassettes/job_with_questions.yml
201
+ - spec/fixtures/cassettes/jobs.yml
202
+ - spec/fixtures/cassettes/jobs_with_content.yml
203
+ - spec/fixtures/cassettes/office.yml
204
+ - spec/fixtures/cassettes/offices.yml
205
+ - spec/greenhouse/api_spec.rb
206
+ - spec/greenhouse/error_spec.rb
207
+ - spec/spec_helper.rb