Sha256: 6bccf68fa1c273a5cdd49688cc68391199016e446736d43b1b8a929bb108f41a

Contents?: true

Size: 1.58 KB

Versions: 10

Compression:

Stored size: 1.58 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

require 'hx'

describe Hx::PathSubset::Predicate do
  it "accepts anything when the accept and reject patterns are nil" do
    filter = Hx::PathSubset::Predicate.new(nil, nil)
    filter.accept?("blah").should be_true
  end

  it "accepts only paths matching the accept pattern when it is specified" do
    filter = Hx::PathSubset::Predicate.new("foo", nil)
    filter.accept?("foo").should be_true
    filter.accept?("bar").should be_false
  end

  it "accepts only paths not matching reject, when only that is specified" do
    filter = Hx::PathSubset::Predicate.new(nil, "foo")
    filter.accept?("foo").should be_false
    filter.accept?("bar").should be_true
  end

  it "matches the difference of accept and reject when both are specified" do
    filter = Hx::PathSubset::Predicate.new("foo/*", "foo/bar")
    filter.accept?("foo/bar").should be_false
    filter.accept?("foo/baz").should be_true
    filter.accept?("bar").should be_false
  end

  it "shouldn't match across slashes with single star" do
    filter = Hx::PathSubset::Predicate.new("foo/*", nil)
    filter.accept?("bar").should be_false
    filter.accept?("foo").should be_false
    filter.accept?("foo/bar").should be_true
    filter.accept?("foo/bar/baz").should be_false
  end

  it "should match across slashes with double star" do
    filter = Hx::PathSubset::Predicate.new("foo/**", nil)
    filter.accept?("bar").should be_false
    filter.accept?("foo").should be_false
    filter.accept?("foo/bar").should be_true
    filter.accept?("foo/bar/baz").should be_true
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hx-0.7.4 spec/pathfilter_spec.rb
hx-0.7.2 spec/pathfilter_spec.rb
hx-0.7.1 spec/pathfilter_spec.rb
hx-0.7.0 spec/pathfilter_spec.rb
hx-0.6.1 spec/pathfilter_spec.rb
hx-0.6.0 spec/pathfilter_spec.rb
hx-0.5.0 spec/pathfilter_spec.rb
hx-0.4.1 spec/pathfilter_spec.rb
hx-0.3.3 spec/pathfilter_spec.rb
hx-0.3.2 spec/pathfilter_spec.rb