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.
@@ -1,59 +1,98 @@
1
- require 'spec_helper'
2
-
3
- describe HawatelSearchJobs::Api::CareerJet do
4
-
5
- let(:client) { return HawatelSearchJobs::Client.new }
6
- let(:result) {
7
- return HawatelSearchJobs::Api::CareerJet.search(
8
- :settings => HawatelSearchJobs.careerjet,
9
- :query => { :keywords => 'ruby', :company => '' }
10
- )
11
- }
12
-
13
- before(:each) do
14
- HawatelSearchJobs.configure do |config|
15
- config.careerjet[:api] = 'public.api.careerjet.net'
16
- end
17
- end
18
-
19
- it "metadata from search() result" do
20
- expect(result.totalResults).to be_a_kind_of(Integer)
21
- expect(result.page).to be_a_kind_of(Integer)
22
- expect(result.last).to be_a_kind_of(Integer)
23
- expect(result.key).to be_a_kind_of(String)
24
- end
25
-
26
- it "job attributes from search() result" do
27
- expect(result.jobs.size).to be > 0
28
- result.jobs.each do |job|
29
- expect(job.jobtitle).to be_a_kind_of(String)
30
- expect(job.url).to include('http')
31
- end
32
- end
33
-
34
- it "call page() without page param (default 0)" do
35
- jobs = HawatelSearchJobs::Api::CareerJet.page({:query_key => result.key})
36
- expect(jobs.page).to eq(0)
37
- end
38
-
39
- it "call page() with specified page" do
40
- jobs = HawatelSearchJobs::Api::CareerJet.page({:query_key => result.key, :page => 2})
41
- expect(jobs.page).to eq(2)
42
- end
43
-
44
- it "call search() with location param" do
45
- result = HawatelSearchJobs::Api::CareerJet.search(:settings => HawatelSearchJobs.careerjet,
46
- :query => { :keywords => 'ruby', :location => 'London' })
47
- location_found = false
48
- result.jobs.each do |job|
49
- if job.location =~ /London/
50
- location_found = true
51
- break
52
- end
53
- end
54
-
55
- expect(location_found).to eq(true)
56
- end
57
-
58
-
1
+ require 'spec_helper'
2
+
3
+ describe HawatelSearchJobs::Api::CareerJet do
4
+
5
+ let(:client) { return HawatelSearchJobs::Client.new }
6
+ let(:result) {
7
+ return HawatelSearchJobs::Api::CareerJet.search(
8
+ :settings => HawatelSearchJobs.careerjet,
9
+ :query => { :keywords => 'ruby', :company => '' }
10
+ )
11
+ }
12
+
13
+ before(:each) do
14
+ HawatelSearchJobs.configure do |config|
15
+ config.careerjet[:api] = 'public.api.careerjet.net'
16
+ config.careerjet[:page_size] = 99
17
+ end
18
+ end
19
+
20
+ it "metadata from search() result" do
21
+ expect(result.totalResults).to be_a_kind_of(Integer)
22
+ expect(result.page).to be_a_kind_of(Integer)
23
+ expect(result.last).to be_a_kind_of(Integer)
24
+ expect(result.key).to be_a_kind_of(String)
25
+ end
26
+
27
+ it "results ordered by date descending" do
28
+
29
+ last_date = nil
30
+ result.jobs.each do |job|
31
+ if !job.date.to_s.empty?
32
+ if !last_date.nil?
33
+ expect(convert_date_to_timestamp(job.date)).to be <= last_date
34
+ end
35
+ last_date = convert_date_to_timestamp(job.date)
36
+ end
37
+ end
38
+ end
39
+
40
+ it "job attributes from search() result" do
41
+ expect(result.jobs.size).to be > 0
42
+ result.jobs.each do |job|
43
+ expect(job.jobtitle).to be_a_kind_of(String)
44
+ expect(job.url).to include('http')
45
+ end
46
+ end
47
+
48
+ it "count of jobs is the same like page_size" do
49
+ expect(result.jobs.count).to eq(HawatelSearchJobs.careerjet[:page_size])
50
+ end
51
+
52
+ it "call page() without page param (default 0)" do
53
+ jobs = HawatelSearchJobs::Api::CareerJet.page({:query_key => result.key})
54
+ expect(jobs.page).to eq(0)
55
+ end
56
+
57
+ it "call page() with specified page" do
58
+ jobs = HawatelSearchJobs::Api::CareerJet.page({:query_key => result.key, :page => 2})
59
+ expect(jobs.page).to eq(2)
60
+ end
61
+
62
+ it "next page does not contain last page" do
63
+ jobs_first = HawatelSearchJobs::Api::CareerJet.page({:query_key => result.key, :page => 2})
64
+ expect(jobs_first.page).to eq(2)
65
+
66
+ jobs_second = HawatelSearchJobs::Api::CareerJet.page({:query_key => result.key, :page => 3})
67
+ expect(jobs_second.page).to eq(3)
68
+
69
+ jobs_first.jobs.each do |first_job|
70
+ jobs_second.jobs.each do |second_job|
71
+ expect(first_job.url).not_to eq(second_job.url)
72
+ end
73
+ end
74
+
75
+ end
76
+
77
+ it "call search() with location param" do
78
+ result = HawatelSearchJobs::Api::CareerJet.search(:settings => HawatelSearchJobs.careerjet,
79
+ :query => { :keywords => 'ruby', :location => 'London' })
80
+ location_found = false
81
+ result.jobs.each do |job|
82
+ if job.location =~ /London/
83
+ location_found = true
84
+ break
85
+ end
86
+ end
87
+
88
+ expect(location_found).to eq(true)
89
+ end
90
+
91
+ private
92
+
93
+ def convert_date_to_timestamp(job_date)
94
+ date = job_date.split('/')
95
+ return Time.parse("#{date[2]}-#{date[1]}-#{date[0]}").to_i
96
+ end
97
+
59
98
  end
@@ -1,88 +1,76 @@
1
- require 'spec_helper'
2
-
3
- describe HawatelSearchJobs::Client do
4
- context 'with default settings' do
5
- it '#new' do
6
- client = HawatelSearchJobs::Client.new
7
- HawatelSearchJobs::Client::APIS.each do |api|
8
- expect(client.instance_variable_get("@#{api.downcase.to_s}")[:activated]).to eq(false)
9
- end
10
- end
11
-
12
- it 'multiple client objects do not have shared variables ' do
13
- client_first = HawatelSearchJobs::Client.new
14
- client_second = HawatelSearchJobs::Client.new
15
-
16
- HawatelSearchJobs::Client::APIS.each do |api|
17
- client_first.instance_variable_get("@#{api.downcase.to_s}")[:activated] = true
18
- client_second.instance_variable_get("@#{api.downcase.to_s}")[:activated] = false
19
- end
20
-
21
- HawatelSearchJobs::Client::APIS.each do |api|
22
- expect(client_first.instance_variable_get("@#{api.downcase.to_s}")[:activated]).to eq(true)
23
- expect(client_second.instance_variable_get("@#{api.downcase.to_s}")[:activated]).to eq(false)
24
- end
25
- end
26
- end
27
-
28
- context 'with custom settings' do
29
- before(:each) do
30
- HawatelSearchJobs.configure do |config|
31
- config.indeed[:activated] = false
32
- config.indeed[:publisher] = ''
33
-
34
- config.xing[:activated] = false
35
- config.xing[:consumer_key] = ''
36
- config.xing[:consumer_secret] = ''
37
- config.xing[:oauth_token] = ''
38
- config.xing[:oauth_token_secret] = ''
39
-
40
- config.reed[:activated] = false
41
- config.reed[:clientid] = ''
42
-
43
- config.careerbuilder[:activated]= false
44
- config.careerbuilder[:clientid] = ''
45
-
46
- config.careerjet[:activated] =true
47
- config.careerjet[:api] = 'public.api.careerjet.net'
48
- end
49
- end
50
-
51
- let(:client) { HawatelSearchJobs::Client.new }
52
-
53
- it '#search valid data' do
54
- client.search_jobs({:keywords => 'ruby'})
55
- valid_jobs_table(client)
56
- end
57
-
58
- it '#search count method' do
59
- client.search_jobs({:keywords => 'ruby'})
60
- expect(client.count).to be_kind_of(Integer)
61
- end
62
-
63
- it '#next valid data' do
64
- client.search_jobs({:keywords => 'ruby'})
65
-
66
- valid_page_number(0, client)
67
- valid_jobs_table(client)
68
- client.next
69
-
70
- valid_page_number(1, client)
71
- valid_jobs_table(client)
72
- end
73
- end
74
-
75
- private
76
- def valid_jobs_table(client)
77
- expect(client.jobs_table).not_to be_nil
78
- client.jobs_table.each do |provider, result|
79
- expect(result.totalResults).to be >= 0
80
- end
81
- end
82
-
83
- def valid_page_number(page, client)
84
- client.jobs_table.each do |provider, result|
85
- expect(result.page).to be == page
86
- end
87
- end
1
+ require 'spec_helper'
2
+
3
+ describe HawatelSearchJobs::Client do
4
+ before(:each) do
5
+ HawatelSearchJobs.configure do |config|
6
+ config.indeed[:activated] = false
7
+ config.indeed[:publisher] = ''
8
+ config.indeed[:page_size] = 10
9
+
10
+ config.xing[:activated] = false
11
+ config.xing[:consumer_key] = ''
12
+ config.xing[:consumer_secret] = ''
13
+ config.xing[:oauth_token] = ''
14
+ config.xing[:oauth_token_secret] = ''
15
+ config.xing[:page_size] = 60
16
+
17
+ config.reed[:activated] = false
18
+ config.reed[:clientid] = ''
19
+ config.reed[:page_size] = 40
20
+
21
+ config.careerbuilder[:activated]= false
22
+ config.careerbuilder[:clientid] = ''
23
+ config.careerbuilder[:page_size] = 80
24
+
25
+ config.careerjet[:activated] =true
26
+ config.careerjet[:api] = 'public.api.careerjet.net'
27
+ config.careerjet[:page_size] = 70
28
+ end
29
+ end
30
+
31
+ let(:client) { HawatelSearchJobs::Client.new }
32
+
33
+ it '#search valid data' do
34
+ client.search_jobs({:keywords => 'ruby'})
35
+ valid_jobs_table(client)
36
+ end
37
+
38
+ it '#search count method' do
39
+ client.search_jobs({:keywords => 'ruby'})
40
+ expect(client.count).to be_kind_of(Integer)
41
+ end
42
+
43
+ it '#search page size limit' do
44
+ client.search_jobs({:keywords => 'ruby'})
45
+ client.jobs_table.each do |provider, result|
46
+ expect(result.jobs.count).to eq(HawatelSearchJobs.instance_variable_get("@#{provider.to_s}")[:page_size])
47
+ end
48
+ end
49
+
50
+ it '#next valid data' do
51
+ client.search_jobs({:keywords => 'ruby'})
52
+
53
+ valid_page_number(0, client)
54
+ valid_jobs_table(client)
55
+ client.next
56
+
57
+ valid_page_number(1, client)
58
+ valid_jobs_table(client)
59
+ end
60
+
61
+
62
+
63
+ private
64
+ def valid_jobs_table(client)
65
+ expect(client.jobs_table).not_to be_nil
66
+ client.jobs_table.each do |provider, result|
67
+ expect(result.totalResults).to be >= 0
68
+ end
69
+ end
70
+
71
+ def valid_page_number(page, client)
72
+ client.jobs_table.each do |provider, result|
73
+ expect(result.page).to be == page
74
+ end
75
+ end
88
76
  end
@@ -1,60 +1,98 @@
1
- require 'spec_helper'
2
-
3
- xdescribe "HawatelSearchJobs::Api::Indeed" do
4
-
5
- before(:each) do
6
- HawatelSearchJobs.configure do |config|
7
- config.indeed[:api] = 'api.indeed.com'
8
- config.indeed[:publisher] = ''
9
- end
10
- end
11
-
12
- let(:client) { return HawatelSearchJobs::Client.new }
13
- let(:result) {
14
- return HawatelSearchJobs::Api::Indeed.search(
15
- :settings => HawatelSearchJobs.indeed,
16
- :query => { :keywords => 'ruby', :company => '' }
17
- )}
18
-
19
- it "metadata from search() result" do
20
- expect(result.totalResults).to be_a_kind_of(Integer)
21
- expect(result.page).to be_a_kind_of(Integer)
22
- expect(result.last).to be_a_kind_of(Integer)
23
- expect(result.key).to include("http")
24
- end
25
-
26
- it "job attrubutes from search() result" do
27
- expect(result.jobs.size).to be > 0
28
- result.jobs.each do |job|
29
- expect(job.jobtitle).to be_a_kind_of(String)
30
- expect(job.location).to be_a_kind_of(String)
31
- expect(job.company).to be_a_kind_of(String)
32
- expect(job.url).to include('http')
33
- end
34
- end
35
-
36
- it "call page() without page param (default 0)" do
37
- jobs = HawatelSearchJobs::Api::Indeed.page({:query_key => result.key})
38
- expect(jobs.page).to eq(0)
39
- end
40
-
41
- it "call page() with specified page" do
42
- jobs = HawatelSearchJobs::Api::Indeed.page({:query_key => result.key, :page => 1})
43
- expect(jobs.page).to eq(1)
44
- end
45
-
46
- it "call search() with providing location param" do
47
- result = HawatelSearchJobs::Api::Indeed.search(:settings => HawatelSearchJobs.indeed, :query => {:location => 'US'})
48
- result.jobs.each do |job|
49
- expect(job.location).to include("US")
50
- end
51
- end
52
-
53
- it "call search() with providing company param" do
54
- result = HawatelSearchJobs::Api::Indeed.search(:settings => HawatelSearchJobs.indeed, :query => {:company => 'ibm'})
55
- result.jobs.each do |job|
56
- expect(job.company).to match(/IBM/)
57
- end
58
- end
59
-
1
+ require 'spec_helper'
2
+
3
+ xdescribe "HawatelSearchJobs::Api::Indeed" do
4
+
5
+ before(:each) do
6
+ HawatelSearchJobs.configure do |config|
7
+ config.indeed[:api] = 'api.indeed.com'
8
+ config.indeed[:publisher] = ''
9
+ config.indeed[:page_size] = 20
10
+ end
11
+ end
12
+
13
+ let(:client) { return HawatelSearchJobs::Client.new }
14
+ let(:result) {
15
+ return HawatelSearchJobs::Api::Indeed.search(
16
+ :settings => HawatelSearchJobs.indeed,
17
+ :query => { :keywords => 'ruby', :company => '' }
18
+ )}
19
+
20
+ it "metadata from search() result" do
21
+ expect(result.totalResults).to be_a_kind_of(Integer)
22
+ expect(result.page).to be_a_kind_of(Integer)
23
+ expect(result.last).to be_a_kind_of(Integer)
24
+ expect(result.key).to include("http")
25
+ end
26
+
27
+ it "job attrubutes from search() result" do
28
+ expect(result.jobs.size).to be > 0
29
+ result.jobs.each do |job|
30
+ expect(job.jobtitle).to be_a_kind_of(String)
31
+ expect(job.location).to be_a_kind_of(String)
32
+ expect(job.company).to be_a_kind_of(String)
33
+ expect(job.url).to include('http')
34
+ end
35
+ end
36
+
37
+ it "count of jobs is the same like page_size" do
38
+ expect(result.jobs.count).to eq(HawatelSearchJobs.indeed[:page_size])
39
+ end
40
+
41
+ it "call page() without page param (default 0)" do
42
+ jobs = HawatelSearchJobs::Api::Indeed.page({:settings => HawatelSearchJobs.indeed, :query_key => result.key})
43
+ expect(jobs.page).to eq(0)
44
+ end
45
+
46
+ it "call page() with specified page" do
47
+ jobs = HawatelSearchJobs::Api::Indeed.page({:settings => HawatelSearchJobs.indeed, :query_key => result.key, :page => 1})
48
+ expect(jobs.page).to eq(1)
49
+ end
50
+
51
+ it "next page does not contain last page" do
52
+ jobs_first = HawatelSearchJobs::Api::Indeed.page({:settings => HawatelSearchJobs.indeed, :query_key => result.key, :page => 1})
53
+ expect(jobs_first.page).to eq(1)
54
+
55
+ jobs_second = HawatelSearchJobs::Api::Indeed.page({:settings => HawatelSearchJobs.indeed, :query_key => result.key, :page => 2})
56
+ expect(jobs_second.page).to eq(2)
57
+
58
+ jobs_first.jobs.each do |first_job|
59
+ jobs_second.jobs.each do |second_job|
60
+ expect(first_job.url).not_to eq(second_job.url)
61
+ end
62
+ end
63
+ end
64
+
65
+ it "results ordered by date descending" do
66
+ last_date = nil
67
+ result.jobs.each do |job|
68
+ if !job.date.to_s.empty?
69
+ if !last_date.nil?
70
+ expect(convert_date_to_timestamp(job.date)).to be <= last_date
71
+ end
72
+ last_date = convert_date_to_timestamp(job.date)
73
+ end
74
+ end
75
+ end
76
+
77
+ it "call search() with providing location param" do
78
+ result = HawatelSearchJobs::Api::Indeed.search(:settings => HawatelSearchJobs.indeed, :query => {:location => 'US'})
79
+ result.jobs.each do |job|
80
+ expect(job.location).to include("US")
81
+ end
82
+ end
83
+
84
+ it "call search() with providing company param" do
85
+ result = HawatelSearchJobs::Api::Indeed.search(:settings => HawatelSearchJobs.indeed, :query => {:company => 'ibm'})
86
+ result.jobs.each do |job|
87
+ expect(job.company).to match(/IBM/)
88
+ end
89
+ end
90
+
91
+ private
92
+
93
+ def convert_date_to_timestamp(job_date)
94
+ date = job_date.split('/')
95
+ return Time.parse("#{date[2]}-#{date[1]}-#{date[0]}").to_i
96
+ end
97
+
60
98
  end