harvestdor-indexer 1.0.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +1 -0
  3. data/harvestdor-indexer.gemspec +1 -1
  4. data/lib/harvestdor-indexer.rb +12 -2
  5. data/lib/harvestdor-indexer/version.rb +1 -1
  6. data/spec/fixtures/vcr_cassettes/before_all_call.yml +48 -0
  7. data/spec/fixtures/vcr_cassettes/cant_find_whitelist_call.yml +48 -0
  8. data/spec/fixtures/vcr_cassettes/empty_array_no_blacklist_config_call.yml +48 -0
  9. data/spec/fixtures/vcr_cassettes/empty_array_no_whitelist_config_call.yml +48 -0
  10. data/spec/fixtures/vcr_cassettes/get_collection_druids_call.yml +18 -20
  11. data/spec/fixtures/vcr_cassettes/ignore_druids_in_blacklist_and_whitelist_call.yml +48 -0
  12. data/spec/fixtures/vcr_cassettes/ignore_druids_in_blacklist_call.yml +61 -20
  13. data/spec/fixtures/vcr_cassettes/know_what_is_in_blacklist_call.yml +46 -0
  14. data/spec/fixtures/vcr_cassettes/know_what_is_in_whitelist_call.yml +46 -0
  15. data/spec/fixtures/vcr_cassettes/load_blacklist_once_call.yml +48 -0
  16. data/spec/fixtures/vcr_cassettes/load_whitelist_once_call.yml +48 -0
  17. data/spec/fixtures/vcr_cassettes/no_blacklist_config_call.yml +61 -20
  18. data/spec/fixtures/vcr_cassettes/no_blacklist_found_call.yml +48 -0
  19. data/spec/fixtures/vcr_cassettes/no_whitelist_config_call.yml +61 -20
  20. data/spec/fixtures/vcr_cassettes/process_druids_whitelist_call.yml +48 -0
  21. data/spec/fixtures/vcr_cassettes/rsolr_client_config_call.yml +48 -0
  22. data/spec/fixtures/vcr_cassettes/single_rsolr_connection_call.yml +61 -20
  23. data/spec/unit/harvestdor-indexer_spec.rb +114 -72
  24. metadata +30 -6
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://127.0.0.1:3000/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - '*/*; q=0.5, application/xml'
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ X-Frame-Options:
22
+ - SAMEORIGIN
23
+ X-Xss-Protection:
24
+ - 1; mode=block
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ Content-Type:
28
+ - application/xml; charset=utf-8
29
+ Etag:
30
+ - '"444bcb3a3fcf8389296c49467f27e1d6"'
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ X-Meta-Request-Version:
34
+ - 0.3.4
35
+ X-Request-Id:
36
+ - 3f57f369-8d39-43dc-b15e-dc7a7f37d25e
37
+ X-Runtime:
38
+ - '0.003776'
39
+ Connection:
40
+ - close
41
+ Server:
42
+ - thin 1.6.2 codename Doc Brown
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ok
46
+ http_version:
47
+ recorded_at: Wed, 12 Nov 2014 18:46:07 GMT
48
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://127.0.0.1:3000/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - '*/*; q=0.5, application/xml'
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ X-Frame-Options:
22
+ - SAMEORIGIN
23
+ X-Xss-Protection:
24
+ - 1; mode=block
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ Content-Type:
28
+ - application/xml; charset=utf-8
29
+ Etag:
30
+ - '"444bcb3a3fcf8389296c49467f27e1d6"'
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ X-Meta-Request-Version:
34
+ - 0.3.4
35
+ X-Request-Id:
36
+ - f3fe5cb0-9a23-4906-bf4b-2e7f236a53a9
37
+ X-Runtime:
38
+ - '0.003822'
39
+ Connection:
40
+ - close
41
+ Server:
42
+ - thin 1.6.2 codename Doc Brown
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ok
46
+ http_version:
47
+ recorded_at: Wed, 12 Nov 2014 18:50:01 GMT
48
+ recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://127.0.0.1:3000/collection/yg867hg1375
5
+ uri: http://127.0.0.1:3000/
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -14,7 +14,7 @@ http_interactions:
14
14
  response:
15
15
  status:
16
16
  code: 200
17
- message: 'OK '
17
+ message: OK
18
18
  headers:
19
19
  X-Frame-Options:
20
20
  - SAMEORIGIN
@@ -23,36 +23,77 @@ http_interactions:
23
23
  X-Content-Type-Options:
24
24
  - nosniff
25
25
  Content-Type:
26
- - application/json; charset=utf-8
26
+ - text/html; charset=utf-8
27
27
  Etag:
28
- - '"682afec57f678e4d153a5841b21395dd"'
28
+ - '"444bcb3a3fcf8389296c49467f27e1d6"'
29
29
  Cache-Control:
30
30
  - max-age=0, private, must-revalidate
31
+ X-Meta-Request-Version:
32
+ - 0.3.4
31
33
  X-Request-Id:
32
- - 37413f0c-a104-4df1-8a80-1873389200f4
34
+ - 4fef0b48-9ee9-4ef8-811e-78b8c0f643f0
33
35
  X-Runtime:
34
- - '0.006754'
36
+ - '0.005477'
37
+ Connection:
38
+ - close
35
39
  Server:
36
- - WEBrick/1.3.1 (Ruby/2.1.2/2014-05-08)
37
- Date:
38
- - Wed, 22 Oct 2014 18:42:32 GMT
39
- Content-Length:
40
- - '1121'
40
+ - thin 1.6.2 codename Doc Brown
41
+ body:
42
+ encoding: US-ASCII
43
+ string: ok
44
+ http_version:
45
+ recorded_at: Wed, 12 Nov 2014 19:34:02 GMT
46
+ - request:
47
+ method: get
48
+ uri: http://127.0.0.1:3000/collections/yg867hg1375
49
+ body:
50
+ encoding: US-ASCII
51
+ string: ''
52
+ headers:
53
+ Accept:
54
+ - '*/*'
55
+ User-Agent:
56
+ - Ruby
57
+ response:
58
+ status:
59
+ code: 200
60
+ message: OK
61
+ headers:
62
+ X-Frame-Options:
63
+ - SAMEORIGIN
64
+ X-Xss-Protection:
65
+ - 1; mode=block
66
+ X-Content-Type-Options:
67
+ - nosniff
68
+ Content-Type:
69
+ - application/json; charset=utf-8
70
+ Etag:
71
+ - '"c3a375a17d64792857f21d1af227ed7b"'
72
+ Cache-Control:
73
+ - max-age=0, private, must-revalidate
74
+ X-Meta-Request-Version:
75
+ - 0.3.4
76
+ X-Request-Id:
77
+ - 26936654-94cb-4135-b867-53f9ba72d1b5
78
+ X-Runtime:
79
+ - '0.011706'
41
80
  Connection:
42
- - Keep-Alive
81
+ - close
82
+ Server:
83
+ - thin 1.6.2 codename Doc Brown
43
84
  body:
44
85
  encoding: US-ASCII
45
- string: '{"collection":[{"druid":"druid:yg867hg1375","latest_change":"2013-11-11T23:34:29Z","title":["Francis
46
- E. Stafford photographs, 1909-1933"]}],"item":[{"druid":"druid:jf275fd6276","latest_change":"2013-11-11T23:34:29Z","title":["Album
86
+ string: '{"collections":[{"druid":"druid:yg867hg1375","latest_change":"2013-11-11T23:34:29Z","title":"Francis
87
+ E. Stafford photographs, 1909-1933"}],"items":[{"druid":"druid:jf275fd6276","latest_change":"2013-11-11T23:34:29Z","title":"Album
47
88
  A: Photographs of China''s natural landscapes, urban scenes, cultural landmarks,
48
- social customs, and people."]},{"druid":"druid:nz353cp1092","latest_change":"2013-11-11T23:34:29Z","title":["Album
49
- E: Photographs of the Seventh Day Adventist Church missionaries in China"]},{"druid":"druid:tc552kq0798","latest_change":"2013-11-11T23:34:29Z","title":["Album
89
+ social customs, and people."},{"druid":"druid:nz353cp1092","latest_change":"2013-11-11T23:34:29Z","title":"Album
90
+ E: Photographs of the Seventh Day Adventist Church missionaries in China"},{"druid":"druid:tc552kq0798","latest_change":"2013-11-11T23:34:29Z","title":"Album
50
91
  D: Photographs of China''s natural landscapes, urban scenes, cultural landmarks,
51
- social customs, and people."]},{"druid":"druid:th998nk0722","latest_change":"2013-11-11T23:34:29Z","title":["Album
92
+ social customs, and people."},{"druid":"druid:th998nk0722","latest_change":"2013-11-11T23:34:29Z","title":"Album
52
93
  C: Photographs of the Chinese Revolution of 1911 and the Shanghai Commercial
53
- Press"]},{"druid":"druid:ww689vs6534","latest_change":"2013-11-11T23:34:29Z","title":["Album
94
+ Press"},{"druid":"druid:ww689vs6534","latest_change":"2013-11-11T23:34:29Z","title":"Album
54
95
  B: Photographs of China''s natural landscapes, urban scenes, cultural landmarks,
55
- social customs, and people."]}],"counts":[{"collection":1},{"item":5},{"total_count":6}]}'
96
+ social customs, and people."}],"counts":{"collections":1,"items":5,"total_count":6}}'
56
97
  http_version:
57
- recorded_at: Wed, 22 Oct 2014 18:42:32 GMT
98
+ recorded_at: Wed, 12 Nov 2014 19:34:02 GMT
58
99
  recorded_with: VCR 2.9.3
@@ -3,15 +3,17 @@ require 'spec_helper'
3
3
  describe Harvestdor::Indexer do
4
4
 
5
5
  before(:all) do
6
- @config_yml_path = File.join(File.dirname(__FILE__), "..", "config", "ap.yml")
7
- @client_config_path = File.join(File.dirname(__FILE__), "../..", "config", "dor-fetcher-client.yml")
8
- @indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
9
- require 'yaml'
10
- @yaml = YAML.load_file(@config_yml_path)
11
- @hdor_client = @indexer.send(:harvestdor_client)
12
- @fake_druid = 'oo000oo0000'
13
- @blacklist_path = File.join(File.dirname(__FILE__), "../config/ap_blacklist.txt")
14
- @whitelist_path = File.join(File.dirname(__FILE__), "../config/ap_whitelist.txt")
6
+ VCR.use_cassette('before_all_call') do
7
+ @config_yml_path = File.join(File.dirname(__FILE__), "..", "config", "ap.yml")
8
+ @client_config_path = File.join(File.dirname(__FILE__), "../..", "config", "dor-fetcher-client.yml")
9
+ @indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
10
+ require 'yaml'
11
+ @yaml = YAML.load_file(@config_yml_path)
12
+ @hdor_client = @indexer.send(:harvestdor_client)
13
+ @fake_druid = 'oo000oo0000'
14
+ @blacklist_path = File.join(File.dirname(__FILE__), "../config/ap_blacklist.txt")
15
+ @whitelist_path = File.join(File.dirname(__FILE__), "../config/ap_whitelist.txt")
16
+ end
15
17
  end
16
18
 
17
19
  # The method that sends the solr document to solr
@@ -56,8 +58,8 @@ describe Harvestdor::Indexer do
56
58
  end
57
59
 
58
60
  it "should initialize the harvestdor_client from the config" do
59
- @hdor_client.should be_an_instance_of(Harvestdor::Client)
60
- @hdor_client.config.default_set.should == @yaml['default_set']
61
+ expect(@hdor_client).to be_an_instance_of(Harvestdor::Client)
62
+ expect(@hdor_client.config.default_set).to eq(@yaml['default_set'])
61
63
  end
62
64
 
63
65
  context "harvest_and_index" do
@@ -86,38 +88,44 @@ describe Harvestdor::Indexer do
86
88
 
87
89
  it "should not process druids in blacklist" do
88
90
  VCR.use_cassette('ignore_druids_in_blacklist_call') do
89
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => @blacklist_path})
90
- hdor_client = indexer.send(:harvestdor_client)
91
- indexer.dor_fetcher_client.should_receive(:druid_array).and_return(["druid:yg867hg1375", "druid:jf275fd6276", "druid:nz353cp1092", "druid:tc552kq0798", "druid:th998nk0722", "druid:ww689vs6534"])
92
- indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:nz353cp1092'}))
93
- indexer.solr_client.should_not_receive(:add).with(hash_including({:id => 'druid:jf275fd6276'}))
94
- indexer.solr_client.should_not_receive(:add).with(hash_including({:id => 'druid:tc552kq0798'}))
95
- indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:th998nk0722'}))
96
- indexer.solr_client.should_receive(:commit)
97
- indexer.harvest_and_index
91
+ lambda{
92
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => @blacklist_path})
93
+ hdor_client = indexer.send(:harvestdor_client)
94
+ indexer.dor_fetcher_client.should_receive(:druid_array).and_return(["druid:yg867hg1375", "druid:jf275fd6276", "druid:nz353cp1092", "druid:tc552kq0798", "druid:th998nk0722", "druid:ww689vs6534"])
95
+ indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:nz353cp1092'}))
96
+ indexer.solr_client.should_not_receive(:add).with(hash_including({:id => 'druid:jf275fd6276'}))
97
+ indexer.solr_client.should_not_receive(:add).with(hash_including({:id => 'druid:tc552kq0798'}))
98
+ indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:th998nk0722'}))
99
+ indexer.solr_client.should_receive(:commit)
100
+ indexer.harvest_and_index
101
+ }
98
102
  end
99
103
  end
100
104
  it "should not process druid if it is in both blacklist and whitelist" do
101
105
  VCR.use_cassette('ignore_druids_in_blacklist_and_whitelist_call') do
102
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => @blacklist_path, :whitelist => @whitelist_path})
103
- hdor_client = indexer.send(:harvestdor_client)
104
- indexer.dor_fetcher_client.should_not_receive(:druid_array)
105
- indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:yg867hg1375'}))
106
- indexer.solr_client.should_not_receive(:add).with(hash_including({:id => 'druid:jf275fd6276'}))
107
- indexer.solr_client.should_receive(:commit)
108
- indexer.harvest_and_index
106
+ lambda{
107
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => @blacklist_path, :whitelist => @whitelist_path})
108
+ hdor_client = indexer.send(:harvestdor_client)
109
+ indexer.dor_fetcher_client.should_not_receive(:druid_array)
110
+ indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:yg867hg1375'}))
111
+ indexer.solr_client.should_not_receive(:add).with(hash_including({:id => 'druid:jf275fd6276'}))
112
+ indexer.solr_client.should_receive(:commit)
113
+ indexer.harvest_and_index
114
+ }
109
115
  end
110
116
  end
111
117
  it "should only process druids in whitelist if it exists" do
112
118
  VCR.use_cassette('process_druids_whitelist_call') do
113
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:whitelist => @whitelist_path})
114
- hdor_client = indexer.send(:harvestdor_client)
115
- indexer.dor_fetcher_client.should_not_receive(:druid_array)
116
- indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:yg867hg1375'}))
117
- indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:jf275fd6276'}))
118
- indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:nz353cp1092'}))
119
- indexer.solr_client.should_receive(:commit)
120
- indexer.harvest_and_index
119
+ lambda{
120
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:whitelist => @whitelist_path})
121
+ hdor_client = indexer.send(:harvestdor_client)
122
+ indexer.dor_fetcher_client.should_not_receive(:druid_array)
123
+ indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:yg867hg1375'}))
124
+ indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:jf275fd6276'}))
125
+ indexer.solr_client.should_receive(:add).with(hash_including({:id => 'druid:nz353cp1092'}))
126
+ indexer.solr_client.should_receive(:commit)
127
+ indexer.harvest_and_index
128
+ }
121
129
  end
122
130
  end
123
131
 
@@ -286,81 +294,115 @@ describe Harvestdor::Indexer do
286
294
  @indexer.send(:blacklist).size.should == 2
287
295
  end
288
296
  it "should be empty Array if there was no blacklist config setting" do
289
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
290
- indexer.send(:blacklist).should == []
297
+ VCR.use_cassette('empty_array_no_blacklist_config_call') do
298
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
299
+ expect(indexer.blacklist).to eq([])
300
+ end
291
301
  end
292
302
  context "load_blacklist" do
303
+ it "knows what is in the blacklist" do
304
+ VCR.use_cassette('know_what_is_in_blacklist_call') do
305
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => @blacklist_path})
306
+ expect(indexer.blacklist).to eq(["druid:jf275fd6276", "druid:tc552kq0798"])
307
+ end
308
+ end
293
309
  it "should not be called if there was no blacklist config setting" do
294
310
  VCR.use_cassette('no_blacklist_config_call') do
295
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
311
+ lambda{
312
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
296
313
 
297
- indexer.should_not_receive(:load_blacklist)
314
+ indexer.should_not_receive(:load_blacklist)
298
315
 
299
- hdor_client = indexer.send(:harvestdor_client)
300
- indexer.dor_fetcher_client.should_receive(:druid_array).and_return([@fake_druid])
301
- indexer.solr_client.should_receive(:add)
302
- indexer.solr_client.should_receive(:commit)
303
- indexer.harvest_and_index
316
+ hdor_client = indexer.send(:harvestdor_client)
317
+ indexer.dor_fetcher_client.should_receive(:druid_array).and_return([@fake_druid])
318
+ indexer.solr_client.should_receive(:add)
319
+ indexer.solr_client.should_receive(:commit)
320
+ indexer.harvest_and_index
321
+ }
304
322
  end
305
323
  end
306
324
  it "should only try to load a blacklist once" do
307
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => @blacklist_path})
308
- indexer.send(:blacklist)
309
- File.any_instance.should_not_receive(:open)
310
- indexer.send(:blacklist)
325
+ VCR.use_cassette('load_blacklist_once_call') do
326
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => @blacklist_path})
327
+ indexer.send(:blacklist)
328
+ File.any_instance.should_not_receive(:open)
329
+ indexer.send(:blacklist)
330
+ end
311
331
  end
312
332
  it "should log an error message and throw RuntimeError if it can't find the indicated blacklist file" do
313
- exp_msg = 'Unable to find list of druids at bad_path'
314
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => 'bad_path'})
315
- indexer.logger.should_receive(:fatal).with(exp_msg)
316
- expect { indexer.send(:load_blacklist, 'bad_path') }.to raise_error(exp_msg)
333
+ VCR.use_cassette('no_blacklist_found_call') do
334
+ exp_msg = 'Unable to find list of druids at bad_path'
335
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:blacklist => 'bad_path'})
336
+ indexer.logger.should_receive(:fatal).with(exp_msg)
337
+ expect { indexer.send(:load_blacklist, 'bad_path') }.to raise_error(exp_msg)
338
+ end
317
339
  end
318
340
  end
319
341
  end # blacklist
320
342
 
321
343
  context "whitelist" do
344
+ it "knows what is in the whitelist" do
345
+ VCR.use_cassette('know_what_is_in_whitelist_call') do
346
+ lambda{
347
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:whitelist => @whitelist_path})
348
+ expect(indexer.whitelist).to eq(["druid:yg867hg1375", "druid:jf275fd6276", "druid:nz353cp1092"])
349
+ }
350
+ end
351
+ end
322
352
  it "should be an Array with an entry for each non-empty line in the file" do
323
353
  @indexer.send(:load_whitelist, @whitelist_path)
324
354
  @indexer.send(:whitelist).should be_an_instance_of(Array)
325
355
  @indexer.send(:whitelist).size.should == 3
326
356
  end
327
357
  it "should be empty Array if there was no whitelist config setting" do
328
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
329
- indexer.send(:whitelist).should == []
358
+ VCR.use_cassette('empty_array_no_whitelist_config_call') do
359
+ lambda{
360
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
361
+ expect(indexer.whitelist).to eq([])
362
+ }
363
+ end
330
364
  end
331
365
  context "load_whitelist" do
332
366
  it "should not be called if there was no whitelist config setting" do
333
367
  VCR.use_cassette('no_whitelist_config_call') do
334
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
368
+ lambda{
369
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path)
335
370
 
336
- indexer.should_not_receive(:load_whitelist)
371
+ indexer.should_not_receive(:load_whitelist)
337
372
 
338
- hdor_client = indexer.send(:harvestdor_client)
339
- indexer.dor_fetcher_client.should_receive(:druid_array).and_return([@fake_druid])
340
- indexer.solr_client.should_receive(:add)
341
- indexer.solr_client.should_receive(:commit)
342
- indexer.harvest_and_index
373
+ hdor_client = indexer.send(:harvestdor_client)
374
+ indexer.dor_fetcher_client.should_receive(:druid_array).and_return([@fake_druid])
375
+ indexer.solr_client.should_receive(:add)
376
+ indexer.solr_client.should_receive(:commit)
377
+ indexer.harvest_and_index
378
+ }
343
379
  end
344
380
  end
345
381
  it "should only try to load a whitelist once" do
346
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:whitelist => @whitelist_path})
347
- indexer.send(:whitelist)
348
- File.any_instance.should_not_receive(:open)
349
- indexer.send(:whitelist)
382
+ VCR.use_cassette('load_whitelist_once_call') do
383
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:whitelist => @whitelist_path})
384
+ indexer.send(:whitelist)
385
+ File.any_instance.should_not_receive(:open)
386
+ indexer.send(:whitelist)
387
+ end
350
388
  end
351
389
  it "should log an error message and throw RuntimeError if it can't find the indicated whitelist file" do
352
- exp_msg = 'Unable to find list of druids at bad_path'
353
- indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:whitelist => 'bad_path'})
354
- indexer.logger.should_receive(:fatal).with(exp_msg)
355
- expect { indexer.send(:load_whitelist, 'bad_path') }.to raise_error(exp_msg)
390
+ VCR.use_cassette('cant_find_whitelist_call') do
391
+ exp_msg = 'Unable to find list of druids at bad_path'
392
+ indexer = Harvestdor::Indexer.new(@config_yml_path, @client_config_path, {:whitelist => 'bad_path'})
393
+ indexer.logger.should_receive(:fatal).with(exp_msg)
394
+ expect { indexer.send(:load_whitelist, 'bad_path') }.to raise_error(exp_msg)
395
+ end
356
396
  end
357
397
  end
358
398
  end # whitelist
359
399
 
360
400
  it "solr_client should initialize the rsolr client using the options from the config" do
361
- indexer = Harvestdor::Indexer.new(nil, @client_config_path, Confstruct::Configuration.new(:solr => { :url => 'http://localhost:2345', :a => 1 }) )
362
- RSolr.should_receive(:connect).with(hash_including(:a => 1, :url => 'http://localhost:2345')).and_return('foo')
363
- indexer.solr_client
401
+ VCR.use_cassette('rsolr_client_config_call') do
402
+ indexer = Harvestdor::Indexer.new(nil, @client_config_path, Confstruct::Configuration.new(:solr => { :url => 'http://localhost:2345', :a => 1 }) )
403
+ RSolr.should_receive(:connect).with(hash_including(:a => 1, :url => 'http://localhost:2345')).and_return('foo')
404
+ indexer.solr_client
405
+ end
364
406
  end
365
407
 
366
408
  end