hawatel_search_jobs 0.1.2 → 0.1.3

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,3 +1,3 @@
1
1
  module HawatelSearchJobs
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,87 +1,83 @@
1
- require 'spec_helper'
2
-
3
- describe HawatelSearchJobs::Api::Careerbuilder do
4
- context 'APIs returned jobs' 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
- end
11
-
12
- @query_api = {:keywords => 'ruby', :location => ''}
13
- @result = HawatelSearchJobs::Api::Careerbuilder.search(
14
- :settings => HawatelSearchJobs.careerbuilder,
15
- :query => {
16
- :keywords => @query_api[:keywords],
17
- :location => @query_api[:location]
18
- })
19
- end
20
-
21
- xit '#search' do
22
- validate_result(@result, @query_api)
23
- expect(@result.page).to be >= 0
24
- expect(@result.last).to be >= 0
25
- end
26
-
27
- xit '#page' do
28
- validate_result(@result, @query_api)
29
- page_result = HawatelSearchJobs::Api::Careerbuilder.page({
30
- :settings => HawatelSearchJobs.careerbuilder,
31
- :query_key => @result.key,
32
- :page => 1})
33
- expect(page_result.key).to match(/&PageNumber=2/)
34
- expect(page_result.page).to be == 1
35
- expect(page_result.last).to be >= 0
36
- end
37
- end
38
-
39
- context 'APIs returned empty table' do
40
- before(:each) do
41
- HawatelSearchJobs.configure do |config|
42
- config.careerbuilder[:api] = 'api.careerbuilder.com'
43
- config.careerbuilder[:version] = 'v2'
44
- config.careerbuilder[:clientid] = ''
45
- end
46
-
47
- @query_api = {:keywords => 'job-not-found-zero-records', :location => 'London'}
48
- @result = HawatelSearchJobs::Api::Careerbuilder.search(
49
- :settings => HawatelSearchJobs.careerbuilder,
50
- :query => {
51
- :keywords => @query_api[:keywords],
52
- :location => @query_api[:location]
53
- })
54
- end
55
-
56
- xit '#search' do
57
- validate_result(@result, @query_api)
58
- expect(@result.totalResults).to eq(0)
59
- expect(@result.page).to be_nil
60
- expect(@result.last).to be_nil
61
- expect(@result.jobs).to be_nil
62
- end
63
-
64
- xit '#page' do
65
- validate_result(@result, @query_api)
66
- page_result = HawatelSearchJobs::Api::Careerbuilder.page({
67
- :settings => HawatelSearchJobs.careerbuilder,
68
- :query_key => @result.key,
69
- :page => 1})
70
- expect(page_result.key).to match(/&PageNumber=2/)
71
- expect(@result.totalResults).to eq(0)
72
- expect(@result.page).to be_nil
73
- expect(@result.last).to be_nil
74
- expect(@result.jobs).to be_nil
75
- end
76
- end
77
-
78
- private
79
-
80
- def validate_result(result, query_api)
81
- expect(result.code).to eq(200)
82
- expect(result.msg).to eq('OK')
83
- expect(result.totalResults).to be >= 0
84
- expect(result.key).to match("Location=#{query_api[:location]}")
85
- expect(result.key).to match("Keywords=#{query_api[:keywords]}")
86
- end
1
+ require 'spec_helper'
2
+
3
+ xdescribe HawatelSearchJobs::Api::Careerbuilder do
4
+ before(:each) do
5
+ HawatelSearchJobs.configure do |config|
6
+ config.careerbuilder[:api] = 'api.careerbuilder.com'
7
+ config.careerbuilder[:version] = 'v2'
8
+ config.careerbuilder[:clientid] = ''
9
+ end
10
+ end
11
+
12
+ context 'APIs returned jobs' do
13
+ before(:each) do
14
+ @query_api = {:keywords => 'ruby', :location => ''}
15
+ @result = HawatelSearchJobs::Api::Careerbuilder.search(
16
+ :settings => HawatelSearchJobs.careerbuilder,
17
+ :query => {
18
+ :keywords => @query_api[:keywords],
19
+ :location => @query_api[:location]
20
+ })
21
+ end
22
+
23
+ it '#search' do
24
+ validate_result(@result, @query_api)
25
+ expect(@result.page).to be >= 0
26
+ expect(@result.last).to be >= 0
27
+ end
28
+
29
+ it '#page' do
30
+ validate_result(@result, @query_api)
31
+ page_result = HawatelSearchJobs::Api::Careerbuilder.page({
32
+ :settings => HawatelSearchJobs.careerbuilder,
33
+ :query_key => @result.key,
34
+ :page => 1})
35
+ expect(page_result.key).to match(/&PageNumber=2/)
36
+ expect(page_result.page).to be == 1
37
+ expect(page_result.last).to be >= 0
38
+ end
39
+ end
40
+
41
+ context 'APIs returned empty table' do
42
+ before(:each) do
43
+ @query_api = {:keywords => 'job-not-found-zero-records', :location => 'London'}
44
+ @result = HawatelSearchJobs::Api::Careerbuilder.search(
45
+ :settings => HawatelSearchJobs.careerbuilder,
46
+ :query => {
47
+ :keywords => @query_api[:keywords],
48
+ :location => @query_api[:location]
49
+ })
50
+ end
51
+
52
+ it '#search' do
53
+ validate_result(@result, @query_api)
54
+ expect(@result.totalResults).to eq(0)
55
+ expect(@result.page).to be_nil
56
+ expect(@result.last).to be_nil
57
+ expect(@result.jobs).to be_nil
58
+ end
59
+
60
+ it '#page' do
61
+ validate_result(@result, @query_api)
62
+ page_result = HawatelSearchJobs::Api::Careerbuilder.page({
63
+ :settings => HawatelSearchJobs.careerbuilder,
64
+ :query_key => @result.key,
65
+ :page => 1})
66
+ expect(page_result.key).to match(/&PageNumber=2/)
67
+ expect(@result.totalResults).to eq(0)
68
+ expect(@result.page).to be_nil
69
+ expect(@result.last).to be_nil
70
+ expect(@result.jobs).to be_nil
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ def validate_result(result, query_api)
77
+ expect(result.code).to eq(200)
78
+ expect(result.msg).to eq('OK')
79
+ expect(result.totalResults).to be >= 0
80
+ expect(result.key).to match("Location=#{query_api[:location]}")
81
+ expect(result.key).to match("Keywords=#{query_api[:keywords]}")
82
+ end
87
83
  end
@@ -1,59 +1,59 @@
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
+ 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
+
59
59
  end
data/spec/client_spec.rb CHANGED
@@ -1,62 +1,88 @@
1
- require 'spec_helper'
2
-
3
- describe HawatelSearchJobs::Client do
4
- before(:each) do
5
- HawatelSearchJobs.configure do |config|
6
- config.indeed[:activated] = true
7
- config.indeed[:publisher] = ''
8
-
9
- config.xing[:activated] = true
10
- config.xing[:consumer_key] = 'd'
11
- config.xing[:consumer_secret] = ''
12
- config.xing[:oauth_token] = ''
13
- config.xing[:oauth_token_secret] = ''
14
-
15
- config.reed[:activated] = true
16
- config.reed[:clientid] = ''
17
-
18
- config.careerbuilder[:activated]= true
19
- config.careerbuilder[:clientid] = ''
20
-
21
- config.careerjet[:activated] =true
22
- config.careerjet[:api] = 'public.api.careerjet.net'
23
- end
24
- end
25
-
26
- let(:client) { HawatelSearchJobs::Client.new }
27
-
28
- xit '#search valid data' do
29
- client.search_jobs({:keywords => 'ruby'})
30
- valid_jobs_table(client)
31
- end
32
-
33
- xit '#search count method' do
34
- client.search_jobs({:keywords => 'ruby'})
35
- expect(client.count).to be_kind_of(Integer)
36
- end
37
-
38
- xit '#next valid data' do
39
- client.search_jobs({:keywords => 'ruby'})
40
-
41
- valid_page_number(0, client)
42
- valid_jobs_table(client)
43
- client.next
44
-
45
- valid_page_number(1, client)
46
- valid_jobs_table(client)
47
- end
48
-
49
- private
50
- def valid_jobs_table(client)
51
- expect(client.jobs_table).not_to be_nil
52
- client.jobs_table.each do |provider, result|
53
- expect(result.totalResults).to be >= 0
54
- end
55
- end
56
-
57
- def valid_page_number(page, client)
58
- client.jobs_table.each do |provider, result|
59
- expect(result.page).to be == page
60
- end
61
- end
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
62
88
  end
data/spec/indeed_spec.rb CHANGED
@@ -1,62 +1,60 @@
1
- require 'spec_helper'
2
-
3
- describe "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
- xit "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
- xit "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
- xit "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
- xit "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
- xit "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
-
54
- xit "call search() with providing company param" do
55
- result = HawatelSearchJobs::Api::Indeed.search(:settings => HawatelSearchJobs.indeed, :query => {:company => 'ibm'})
56
- result.jobs.each do |job|
57
- expect(job.company).to eq("IBM")
58
- end
59
- end
60
-
61
-
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
+
62
60
  end