workable 1.0.0 → 2.0.0rc1
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/CHANGELOG.md +15 -0
- data/Gemfile +1 -1
- data/Guardfile +3 -3
- data/README.md +5 -6
- data/Rakefile +3 -2
- data/lib/workable.rb +7 -4
- data/lib/workable/client.rb +106 -91
- data/lib/workable/collection.rb +29 -0
- data/lib/workable/errors.rb +6 -6
- data/lib/workable/transformation.rb +26 -0
- data/lib/workable/version.rb +1 -1
- data/spec/fixtures.rb +34 -122
- data/spec/fixtures/about.json +8 -0
- data/spec/fixtures/job.json +31 -0
- data/spec/fixtures/job_candidate.json +119 -0
- data/spec/fixtures/job_candidates.json +58 -0
- data/spec/fixtures/job_questions.json +34 -0
- data/spec/fixtures/jobs.json +73 -0
- data/spec/fixtures/members.json +32 -0
- data/spec/fixtures/new_candidate.json +60 -0
- data/spec/fixtures/new_candidate_response.json +109 -0
- data/spec/fixtures/recruiters.json +14 -0
- data/spec/fixtures/stages.json +40 -0
- data/spec/lib/workable/client_spec.rb +157 -121
- data/spec/lib/workable/collection_spec.rb +49 -0
- data/spec/lib/workable/transformation_spec.rb +38 -0
- data/spec/spec_helper.rb +6 -1
- data/workable.gemspec +7 -7
- metadata +32 -4
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Workable::Collection do
|
4
|
+
describe 'delegation' do
|
5
|
+
let(:collection){ described_class.new([1, 2, 3], double, :job, 'jobs') }
|
6
|
+
|
7
|
+
it 'delegates size to `data`' do
|
8
|
+
expect(collection.size).to eq(3)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'delegates each to `data`' do
|
12
|
+
expect(collection.each).to be_kind_of(Enumerator)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'delegates [] to `data`' do
|
16
|
+
expect(collection[1]).to eq(2)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'delegates .first to `data`' do
|
20
|
+
expect(collection.first).to eq (1)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'delegates map to `data`' do
|
24
|
+
expect(collection.map { |q| q*2 }).to eq([2, 4, 6])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#fetch_next_page' do
|
29
|
+
let(:next_method){ double }
|
30
|
+
let(:collection){ described_class.new([], next_method, :job, 'jobs', paging) }
|
31
|
+
|
32
|
+
context 'when next page is available' do
|
33
|
+
let(:paging){ { 'next' => 'http://example.com?limit=2&since_id=3' } }
|
34
|
+
|
35
|
+
it 'executes next_method with next page url' do
|
36
|
+
expect(next_method).to receive(:call).with('http://example.com?limit=2&since_id=3', :job, 'jobs')
|
37
|
+
collection.fetch_next_page
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when next page is not available' do
|
42
|
+
let(:paging){ nil }
|
43
|
+
|
44
|
+
it 'does nothing' do
|
45
|
+
expect(collection.fetch_next_page).to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Workable::Transformation do
|
4
|
+
let(:client) do
|
5
|
+
described_class.new(
|
6
|
+
candidate: OpenStruct.method(:new)
|
7
|
+
)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'transforming candidate' do
|
11
|
+
it 'transforms candidate' do
|
12
|
+
result = client.apply(:candidate, name: 'Tom')
|
13
|
+
expect(result).to be_kind_of(OpenStruct)
|
14
|
+
expect(result.name).to eq('Tom')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'transforming many candidates' do
|
19
|
+
it 'transforms many' do
|
20
|
+
result = client.apply(:candidate, [{ name: 'Tom' }, { name: 'Alice' }])
|
21
|
+
expect(result).to be_kind_of(Array)
|
22
|
+
expect(result.map(&:class)).to eq([OpenStruct, OpenStruct])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'transforming nil' do
|
27
|
+
it 'does not transform nil' do
|
28
|
+
expect(client.apply(:candidate, nil)).to eq(nil)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'no transformation' do
|
33
|
+
it 'does not transform without transformation' do
|
34
|
+
data = client.apply(:stage, slug: 'sourced')
|
35
|
+
expect(data).to eq(slug: 'sourced')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/workable.gemspec
CHANGED
@@ -4,18 +4,18 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'workable/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'workable'
|
8
8
|
spec.version = Workable::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.homepage =
|
12
|
-
spec.license =
|
13
|
-
spec.summary = spec.description =
|
9
|
+
spec.authors = ['Rafał Wojsznis', 'Michal Papis']
|
10
|
+
spec.email = ['rafal.wojsznis@gmail.com', 'mpapis@gmail.com']
|
11
|
+
spec.homepage = 'https://github.com/emq/workable'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.summary = spec.description = 'Dead-simple Ruby API client for workable.com'
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.required_ruby_version = '>= 1.9.3'
|
21
21
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Wojsznis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -114,10 +114,25 @@ files:
|
|
114
114
|
- Rakefile
|
115
115
|
- lib/workable.rb
|
116
116
|
- lib/workable/client.rb
|
117
|
+
- lib/workable/collection.rb
|
117
118
|
- lib/workable/errors.rb
|
119
|
+
- lib/workable/transformation.rb
|
118
120
|
- lib/workable/version.rb
|
119
121
|
- spec/fixtures.rb
|
122
|
+
- spec/fixtures/about.json
|
123
|
+
- spec/fixtures/job.json
|
124
|
+
- spec/fixtures/job_candidate.json
|
125
|
+
- spec/fixtures/job_candidates.json
|
126
|
+
- spec/fixtures/job_questions.json
|
127
|
+
- spec/fixtures/jobs.json
|
128
|
+
- spec/fixtures/members.json
|
129
|
+
- spec/fixtures/new_candidate.json
|
130
|
+
- spec/fixtures/new_candidate_response.json
|
131
|
+
- spec/fixtures/recruiters.json
|
132
|
+
- spec/fixtures/stages.json
|
120
133
|
- spec/lib/workable/client_spec.rb
|
134
|
+
- spec/lib/workable/collection_spec.rb
|
135
|
+
- spec/lib/workable/transformation_spec.rb
|
121
136
|
- spec/spec_helper.rb
|
122
137
|
- workable.gemspec
|
123
138
|
homepage: https://github.com/emq/workable
|
@@ -135,9 +150,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
150
|
version: 1.9.3
|
136
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
152
|
requirements:
|
138
|
-
- - "
|
153
|
+
- - ">"
|
139
154
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
155
|
+
version: 1.3.1
|
141
156
|
requirements: []
|
142
157
|
rubyforge_project:
|
143
158
|
rubygems_version: 2.4.6
|
@@ -146,5 +161,18 @@ specification_version: 4
|
|
146
161
|
summary: Dead-simple Ruby API client for workable.com
|
147
162
|
test_files:
|
148
163
|
- spec/fixtures.rb
|
164
|
+
- spec/fixtures/about.json
|
165
|
+
- spec/fixtures/job.json
|
166
|
+
- spec/fixtures/job_candidate.json
|
167
|
+
- spec/fixtures/job_candidates.json
|
168
|
+
- spec/fixtures/job_questions.json
|
169
|
+
- spec/fixtures/jobs.json
|
170
|
+
- spec/fixtures/members.json
|
171
|
+
- spec/fixtures/new_candidate.json
|
172
|
+
- spec/fixtures/new_candidate_response.json
|
173
|
+
- spec/fixtures/recruiters.json
|
174
|
+
- spec/fixtures/stages.json
|
149
175
|
- spec/lib/workable/client_spec.rb
|
176
|
+
- spec/lib/workable/collection_spec.rb
|
177
|
+
- spec/lib/workable/transformation_spec.rb
|
150
178
|
- spec/spec_helper.rb
|