Sha256: 98d3aa42a4132c0a78d7163ebda3e447e07b617adb9ff113defa5d1dc3f4f4db

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

module Recog
class Verifier
  attr_reader :fingerprints, :reporter

  def initialize(fingerprints, reporter)
    @fingerprints = fingerprints
    @reporter = reporter
  end

  def verify_tests
    reporter.report(fingerprints.count) do
      fingerprints.each do |fp|
        reporter.print_name fp

        if fp.tests.length == 0
          warning = "'#{fp.name}' has no test cases"
          reporter.warning "WARN: #{warning}"
        end

        fp.tests.each do |test|
          m = test.match(fp.regex)
          unless m
            failure = "'#{fp.name}' failed to match #{test.inspect} with #{fp.regex.to_s}'"
            reporter.failure("FAIL: #{failure}")
          else
            info = { }
            fp.params.each_pair do |k,v|
              if v[0] == 0
                info[k] = v[1]
              else
                info[k] = m[ v[0] ]
                if m[ v[0] ].to_s.empty?
                  warning = "'#{fp.name}' failed to match #{test.inspect} key '#{k}'' with #{fp.regex.to_s}'"
                  reporter.warning "WARN: #{warning}"
                end					
              end
            end

            reporter.success(test)
          end
        end
      end
    end
  end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
recog-0.02 lib/recog/verifier.rb
recog-0.01 lib/recog/verifier.rb