hawatel_search_jobs 0.1.3 → 0.2.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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -18
- data/.gitignore +11 -11
- data/.rspec +2 -2
- data/.rubocop.yml +1169 -1169
- data/.travis.yml +6 -6
- data/CODE_OF_CONDUCT.md +13 -13
- data/CONTRIBUTING.md +69 -69
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +12 -7
- data/Rakefile +6 -6
- data/hawatel_search_jobs.gemspec +32 -32
- data/lib/hawatel_search_jobs.rb +64 -64
- data/lib/hawatel_search_jobs/api.rb +9 -9
- data/lib/hawatel_search_jobs/api/careerbuilder.rb +172 -169
- data/lib/hawatel_search_jobs/api/careerjet.rb +131 -126
- data/lib/hawatel_search_jobs/api/indeed.rb +166 -157
- data/lib/hawatel_search_jobs/api/reed.rb +189 -185
- data/lib/hawatel_search_jobs/api/xing.rb +16 -6
- data/lib/hawatel_search_jobs/client.rb +170 -172
- data/lib/hawatel_search_jobs/version.rb +1 -1
- data/spec/careerbuilder_spec.rb +142 -82
- data/spec/careerjet_spec.rb +97 -58
- data/spec/client_spec.rb +75 -87
- data/spec/indeed_spec.rb +97 -59
- data/spec/reed_spec.rb +93 -77
- data/spec/spec_helper.rb +2 -2
- data/spec/xing_spec.rb +66 -46
- metadata +2 -2
@@ -11,6 +11,8 @@ module HawatelSearchJobs::Api
|
|
11
11
|
:company => ''
|
12
12
|
}
|
13
13
|
|
14
|
+
RESULT_LIMIT = 25
|
15
|
+
|
14
16
|
# @see https://github.com/xing/xing_api
|
15
17
|
# Search jobs based on specified keywords
|
16
18
|
#
|
@@ -30,9 +32,13 @@ module HawatelSearchJobs::Api
|
|
30
32
|
def search(args)
|
31
33
|
args[:query] = DEFAULT.merge(args[:query]) if args[:query]
|
32
34
|
keywords = args[:query][:keywords]
|
33
|
-
|
35
|
+
page_size = args[:settings][:page_size].to_s.empty? ? RESULT_LIMIT : args[:settings][:page_size].to_i
|
36
|
+
page_size = RESULT_LIMIT if page_size <= 0 || page_size > 100
|
37
|
+
|
38
|
+
result = send_request({:keywords => keywords, :offset => 0, :settings => args[:settings], :page_size => page_size})
|
39
|
+
|
34
40
|
if !result[:code]
|
35
|
-
set_attributes({:result => result, :page => 0, :keywords => keywords})
|
41
|
+
set_attributes({:result => result, :page => 0, :keywords => keywords, :page_size => page_size})
|
36
42
|
else
|
37
43
|
OpenStruct.new({:code => 501, :msg => 'incorrect settings'})
|
38
44
|
end
|
@@ -50,8 +56,11 @@ module HawatelSearchJobs::Api
|
|
50
56
|
# @return [Hash<OpenStruct>]
|
51
57
|
def page(args)
|
52
58
|
args[:page] = 0 if args[:page].nil?
|
53
|
-
|
54
|
-
|
59
|
+
page_size = args[:settings][:page_size].to_s.empty? ? RESULT_LIMIT : args[:settings][:page_size].to_i
|
60
|
+
page_size = RESULT_LIMIT if page_size <= 0 || page_size > 100
|
61
|
+
|
62
|
+
result = XingApi::Job.search(args[:query_key], {:limit => page_size, :offset => args[:page]*page_size})
|
63
|
+
set_attributes({:result => result, :page => args[:page], :keywords => args[:query_key], :page_size => page_size})
|
55
64
|
rescue XingApi::Error => e
|
56
65
|
{:code => e.status_code, :msg => e.text}
|
57
66
|
end
|
@@ -66,7 +75,8 @@ module HawatelSearchJobs::Api
|
|
66
75
|
# @return [Hash<OpenStruct>]
|
67
76
|
def send_request(args)
|
68
77
|
set_settings(args[:settings])
|
69
|
-
|
78
|
+
|
79
|
+
XingApi::Job.search(args[:keywords], {:limit => args[:page_size], :offset => 0})
|
70
80
|
rescue XingApi::Error => e
|
71
81
|
{:code => e.status_code, :msg => e.text}
|
72
82
|
end
|
@@ -79,7 +89,7 @@ module HawatelSearchJobs::Api
|
|
79
89
|
attributes[:code] = '200'
|
80
90
|
attributes[:msg] = "OK"
|
81
91
|
attributes[:page] = args[:page]
|
82
|
-
attributes[:last] = args[:result][:jobs][:total] /
|
92
|
+
attributes[:last] = args[:result][:jobs][:total] / args[:page_size]
|
83
93
|
attributes[:key] = args[:keywords]
|
84
94
|
attributes[:jobs] = parse_raw_data(args[:result])
|
85
95
|
OpenStruct.new(attributes)
|
@@ -1,172 +1,170 @@
|
|
1
|
-
module HawatelSearchJobs
|
2
|
-
##
|
3
|
-
# = Client for a jobs search engine
|
4
|
-
#
|
5
|
-
# @!attribute [rw] indeed
|
6
|
-
# @return [Hash] settings of API
|
7
|
-
# @!attribute [rw] xing
|
8
|
-
# @return [Hash] settings of API
|
9
|
-
# @!attribute [rw] reed
|
10
|
-
# @return [Hash] settings of API
|
11
|
-
# @!attribute [rw] careerbuilder
|
12
|
-
# @return [Hash] settings of API
|
13
|
-
# @!attribute [rw] careerjet
|
14
|
-
# @return [Hash] settings of API
|
15
|
-
class Client
|
16
|
-
include HawatelSearchJobs::Api
|
17
|
-
|
18
|
-
# Values have to be the same name like module name of usesd APIs (HawatelSearchJobs::Api::[ApiName])
|
19
|
-
APIS = ['Indeed', 'Xing', 'Reed', 'Careerbuilder', 'CareerJet']
|
20
|
-
|
21
|
-
attr_reader :jobs_table
|
22
|
-
|
23
|
-
DEFAULT = {
|
24
|
-
:keywords => '',
|
25
|
-
:location => '',
|
26
|
-
:company => '',
|
27
|
-
}
|
28
|
-
|
29
|
-
def initialize
|
30
|
-
APIS.each do |api|
|
31
|
-
metaclasses.send(:attr_reader, api.downcase.to_sym)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
# config.
|
55
|
-
# config.
|
56
|
-
# config.
|
57
|
-
# config.
|
58
|
-
#
|
59
|
-
#
|
60
|
-
# config.
|
61
|
-
# config.
|
62
|
-
# config.
|
63
|
-
# config.
|
64
|
-
#
|
65
|
-
#
|
66
|
-
# config.
|
67
|
-
# config.
|
68
|
-
# config.
|
69
|
-
#
|
70
|
-
# config.careerbuilder[:
|
71
|
-
#
|
72
|
-
# config.
|
73
|
-
# config.
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
# client.
|
81
|
-
#
|
82
|
-
# p client.jobs_table[:
|
83
|
-
# p client.jobs_table[:
|
84
|
-
# p client.jobs_table[:
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
#
|
130
|
-
#
|
131
|
-
# @
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
end
|
172
|
-
|
1
|
+
module HawatelSearchJobs
|
2
|
+
##
|
3
|
+
# = Client for a jobs search engine
|
4
|
+
#
|
5
|
+
# @!attribute [rw] indeed
|
6
|
+
# @return [Hash] settings of API
|
7
|
+
# @!attribute [rw] xing
|
8
|
+
# @return [Hash] settings of API
|
9
|
+
# @!attribute [rw] reed
|
10
|
+
# @return [Hash] settings of API
|
11
|
+
# @!attribute [rw] careerbuilder
|
12
|
+
# @return [Hash] settings of API
|
13
|
+
# @!attribute [rw] careerjet
|
14
|
+
# @return [Hash] settings of API
|
15
|
+
class Client
|
16
|
+
include HawatelSearchJobs::Api
|
17
|
+
|
18
|
+
# Values have to be the same name like module name of usesd APIs (HawatelSearchJobs::Api::[ApiName])
|
19
|
+
APIS = ['Indeed', 'Xing', 'Reed', 'Careerbuilder', 'CareerJet']
|
20
|
+
|
21
|
+
attr_reader :jobs_table
|
22
|
+
|
23
|
+
DEFAULT = {
|
24
|
+
:keywords => '',
|
25
|
+
:location => '',
|
26
|
+
:company => '',
|
27
|
+
}
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
APIS.each do |api|
|
31
|
+
metaclasses.send(:attr_reader, api.downcase.to_sym)
|
32
|
+
instance_variable_set("@#{api.downcase}", HawatelSearchJobs.instance_variable_get("@"+api.downcase))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def metaclasses
|
37
|
+
class << self; self; end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Search Jobs by specific criteria
|
41
|
+
# @param query [Hash]
|
42
|
+
# @option query [String] :keywords
|
43
|
+
# @option query [String] :location not working in Xing API
|
44
|
+
# @option query [String] :company not working in Reed API
|
45
|
+
# @example
|
46
|
+
# HawatelSearchJobs.configure do |config|
|
47
|
+
# config.indeed[:activated] = true
|
48
|
+
# config.indeed[:api] = 'api.indeed.com'
|
49
|
+
# config.indeed[:version] = '2'
|
50
|
+
# config.indeed[:publisher] = 'secret-key'
|
51
|
+
# config.indeed[:page_size] = 25 # allowed range <1,25>
|
52
|
+
#
|
53
|
+
# config.xing[:activated] = true
|
54
|
+
# config.xing[:consumer_key] = 'secret-key'
|
55
|
+
# config.xing[:consumer_secret] = 'secret-key'
|
56
|
+
# config.xing[:oauth_token] = 'secret-key'
|
57
|
+
# config.xing[:oauth_token_secret] = 'secret-key'
|
58
|
+
# config.xing[:page_size] = 25 # allowed range <1,100>
|
59
|
+
#
|
60
|
+
# config.reed[:activated] = true
|
61
|
+
# config.reed[:api] = 'reed.co.uk/api'
|
62
|
+
# config.reed[:clientid] = 'secret-key'
|
63
|
+
# config.reed[:version] = '1.0'
|
64
|
+
# config.reed[:page_size] = 25 # allowed range <1,100>
|
65
|
+
#
|
66
|
+
# config.careerbuilder[:activated] = true
|
67
|
+
# config.careerbuilder[:api] = 'api.careerbuilder.com'
|
68
|
+
# config.careerbuilder[:clientid] = 'secret-key'
|
69
|
+
# config.careerbuilder[:version] = 'v2'
|
70
|
+
# config.careerbuilder[:page_size] = 25 # allowed range <1,100>
|
71
|
+
#
|
72
|
+
# config.careerjet[:activated] = true
|
73
|
+
# config.careerjet[:api] = 'public.api.careerjet.net'
|
74
|
+
# config.careerjet[:page_size] = 25 # allowed range <1,99>
|
75
|
+
# end
|
76
|
+
#
|
77
|
+
# client = HawatelSearchJobs::Client.new
|
78
|
+
# client.search_jobs({:keywords => 'ruby'})
|
79
|
+
#
|
80
|
+
# p client.jobs_table[:indeed]
|
81
|
+
# p client.jobs_table[:xing]
|
82
|
+
# p client.jobs_table[:reed]
|
83
|
+
# p client.jobs_table[:careerbuilder]
|
84
|
+
# p client.jobs_table[:careerjet]
|
85
|
+
#
|
86
|
+
# client.next
|
87
|
+
# @return [Hash] First page of result for all providers (default maximum 25 records for each page)
|
88
|
+
def search_jobs(query = {})
|
89
|
+
query = DEFAULT.merge(query)
|
90
|
+
|
91
|
+
@jobs_table = Hash.new
|
92
|
+
|
93
|
+
APIS.each do |api|
|
94
|
+
api_module_name = Object.const_get('HawatelSearchJobs').const_get('Api').const_get(api)
|
95
|
+
api_inst_var = instance_variable_get("@"+api.downcase)
|
96
|
+
@jobs_table[api.downcase.to_sym] = api_module_name.search({:settings => api_inst_var, :query => query}) if api_inst_var[:activated]
|
97
|
+
end
|
98
|
+
|
99
|
+
@jobs_table
|
100
|
+
end
|
101
|
+
|
102
|
+
# Get next page of result
|
103
|
+
# @example
|
104
|
+
# p client.next
|
105
|
+
# p client.jobs_table
|
106
|
+
# @return [Hash] Next page of result for all providers (default maximum 25 records for each)
|
107
|
+
def next
|
108
|
+
next_result = Hash.new
|
109
|
+
APIS.each do |api|
|
110
|
+
api_module_name = Object.const_get('HawatelSearchJobs').const_get('Api').const_get(api)
|
111
|
+
api_inst_var = instance_variable_get("@"+api.downcase)
|
112
|
+
api_sym_name = api.downcase.to_sym
|
113
|
+
|
114
|
+
if api_inst_var[:activated] && next_result?(api_sym_name)
|
115
|
+
next_result[api_sym_name] = api_module_name.page({:settings => api_inst_var,
|
116
|
+
:page => @jobs_table[api_sym_name].page + 1,
|
117
|
+
:query_key => @jobs_table[api_sym_name].key})
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
return nil if next_result.empty?
|
122
|
+
|
123
|
+
@jobs_table = next_result
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
# Sum jobs offers from specified api or count all
|
128
|
+
#
|
129
|
+
# @param args [Hash]
|
130
|
+
# @option args [String] :api name
|
131
|
+
# @example
|
132
|
+
# p client.count
|
133
|
+
# p client.count('indeed')
|
134
|
+
#
|
135
|
+
# @return [Integer]
|
136
|
+
def count(api = nil)
|
137
|
+
sum = 0
|
138
|
+
|
139
|
+
if api
|
140
|
+
api = api.downcase
|
141
|
+
api_inst_var = instance_variable_get("@"+api)
|
142
|
+
if api_inst_var[:activated]
|
143
|
+
sum = @jobs_table[:"#{api}"].totalResults if @jobs_table[:"#{api}"].totalResults
|
144
|
+
end
|
145
|
+
else
|
146
|
+
APIS.each do |provider|
|
147
|
+
api_inst_var = instance_variable_get("@"+provider.downcase)
|
148
|
+
if api_inst_var[:activated]
|
149
|
+
provider = provider.downcase
|
150
|
+
sum += @jobs_table[:"#{provider}"].totalResults if @jobs_table[:"#{provider}"].totalResults
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
return sum
|
155
|
+
end
|
156
|
+
|
157
|
+
private
|
158
|
+
def next_result?(provider)
|
159
|
+
if @jobs_table[provider] && @jobs_table[provider].page && @jobs_table[provider].last &&
|
160
|
+
@jobs_table[provider].page < @jobs_table[provider].last
|
161
|
+
true
|
162
|
+
else
|
163
|
+
false
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
data/spec/careerbuilder_spec.rb
CHANGED
@@ -1,83 +1,143 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
config.careerbuilder[:
|
8
|
-
config.careerbuilder[:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
expect(
|
55
|
-
expect(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
xdescribe HawatelSearchJobs::Api::Careerbuilder do
|
5
|
+
before(:each) do
|
6
|
+
HawatelSearchJobs.configure do |config|
|
7
|
+
config.careerbuilder[:api] = 'api.careerbuilder.com'
|
8
|
+
config.careerbuilder[:version] = 'v2'
|
9
|
+
config.careerbuilder[:clientid] = ''
|
10
|
+
config.careerbuilder[:page_size]= 100
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'APIs returned jobs' do
|
15
|
+
before(:each) do
|
16
|
+
@query_api = {:keywords => 'ruby', :location => ''}
|
17
|
+
@result = HawatelSearchJobs::Api::Careerbuilder.search(
|
18
|
+
:settings => HawatelSearchJobs.careerbuilder,
|
19
|
+
:query => {
|
20
|
+
:keywords => @query_api[:keywords],
|
21
|
+
:location => @query_api[:location]
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
it '#search' do
|
26
|
+
validate_result(@result, @query_api)
|
27
|
+
expect(@result.page).to be >= 0
|
28
|
+
expect(@result.last).to be >= 0
|
29
|
+
end
|
30
|
+
|
31
|
+
it '#results ordered by date descending' do
|
32
|
+
validate_result(@result, @query_api)
|
33
|
+
|
34
|
+
last_date = nil
|
35
|
+
@result.jobs.each do |job|
|
36
|
+
if !job.date.to_s.empty?
|
37
|
+
if !last_date.nil?
|
38
|
+
expect(convert_date_to_timestamp(job.date)).to be <= last_date
|
39
|
+
end
|
40
|
+
last_date = convert_date_to_timestamp(job.date)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it '#page' do
|
46
|
+
validate_result(@result, @query_api)
|
47
|
+
|
48
|
+
page_result =
|
49
|
+
HawatelSearchJobs::Api::Careerbuilder.page({
|
50
|
+
:settings => HawatelSearchJobs.careerbuilder,
|
51
|
+
:query_key => @result.key,
|
52
|
+
:page => 1})
|
53
|
+
expect(page_result.key).to match(/&PageNumber=2/)
|
54
|
+
expect(page_result.page).to be == 1
|
55
|
+
expect(page_result.last).to be >= 0
|
56
|
+
end
|
57
|
+
|
58
|
+
it '#count of jobs is the same like page_size' do
|
59
|
+
validate_result(@result, @query_api)
|
60
|
+
expect(@result.jobs.count).to eq(HawatelSearchJobs.careerbuilder[:page_size])
|
61
|
+
end
|
62
|
+
|
63
|
+
it '#next page does not contain last page' do
|
64
|
+
validate_result(@result, @query_api)
|
65
|
+
|
66
|
+
first_page =
|
67
|
+
HawatelSearchJobs::Api::Careerbuilder.page({
|
68
|
+
:settings => HawatelSearchJobs.careerbuilder,
|
69
|
+
:query_key => @result.key,
|
70
|
+
:page => 1})
|
71
|
+
expect(first_page.key).to match(/&PageNumber=2/)
|
72
|
+
expect(first_page.page).to be == 1
|
73
|
+
expect(first_page.last).to be >= 0
|
74
|
+
|
75
|
+
second_page =
|
76
|
+
HawatelSearchJobs::Api::Careerbuilder.page({
|
77
|
+
:settings => HawatelSearchJobs.careerbuilder,
|
78
|
+
:query_key => @result.key,
|
79
|
+
:page => 2})
|
80
|
+
|
81
|
+
expect(second_page.key).to match(/&PageNumber=3/)
|
82
|
+
expect(second_page.page).to be == 2
|
83
|
+
expect(second_page.last).to be >= 0
|
84
|
+
|
85
|
+
first_page.jobs.each do |first_job|
|
86
|
+
second_page.jobs.each do |second_job|
|
87
|
+
expect(first_job.url).not_to eq(second_job.url)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'APIs returned empty table' do
|
95
|
+
before(:each) do
|
96
|
+
@query_api = {:keywords => 'job-not-found-zero-records', :location => 'London'}
|
97
|
+
@result = HawatelSearchJobs::Api::Careerbuilder.search(
|
98
|
+
:settings => HawatelSearchJobs.careerbuilder,
|
99
|
+
:query => {
|
100
|
+
:keywords => @query_api[:keywords],
|
101
|
+
:location => @query_api[:location]
|
102
|
+
})
|
103
|
+
end
|
104
|
+
|
105
|
+
it '#search' do
|
106
|
+
validate_result(@result, @query_api)
|
107
|
+
expect(@result.totalResults).to eq(0)
|
108
|
+
expect(@result.page).to be_nil
|
109
|
+
expect(@result.last).to be_nil
|
110
|
+
expect(@result.jobs).to be_nil
|
111
|
+
end
|
112
|
+
|
113
|
+
it '#page' do
|
114
|
+
validate_result(@result, @query_api)
|
115
|
+
page_result =
|
116
|
+
HawatelSearchJobs::Api::Careerbuilder.page({
|
117
|
+
:settings => HawatelSearchJobs.careerbuilder,
|
118
|
+
:query_key => @result.key,
|
119
|
+
:page => 1})
|
120
|
+
expect(page_result.key).to match(/&PageNumber=2/)
|
121
|
+
expect(@result.totalResults).to eq(0)
|
122
|
+
expect(@result.page).to be_nil
|
123
|
+
expect(@result.last).to be_nil
|
124
|
+
expect(@result.jobs).to be_nil
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def validate_result(result, query_api)
|
131
|
+
expect(result.code).to eq(200)
|
132
|
+
expect(result.msg).to eq('OK')
|
133
|
+
expect(result.totalResults).to be >= 0
|
134
|
+
expect(result.key).to match("Location=#{query_api[:location]}")
|
135
|
+
expect(result.key).to match("Keywords=#{query_api[:keywords]}")
|
136
|
+
end
|
137
|
+
|
138
|
+
def convert_date_to_timestamp(job_date)
|
139
|
+
date = job_date.split('/')
|
140
|
+
return Time.parse("#{date[2]}-#{date[1]}-#{date[0]}").to_i
|
141
|
+
end
|
142
|
+
|
83
143
|
end
|