@@ -83,45 +83,45 @@ def get_stderr(&block)
83
83
fake . string
84
84
end
85
85
86
- subject do
86
+ subject ( :object_helper ) do
87
87
mod = Object . new
88
88
mod . extend MicrosoftPatchFinder ::Helper
89
89
mod
90
90
end
91
91
92
92
describe '#print_debug' do
93
93
it 'prints a [DEBUG] message' do
94
- output = get_stderr { subject . print_debug }
94
+ output = get_stderr { object_helper . print_debug }
95
95
expect ( output ) . to include ( '[DEBUG]' )
96
96
end
97
97
end
98
98
99
99
describe '#print_status' do
100
100
it 'prints a [*] message' do
101
- output = get_stderr { subject . print_status }
101
+ output = get_stderr { object_helper . print_status }
102
102
expect ( output ) . to include ( '[*]' )
103
103
end
104
104
end
105
105
106
106
describe '#print_error' do
107
107
it 'prints an [ERROR] message' do
108
- output = get_stderr { subject . print_error }
108
+ output = get_stderr { object_helper . print_error }
109
109
expect ( output ) . to include ( '[ERROR]' )
110
110
end
111
111
end
112
112
113
113
describe '#print_line' do
114
114
it 'prints a regular message' do
115
115
msg = 'TEST'
116
- output = get_stdout { subject . print_line ( msg ) }
116
+ output = get_stdout { object_helper . print_line ( msg ) }
117
117
expect ( output ) . to eq ( "#{ msg } \n " )
118
118
end
119
119
end
120
120
121
121
describe '#send_http_request' do
122
122
it 'returns a Rex::Proto::Http::Response object' do
123
- allow ( subject ) . to receive ( :print_debug )
124
- res = subject . send_http_request ( MicrosoftPatchFinder ::SiteInfo ::TECHNET )
123
+ allow ( object_helper ) . to receive ( :print_debug )
124
+ res = object_helper . send_http_request ( MicrosoftPatchFinder ::SiteInfo ::TECHNET )
125
125
expect ( res ) . to be_kind_of ( Rex ::Proto ::Http ::Response )
126
126
end
127
127
end
@@ -200,17 +200,17 @@ def get_stderr(&block)
200
200
|
201
201
end
202
202
203
- subject do
203
+ subject ( :patch_link_collector ) do
204
204
MicrosoftPatchFinder ::PatchLinkCollector . new
205
205
end
206
206
207
207
before ( :each ) do
208
- allow ( subject ) . to receive ( :print_debug )
208
+ allow ( patch_link_collector ) . to receive ( :print_debug )
209
209
end
210
210
211
211
describe '#download_advisory' do
212
212
it 'returns a Rex::Proto::Http::Response object' do
213
- res = subject . download_advisory ( 'ms15-100' )
213
+ res = patch_link_collector . download_advisory ( 'ms15-100' )
214
214
expect ( res ) . to be_kind_of ( Rex ::Proto ::Http ::Response )
215
215
end
216
216
end
@@ -219,25 +219,25 @@ def get_stderr(&block)
219
219
220
220
it 'returns a pattern for ms15-100' do
221
221
expected_pattern = '//div[@id="mainBody"]//div//div[@class="sectionblock"]//table//a'
222
- p = subject . get_appropriate_pattern ( ::Nokogiri ::HTML ( ms15_100_html ) )
222
+ p = patch_link_collector . get_appropriate_pattern ( ::Nokogiri ::HTML ( ms15_100_html ) )
223
223
expect ( p ) . to eq ( expected_pattern )
224
224
end
225
225
226
226
it 'returns a pattern for ms07-029' do
227
227
expected_pattern = '//div[@id="mainBody"]//ul//li//a[contains(text(), "Download the update")]'
228
- p = subject . get_appropriate_pattern ( ::Nokogiri ::HTML ( ms07_029_html ) )
228
+ p = patch_link_collector . get_appropriate_pattern ( ::Nokogiri ::HTML ( ms07_029_html ) )
229
229
expect ( p ) . to eq ( expected_pattern )
230
230
end
231
231
232
232
it 'returns a pattern for ms03-039' do
233
233
expected_pattern = '//div[@id="mainBody"]//div//div[@class="sectionblock"]//ul//li//a'
234
- p = subject . get_appropriate_pattern ( ::Nokogiri ::HTML ( ms03_039_html ) )
234
+ p = patch_link_collector . get_appropriate_pattern ( ::Nokogiri ::HTML ( ms03_039_html ) )
235
235
expect ( p ) . to eq ( expected_pattern )
236
236
end
237
237
238
238
it 'returns a pattern for ms07-030' do
239
239
expected_pattern = '//div[@id="mainBody"]//table//a'
240
- p = subject . get_appropriate_pattern ( ::Nokogiri ::HTML ( ms07_030_html ) )
240
+ p = patch_link_collector . get_appropriate_pattern ( ::Nokogiri ::HTML ( ms07_030_html ) )
241
241
expect ( p ) . to eq ( expected_pattern )
242
242
end
243
243
end
@@ -250,7 +250,7 @@ def get_stderr(&block)
250
250
end
251
251
252
252
it 'returns an URI object to a details aspx' do
253
- links = subject . get_details_aspx ( details_aspx )
253
+ links = patch_link_collector . get_details_aspx ( details_aspx )
254
254
expected_uri = 'https://www.microsoft.com/downloads/details.aspx?familyid=1'
255
255
expect ( links . length ) . to eq ( 1 )
256
256
expect ( links . first ) . to be_kind_of ( URI )
@@ -276,14 +276,14 @@ def get_stderr(&block)
276
276
allow ( cli ) . to receive ( :send_recv ) . and_return ( http_res )
277
277
allow ( Rex ::Proto ::Http ::Client ) . to receive ( :new ) . and_return ( cli )
278
278
279
- expect ( subject . follow_redirect ( technet , http_res ) . headers ) . to eq ( expected_header )
279
+ expect ( patch_link_collector . follow_redirect ( technet , http_res ) . headers ) . to eq ( expected_header )
280
280
end
281
281
end
282
282
283
283
describe '#get_download_page' do
284
284
it 'returns a Rex::Proto::Http::Response object' do
285
285
uri = URI ( 'http://www.example.com/' )
286
- expect ( subject . get_download_page ( uri ) ) . to be_kind_of ( Rex ::Proto ::Http ::Response )
286
+ expect ( patch_link_collector . get_download_page ( uri ) ) . to be_kind_of ( Rex ::Proto ::Http ::Response )
287
287
end
288
288
end
289
289
@@ -319,14 +319,14 @@ def get_stderr(&block)
319
319
allow ( cli ) . to receive ( :send_recv ) . and_return ( download_html_res )
320
320
allow ( Rex ::Proto ::Http ::Client ) . to receive ( :new ) . and_return ( cli )
321
321
322
- expect ( subject . get_download_links ( confirm_aspx ) . first ) . to eq ( expected_link )
322
+ expect ( patch_link_collector . get_download_links ( confirm_aspx ) . first ) . to eq ( expected_link )
323
323
end
324
324
end
325
325
326
326
describe '#has_advisory?' do
327
327
it 'returns true if the page is found' do
328
328
res = Rex ::Proto ::Http ::Response . new
329
- expect ( subject . has_advisory? ( res ) ) . to be_truthy
329
+ expect ( patch_link_collector . has_advisory? ( res ) ) . to be_truthy
330
330
end
331
331
332
332
it 'returns false if the page is not found' do
@@ -338,7 +338,7 @@ def get_stderr(&block)
338
338
339
339
res = Rex ::Proto ::Http ::Response . new
340
340
allow ( res ) . to receive ( :body ) . and_return ( html )
341
- expect ( subject . has_advisory? ( res ) ) . to be_falsey
341
+ expect ( patch_link_collector . has_advisory? ( res ) ) . to be_falsey
342
342
end
343
343
end
344
344
@@ -352,11 +352,11 @@ def get_stderr(&block)
352
352
end
353
353
354
354
it 'returns true if the MSB format is correct' do
355
- expect ( subject . is_valid_msb? ( good_msb ) ) . to be_truthy
355
+ expect ( patch_link_collector . is_valid_msb? ( good_msb ) ) . to be_truthy
356
356
end
357
357
358
358
it 'returns false if the MSB format is incorrect' do
359
- expect ( subject . is_valid_msb? ( bad_msb ) ) . to be_falsey
359
+ expect ( patch_link_collector . is_valid_msb? ( bad_msb ) ) . to be_falsey
360
360
end
361
361
362
362
end
@@ -365,7 +365,7 @@ def get_stderr(&block)
365
365
366
366
describe MicrosoftPatchFinder ::TechnetMsbSearch do
367
367
368
- subject do
368
+ subject ( :technet_msb_search ) do
369
369
MicrosoftPatchFinder ::TechnetMsbSearch . new
370
370
end
371
371
@@ -425,39 +425,39 @@ def get_stderr(&block)
425
425
426
426
describe '#find_msb_numbers' do
427
427
it 'returns an array of found MSB numbers' do
428
- msb = subject . find_msb_numbers ( ie10 )
428
+ msb = technet_msb_search . find_msb_numbers ( ie10 )
429
429
expect ( msb ) . to be_kind_of ( Array )
430
430
expect ( msb . first ) . to eq ( 'ms15-100' )
431
431
end
432
432
end
433
433
434
434
describe '#search' do
435
435
it 'returns search results in JSON format' do
436
- results = subject . search ( ie10 )
436
+ results = technet_msb_search . search ( ie10 )
437
437
expect ( results ) . to be_kind_of ( Hash )
438
438
expect ( results [ 'b' ] . first [ 'Id' ] ) . to eq ( 'MS15-100' )
439
439
end
440
440
end
441
441
442
442
describe '#search_by_product_ids' do
443
443
it 'returns an array of found MSB numbers' do
444
- results = subject . search_by_product_ids ( [ ie10_id ] )
444
+ results = technet_msb_search . search_by_product_ids ( [ ie10_id ] )
445
445
expect ( results ) . to be_kind_of ( Array )
446
446
expect ( results . first ) . to eq ( 'ms15-100' )
447
447
end
448
448
end
449
449
450
450
describe '#search_by_keyword' do
451
451
it 'returns an array of found MSB numbers' do
452
- results = subject . search_by_keyword ( 'ms15-100' )
452
+ results = technet_msb_search . search_by_keyword ( 'ms15-100' )
453
453
expect ( results ) . to be_kind_of ( Array )
454
454
expect ( results . first ) . to eq ( 'ms15-100' )
455
455
end
456
456
end
457
457
458
458
describe '#get_product_dropdown_list' do
459
459
it 'returns an array of products' do
460
- results = subject . get_product_dropdown_list
460
+ results = technet_msb_search . get_product_dropdown_list
461
461
expect ( results ) . to be_kind_of ( Array )
462
462
expect ( results . first ) . to be_kind_of ( Hash )
463
463
expected_hash = { :option_value => "10175" , :option_text => "Active Directory" }
@@ -469,7 +469,7 @@ def get_stderr(&block)
469
469
470
470
describe MicrosoftPatchFinder ::GoogleMsbSearch do
471
471
472
- subject do
472
+ subject ( :google_msb_search ) do
473
473
MicrosoftPatchFinder ::GoogleMsbSearch . new
474
474
end
475
475
@@ -571,15 +571,15 @@ def get_stderr(&block)
571
571
572
572
describe '#find_msb_numbers' do
573
573
it 'returns an array of msb numbers' do
574
- results = subject . find_msb_numbers ( expected_msb )
574
+ results = google_msb_search . find_msb_numbers ( expected_msb )
575
575
expect ( results ) . to be_kind_of ( Array )
576
576
expect ( results ) . to eq ( [ expected_msb ] )
577
577
end
578
578
end
579
579
580
580
describe '#search' do
581
581
it 'returns a hash (json data)' do
582
- results = subject . search ( starting_index : 1 )
582
+ results = google_msb_search . search ( starting_index : 1 )
583
583
expect ( results ) . to be_kind_of ( Hash )
584
584
end
585
585
end
@@ -589,21 +589,21 @@ def get_stderr(&block)
589
589
res = Rex ::Proto ::Http ::Response . new
590
590
allow ( res ) . to receive ( :body ) . and_return ( json_data )
591
591
592
- results = subject . parse_results ( res )
592
+ results = google_msb_search . parse_results ( res )
593
593
expect ( results ) . to be_kind_of ( Hash )
594
594
end
595
595
end
596
596
597
597
describe '#get_total_results' do
598
598
it 'returns a fixnum' do
599
- total = subject . get_total_results ( JSON . parse ( json_data ) )
599
+ total = google_msb_search . get_total_results ( JSON . parse ( json_data ) )
600
600
expect ( total ) . to be_kind_of ( Fixnum )
601
601
end
602
602
end
603
603
604
604
describe '#get_next_index' do
605
605
it 'returns a fixnum' do
606
- i = subject . get_next_index ( JSON . parse ( json_data ) )
606
+ i = google_msb_search . get_next_index ( JSON . parse ( json_data ) )
607
607
expect ( i ) . to be_kind_of ( Fixnum )
608
608
end
609
609
end
@@ -633,13 +633,13 @@ def get_stderr(&block)
633
633
allow_any_instance_of ( MicrosoftPatchFinder ::PatchLinkCollector ) . to receive ( :print_error )
634
634
end
635
635
636
- subject do
636
+ subject ( :driver ) do
637
637
MicrosoftPatchFinder ::Driver . new
638
638
end
639
639
640
640
describe '#get_download_links' do
641
641
it 'returns an array of links' do
642
- results = subject . get_download_links ( msb )
642
+ results = driver . get_download_links ( msb )
643
643
expect ( results ) . to be_kind_of ( Array )
644
644
expect ( results . first ) . to eq ( expected_link )
645
645
end
0 commit comments