Sha256: 31e455fef871c42d73fe24f384ee37de923f227e94330ba1aa111f435aad1259

Contents?: true

Size: 929 Bytes

Versions: 9

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/wildcards'

::RSpec.describe ::EacRubyUtils::Wildcards do
  describe '#match' do
    {
      'h*llo' => { 'hello' => true, 'hallo' => true, 'hxllo' => true, 'hillo' => true },
      'w?rld' => { 'world' => true, 'warld' => true, 'wzzrld' => false },
      'h*l?o' => { 'hello' => true, 'hallo' => true, 'hxxllo' => true, 'hilbbo' => false },
      '' => { '' => true, 'hello' => false },
      'hello' => { '' => false, 'hello' => true }
    }.each do |pattern, examples|
      context "when pattern is '#{pattern}'" do
        let(:instance) { described_class.new(pattern) }

        examples.each do |string, expected_result|
          context "when string is \"#{string}\"" do # rubocop:disable RSpec/NestedGroups
            it do
              expect(instance.match?(string)).to eq(expected_result)
            end
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
eac_tools-0.76.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb
eac_tools-0.76.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb
eac_tools-0.75.2 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb
eac_tools-0.75.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb
eac_tools-0.75.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb
eac_tools-0.74.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb
eac_tools-0.74.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb
eac_tools-0.73.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb
eac_tools-0.72.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/wildcards_spec.rb