Sha256: 8b16867162fcbc9ed417a825e75c5e7fbeb59c62e9618b4f24afe9fcafc16f58

Contents?: true

Size: 1.83 KB

Versions: 6

Compression:

Stored size: 1.83 KB

Contents

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

require 'set'
require 'hx'

describe Hx::AddPath do
  before(:each) do
    @before_paths = Set['foo', 'bar']
    @after_paths = Set['XXXfooYYY', 'XXXbarYYY']
    @source = FakeSource.new
    @source.add_entry('foo', 'FOO')
    @source.add_entry('bar', 'BAR')
    @add = Hx::AddPath.new(@source, :prefix => 'XXX', :suffix => 'YYY')
  end

  it "should return itself from each_entry" do
    @add.each_entry {}.should == @add
  end

  it "yields augmented paths from each_entry" do
    paths = Set[]
    @add.each_entry do |path, entry|
      paths.add path
    end
    paths.should == @after_paths
  end
end

describe Hx::StripPath do
  before(:each) do @before_paths = Set['XXXfooYYY', 'XXXbarYYY', 'lemur']
    @after_paths = Set['foo', 'bar']
    @source = FakeSource.new
    @source.add_entry('XXXfooYYY', 'FOO')
    @source.add_entry('XXXbarYYY', 'BAR')
    @strip = Hx::StripPath.new(@source, :prefix => 'XXX', :suffix => 'YYY')
  end

  it "should return itself from each_entry" do
    @strip.each_entry {}.should == @strip
  end

  it "yields stripped paths from each_entry" do
    paths = Set[]
    @strip.each_entry do |path, entry|
      paths.add path
    end
    paths.should == @after_paths
  end
end

describe Hx::PathSubset do
  before(:each) do
    @source = FakeSource.new
    @all_paths = Set['lemur', 'foo/bar', 'foo/baz', 'hoge/hoge']
    @all_paths.each do |path|
      @source.add_entry(path, path)
    end
    @subset = Hx::PathSubset.new(@source, :only => 'foo/*')
  end

  it "returns itself from each_entry" do
    @subset.each_entry {}.should == @subset
  end

  it "enumerates paths according to the subset filter" do
    actual_paths = Set[]
    @subset.each_entry do |path, entry|
      actual_paths.add path
    end
    actual_paths.should == Set['foo/bar', 'foo/baz']
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hx-0.6.1 spec/pathops_spec.rb
hx-0.6.0 spec/pathops_spec.rb
hx-0.5.0 spec/pathops_spec.rb
hx-0.4.1 spec/pathops_spec.rb
hx-0.3.3 spec/pathops_spec.rb
hx-0.3.2 spec/pathops_spec.rb