hawatel_search_jobs 0.2.0 → 0.2.1

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.
@@ -29,7 +29,14 @@ module HawatelSearchJobs
29
29
  def initialize
30
30
  APIS.each do |api|
31
31
  metaclasses.send(:attr_reader, api.downcase.to_sym)
32
- instance_variable_set("@#{api.downcase}", HawatelSearchJobs.instance_variable_get("@"+api.downcase))
32
+ api_conf = HawatelSearchJobs.instance_variable_get("@"+api.downcase)
33
+
34
+ if api_conf.nil?
35
+ HawatelSearchJobs.configure
36
+ api_conf = HawatelSearchJobs.instance_variable_get("@"+api.downcase)
37
+ end
38
+
39
+ instance_variable_set("@#{api.downcase}", api_conf.dup)
33
40
  end
34
41
  end
35
42
 
@@ -1,3 +1,3 @@
1
1
  module HawatelSearchJobs
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -1,64 +1,88 @@
1
1
  require 'spec_helper'
2
2
 
3
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
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
28
10
  end
29
- end
30
11
 
31
- let(:client) { HawatelSearchJobs::Client.new }
12
+ it 'multiple client objects do not have shared variables ' do
13
+ client_first = HawatelSearchJobs::Client.new
14
+ client_second = HawatelSearchJobs::Client.new
32
15
 
33
- it '#search valid data' do
34
- client.search_jobs({:keywords => 'ruby'})
35
- valid_jobs_table(client)
36
- end
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
37
20
 
38
- it '#search count method' do
39
- client.search_jobs({:keywords => 'ruby'})
40
- expect(client.count).to be_kind_of(Integer)
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
41
26
  end
42
27
 
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])
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
+ config.indeed[:page_size] = 10
34
+
35
+ config.xing[:activated] = false
36
+ config.xing[:consumer_key] = ''
37
+ config.xing[:consumer_secret] = ''
38
+ config.xing[:oauth_token] = ''
39
+ config.xing[:oauth_token_secret] = ''
40
+ config.xing[:page_size] = 60
41
+
42
+ config.reed[:activated] = false
43
+ config.reed[:clientid] = ''
44
+ config.reed[:page_size] = 40
45
+
46
+ config.careerbuilder[:activated]= false
47
+ config.careerbuilder[:clientid] = ''
48
+ config.careerbuilder[:page_size] = 80
49
+
50
+ config.careerjet[:activated] =true
51
+ config.careerjet[:api] = 'public.api.careerjet.net'
52
+ config.careerjet[:page_size] = 70
53
+ end
47
54
  end
48
- end
49
55
 
50
- it '#next valid data' do
51
- client.search_jobs({:keywords => 'ruby'})
56
+ let(:client) { HawatelSearchJobs::Client.new }
52
57
 
53
- valid_page_number(0, client)
54
- valid_jobs_table(client)
55
- client.next
58
+ it '#search valid data' do
59
+ client.search_jobs({:keywords => 'ruby'})
60
+ valid_jobs_table(client)
61
+ end
56
62
 
57
- valid_page_number(1, client)
58
- valid_jobs_table(client)
59
- end
63
+ it '#search count method' do
64
+ client.search_jobs({:keywords => 'ruby'})
65
+ expect(client.count).to be_kind_of(Integer)
66
+ end
67
+
68
+ it '#search page size limit' do
69
+ client.search_jobs({:keywords => 'ruby'})
70
+ client.jobs_table.each do |provider, result|
71
+ expect(result.jobs.count).to eq(HawatelSearchJobs.instance_variable_get("@#{provider.to_s}")[:page_size])
72
+ end
73
+ end
60
74
 
75
+ it '#next valid data' do
76
+ client.search_jobs({:keywords => 'ruby'})
61
77
 
78
+ valid_page_number(0, client)
79
+ valid_jobs_table(client)
80
+ client.next
81
+
82
+ valid_page_number(1, client)
83
+ valid_jobs_table(client)
84
+ end
85
+ end
62
86
 
63
87
  private
64
88
  def valid_jobs_table(client)
data/spec/spec_helper.rb CHANGED
@@ -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'
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.2.0
4
+ version: 0.2.1
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-27 00:00:00.000000000 Z
12
+ date: 2016-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xing_api