Class: ScraperWiki::API::Matchers::DatastoreMatcher
Overview
Datastore matchers -----------------------------------------------------
Instance Method Summary
collapse
Instance Method Details
#does_not_match?(actual) ⇒ Boolean
426
427
428
429
430
|
# File 'lib/scraperwiki-api/matchers.rb', line 426
def does_not_match?(actual)
super
@matches = matches
@matches.empty?
end
|
#failure_description ⇒ Object
464
465
466
|
# File 'lib/scraperwiki-api/matchers.rb', line 464
def failure_description
raise NotImplementerError, 'Subclasses must implement this method'
end
|
#failure_message ⇒ Object
456
457
458
|
# File 'lib/scraperwiki-api/matchers.rb', line 456
def failure_message
"#{failure_size} of #{items.size} #{failure_description}\n#{failures.map(&:inspect).join "\n"}"
end
|
#failure_size ⇒ Object
448
449
450
451
452
453
454
|
# File 'lib/scraperwiki-api/matchers.rb', line 448
def failure_size
if @mismatches
@mismatches.size
else
@matches.size
end
end
|
#failures ⇒ Object
440
441
442
443
444
445
446
|
# File 'lib/scraperwiki-api/matchers.rb', line 440
def failures
if @mismatches
@mismatches
else
@matches
end
end
|
#items ⇒ Object
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
# File 'lib/scraperwiki-api/matchers.rb', line 400
def items
@items ||= if Array === @actual
@actual
elsif Hash === @actual
if @actual['data']
@actual['data'].map do |array|
hash = {}
@actual['keys'].each_with_index do |key,index|
hash[key] = array[index]
end
hash
end
else
{}
end
else
raise NotImplementerError, "Can only handle jsondict or jsonlist formats"
end
end
|
#matches ⇒ Object
432
433
434
|
# File 'lib/scraperwiki-api/matchers.rb', line 432
def matches
raise NotImplementerError, 'Subclasses must implement this method'
end
|
#matches?(actual) ⇒ Boolean
420
421
422
423
424
|
# File 'lib/scraperwiki-api/matchers.rb', line 420
def matches?(actual)
super
@mismatches = mismatches
@mismatches.empty?
end
|
#mismatches ⇒ Object
436
437
438
|
# File 'lib/scraperwiki-api/matchers.rb', line 436
def mismatches
raise NotImplementerError, 'Subclasses must implement this method'
end
|
#negative_failure_description ⇒ Object
468
469
470
|
# File 'lib/scraperwiki-api/matchers.rb', line 468
def negative_failure_description
raise NotImplementerError, 'Subclasses must implement this method'
end
|
#negative_failure_message ⇒ Object
460
461
462
|
# File 'lib/scraperwiki-api/matchers.rb', line 460
def negative_failure_message
"#{failure_size} of #{items.size} #{negative_failure_description}\n#{failures.map(&:inspect).join "\n"}"
end
|