Class: ScraperWiki::API::Matchers::CountMatcher

Inherits:
TablesMatcher show all
Defined in:
lib/scraperwiki-api/matchers.rb

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from ScraperWiki::API::Matchers::CustomMatcher

Instance Method Details

#countObject



340
341
342
343
344
345
346
# File 'lib/scraperwiki-api/matchers.rb', line 340

def count
  if @actual['datasummary']['tables'][@table]
    @actual['datasummary']['tables'][@table]['count']
  else
    0
  end
end

#failure_messageObject



353
354
355
# File 'lib/scraperwiki-api/matchers.rb', line 353

def failure_message
  "expected #{@actual['short_name']} to have #{@expected} rows, not #{count}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


348
349
350
351
# File 'lib/scraperwiki-api/matchers.rb', line 348

def matches?(actual)
  super
  count == @expected
end

#negative_failure_messageObject



357
358
359
# File 'lib/scraperwiki-api/matchers.rb', line 357

def negative_failure_message
  "expected #{@actual['short_name']} to not have #{@expected} rows"
end