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,78 +1,94 @@
1
- require 'spec_helper'
2
- require 'ostruct'
3
-
4
- xdescribe HawatelSearchJobs::Api::Reed do
5
- before(:each) do
6
- HawatelSearchJobs.configure do |config|
7
- config.reed[:api] = "reed.co.uk/api"
8
- config.reed[:clientid] = ''
9
- end
10
- end
11
-
12
- context 'APIs returned jobs' do
13
- before(:each) do
14
- @query_api = { :keywords => 'ruby', :location => 'London' }
15
-
16
- @result = HawatelSearchJobs::Api::Reed.search(
17
- :settings => HawatelSearchJobs.reed,
18
- :query => {
19
- :keywords => @query_api[:keywords],
20
- :location => @query_api[:location]
21
- })
22
- end
23
-
24
- it '#search' do
25
- validate_result(@result, @query_api)
26
- expect(@result.page).to be >= 0
27
- expect(@result.last).to be >= 0
28
- end
29
-
30
- it '#page' do
31
- validate_result(@result, @query_api)
32
- page_result = HawatelSearchJobs::Api::Reed.page({:settings => HawatelSearchJobs.reed, :query_key => @result.key, :page => 1})
33
- expect(page_result.key).to match(/&resultsToSkip=25/)
34
- expect(page_result.page).to eq(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
- @query_api = { :keywords => 'job-not-found-zero-records', :location => 'London' }
42
-
43
- @result = HawatelSearchJobs::Api::Reed.search(
44
- :settings => HawatelSearchJobs.reed,
45
- :query => {
46
- :keywords => @query_api[:keywords],
47
- :location => @query_api[:location]
48
- })
49
- end
50
-
51
- it '#search' do
52
- validate_result(@result, @query_api)
53
- expect(@result.totalResults).to eq(0)
54
- expect(@result.page).to be_nil
55
- expect(@result.last).to be_nil
56
- end
57
-
58
- it '#page' do
59
- validate_result(@result, @query_api)
60
- page_result = HawatelSearchJobs::Api::Reed.page({:settings => HawatelSearchJobs.reed, :query_key => @result.key, :page => 1})
61
- expect(page_result.key).to match(/&resultsToSkip=25/)
62
- expect(@result.totalResults).to eq(0)
63
- expect(@result.page).to be_nil
64
- expect(@result.last).to be_nil
65
- end
66
-
67
- end
68
-
69
- private
70
-
71
- def validate_result(result, query_api)
72
- expect(result.code).to eq(200)
73
- expect(result.msg).to eq('OK')
74
- expect(result.totalResults).to be >= 0
75
- expect(result.key).to match("locationName=#{query_api[:location]}")
76
- expect(result.key).to match("keywords=#{query_api[:keywords]}")
77
- end
1
+ require 'spec_helper'
2
+ require 'ostruct'
3
+
4
+ xdescribe HawatelSearchJobs::Api::Reed do
5
+ before(:each) do
6
+ HawatelSearchJobs.configure do |config|
7
+ config.reed[:api] = "reed.co.uk/api"
8
+ config.reed[:clientid] = ''
9
+ config.reed[:page_size] = 100
10
+ end
11
+ end
12
+
13
+ context 'APIs returned jobs' do
14
+ before(:each) do
15
+ @query_api = { :keywords => 'ruby', :location => 'London' }
16
+
17
+ @result = HawatelSearchJobs::Api::Reed.search(
18
+ :settings => HawatelSearchJobs.reed,
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 '#page' do
32
+ validate_result(@result, @query_api)
33
+ page_result = HawatelSearchJobs::Api::Reed.page({:settings => HawatelSearchJobs.reed, :query_key => @result.key, :page => 1})
34
+ expect(page_result.key).to match(/&resultsToSkip=#{HawatelSearchJobs.reed[:page_size]}/)
35
+ expect(page_result.page).to eq(1)
36
+ expect(page_result.last).to be >= 0
37
+ end
38
+
39
+ it '#next page does not contain last page' do
40
+ validate_result(@result, @query_api)
41
+ page_first = HawatelSearchJobs::Api::Reed.page({:settings => HawatelSearchJobs.reed, :query_key => @result.key, :page => 1})
42
+ page_second = HawatelSearchJobs::Api::Reed.page({:settings => HawatelSearchJobs.reed, :query_key => @result.key, :page => 2})
43
+
44
+ page_first.jobs.each do |first_job|
45
+ page_second.jobs.each do |second_job|
46
+ expect(first_job.url).not_to eq(second_job.url)
47
+ end
48
+ end
49
+ end
50
+
51
+ it '#count of jobs is the same like page_size' do
52
+ expect(@result.jobs.count).to eq(HawatelSearchJobs.reed[:page_size])
53
+ end
54
+ end
55
+
56
+ context 'APIs returned empty table' do
57
+ before(:each) do
58
+ @query_api = { :keywords => 'job-not-found-zero-records', :location => 'London' }
59
+
60
+ @result = HawatelSearchJobs::Api::Reed.search(
61
+ :settings => HawatelSearchJobs.reed,
62
+ :query => {
63
+ :keywords => @query_api[:keywords],
64
+ :location => @query_api[:location]
65
+ })
66
+ end
67
+
68
+ it '#search' do
69
+ validate_result(@result, @query_api)
70
+ expect(@result.totalResults).to eq(0)
71
+ expect(@result.page).to be_nil
72
+ expect(@result.last).to be_nil
73
+ end
74
+
75
+ it '#page' do
76
+ validate_result(@result, @query_api)
77
+ page_result = HawatelSearchJobs::Api::Reed.page({:settings => HawatelSearchJobs.reed, :query_key => @result.key, :page => 1})
78
+ expect(@result.totalResults).to eq(0)
79
+ expect(@result.page).to be_nil
80
+ expect(@result.last).to be_nil
81
+ end
82
+
83
+ end
84
+
85
+ private
86
+
87
+ def validate_result(result, query_api)
88
+ expect(result.code).to eq(200)
89
+ expect(result.msg).to eq('OK')
90
+ expect(result.totalResults).to be >= 0
91
+ expect(result.key).to match("locationName=#{query_api[:location]}")
92
+ expect(result.key).to match("keywords=#{query_api[:keywords]}")
93
+ end
78
94
  end
@@ -1,2 +1,2 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'hawatel_search_jobs'
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'hawatel_search_jobs'
@@ -1,47 +1,67 @@
1
- require 'spec_helper'
2
- require 'xing_api'
3
-
4
- xdescribe "HawatelSearchJobs::Api::Xing" do
5
-
6
- before(:each) do
7
- HawatelSearchJobs.configure do |config|
8
- config.xing[:consumer_key] = ''
9
- config.xing[:consumer_secret] = ''
10
- config.xing[:oauth_token] = ''
11
- config.xing[:oauth_token_secret] = ''
12
- end
13
- end
14
-
15
- let(:client) { return HawatelSearchJobs::Client.new }
16
- let(:result) {
17
- return HawatelSearchJobs::Api::Xing.search(
18
- :settings => HawatelSearchJobs.xing,
19
- :query => { :keywords => 'ruby', :company => '' }
20
- )}
21
-
22
- it "metadata from search() result" do
23
- expect(result.page).to be_a_kind_of(Integer)
24
- expect(result.last).to be_a_kind_of(Integer)
25
- expect(result.totalResults).to be_a_kind_of(Integer)
26
- end
27
-
28
- it "job attributes from search() result" do
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 "call page() without specified page (default 0)" do
38
- jobs = HawatelSearchJobs::Api::Xing.page({:query_key => result.key})
39
- expect(jobs.page).to eq(0)
40
- end
41
-
42
- it "call page() with specified page" do
43
- jobs = HawatelSearchJobs::Api::Xing.page({:query_key => result.key, :page => 1})
44
- expect(jobs.page).to eq(1)
45
- end
46
-
1
+ require 'spec_helper'
2
+ require 'xing_api'
3
+
4
+ xdescribe "HawatelSearchJobs::Api::Xing" do
5
+
6
+ before(:each) do
7
+ HawatelSearchJobs.configure do |config|
8
+ config.xing[:consumer_key] = ''
9
+ config.xing[:consumer_secret] = ''
10
+ config.xing[:oauth_token] = ''
11
+ config.xing[:oauth_token_secret] = ''
12
+ config.xing[:page_size] = 100
13
+ end
14
+ end
15
+
16
+ let(:client) { return HawatelSearchJobs::Client.new }
17
+ let(:result) {
18
+ return HawatelSearchJobs::Api::Xing.search(
19
+ :settings => HawatelSearchJobs.xing,
20
+ :query => { :keywords => 'ruby', :company => '' }
21
+ )}
22
+
23
+ it "metadata from search() result" do
24
+ expect(result.page).to be_a_kind_of(Integer)
25
+ expect(result.last).to be_a_kind_of(Integer)
26
+ expect(result.totalResults).to be_a_kind_of(Integer)
27
+ end
28
+
29
+ it "job attributes from search() result" do
30
+ result.jobs.each do |job|
31
+ expect(job.jobtitle).to be_a_kind_of(String)
32
+ expect(job.location).to be_a_kind_of(String)
33
+ expect(job.company).to be_a_kind_of(String)
34
+ expect(job.url).to include('http')
35
+ end
36
+ end
37
+
38
+ it "count of jobs is the same like page_size" do
39
+ expect(result.jobs.count).to eq(HawatelSearchJobs.xing[:page_size])
40
+ end
41
+
42
+ it "call page() without specified page (default 0)" do
43
+ jobs = HawatelSearchJobs::Api::Xing.page({:settings => HawatelSearchJobs.xing, :query_key => result.key})
44
+ expect(jobs.page).to eq(0)
45
+ end
46
+
47
+ it "call page() with specified page" do
48
+ jobs = HawatelSearchJobs::Api::Xing.page({:settings => HawatelSearchJobs.xing, :query_key => result.key, :page => 1})
49
+ expect(jobs.page).to eq(1)
50
+ end
51
+
52
+ it "next page does not contain last page" do
53
+ jobs_first = HawatelSearchJobs::Api::Xing.page({:settings => HawatelSearchJobs.xing, :query_key => result.key, :page => 1})
54
+ expect(jobs_first.page).to eq(1)
55
+
56
+ jobs_second = HawatelSearchJobs::Api::Xing.page({:settings => HawatelSearchJobs.xing, :query_key => result.key, :page => 2})
57
+ expect(jobs_second.page).to eq(2)
58
+
59
+ jobs_first.jobs.each do |first_job|
60
+ jobs_second.jobs.each do |second_job|
61
+ expect(first_job.url).not_to eq(second_job.url)
62
+ end
63
+ end
64
+
65
+ end
66
+
47
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hawatel_search_jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Przemyslaw Mantaj
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-29 00:00:00.000000000 Z
12
+ date: 2016-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xing_api