Sha256: c423e189b10a284ab4b3d35c2f8549454fa0adc3d51f8745c2d59b84f6bc87fe

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'recog/db'

describe Recog::DB do
  Dir[File.expand_path File.join('xml', '*.xml')].each do |xml_file_name|

    describe "##{File.basename(xml_file_name)}" do

      db = Recog::DB.new(xml_file_name)

      it "has a match key" do
        expect(db.match_key).not_to be_nil
        expect(db.match_key).not_to be_empty
      end

      db.fingerprints.each do |fp|

        context "#{fp.regex}" do

          if fp.name.nil? || fp.name.empty?
            skip "has a name"
          end

          # Not yet enforced
          # it "has a name" do
          #   expect(fp.name).not_to be_nil
          #   expect(fp.name).not_to be_empty
          # end

          it "has a regex" do
            expect(fp.regex).not_to be_nil
            expect(fp.regex.class).to be ::Regexp
          end

          # Not yet enforced
          # it "has test cases" do
          #  expect(fp.tests.length).not_to equal(0)
          # end

          fp.tests.each do |example|
            it "passes self-test #{example.content.gsub(/\s+/, ' ')[0,32]}..." do
              expect(fp.match(example.content)).to_not be_nil
            end
          end

        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recog-1.0.0 spec/lib/fingerprint_self_test_spec.rb