Sha256: aeeb4ab69bd0bca2a8526467a1bfc3aee2e9fda411503c8d736cf7399aea58f6

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'helper'

class TestIdentity < MiniTest::Spec
  it %{determines whether two records COULD be identical} do
    i = FuzzyMatch::Identity.new %r{(A)[ ]*(\d)}
    i.identical?('A1', 'A     1foobar').must_equal true
  end
  
  it %{determines that two records MUST NOT be identical} do
    i = FuzzyMatch::Identity.new %r{(A)[ ]*(\d)}
    i.identical?('A1', 'A     2foobar').must_equal false
  end
  
  it %{returns nil indicating no information} do
    i = FuzzyMatch::Identity.new %r{(A)[ ]*(\d)}
    i.identical?('B1', 'A     2foobar').must_equal nil
  end

  it %{can be initialized with a regexp} do
    i = FuzzyMatch::Identity.new %r{\A\\?/(.*)etc/mysql\$$}
    i.regexp.must_equal %r{\A\\?/(.*)etc/mysql\$$}
  end
  
  it %{can be initialized from a string (via to_regexp gem)} do
    i = FuzzyMatch::Identity.new '%r{\A\\\?/(.*)etc/mysql\$$}'
    i.regexp.must_equal %r{\A\\?/(.*)etc/mysql\$$}

    i = FuzzyMatch::Identity.new '/\A\\\?\/(.*)etc\/mysql\$$/'
    i.regexp.must_equal %r{\A\\?/(.*)etc/mysql\$$}
  end
  
  it %{embraces case insensitivity} do
    i = FuzzyMatch::Identity.new %r{(A)[ ]*(\d)}i
    i.identical?('A1', 'a     1foobar').must_equal true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fuzzy_match-1.3.1 test/test_identity.rb
fuzzy_match-1.3.0 test/test_identity.rb