Sha256: e3ad7b61a4d18f83a1901162fcc950ac9c05cecfd36d5f2132d8ccd38517d015

Contents?: true

Size: 1.92 KB

Versions: 22

Compression:

Stored size: 1.92 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 = FakeInput.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(Hx::Path::ALL) {}.should == @add
  end

  it "yields augmented paths from each_entry" do
    paths = Set[]
    @add.each_entry(Hx::Path::ALL) 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 = FakeInput.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(Hx::Path::ALL) {}.should == @strip
  end

  it "yields stripped paths from each_entry" do
    paths = Set[]
    @strip.each_entry(Hx::Path::ALL) do |path, entry|
      paths.add path
    end
    paths.should == @after_paths
  end
end

describe Hx::PathSubset do
  before(:each) do
    @source = FakeInput.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(Hx::Path::ALL) {}.should == @subset
  end

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hx-0.26.1 spec/pathops_spec.rb
hx-0.26.0 spec/pathops_spec.rb
hx-0.25.0 spec/pathops_spec.rb
hx-0.24.0 spec/pathops_spec.rb
hx-0.23.0 spec/pathops_spec.rb
hx-0.22.0 spec/pathops_spec.rb
hx-0.21.0 spec/pathops_spec.rb
hx-0.20.0 spec/pathops_spec.rb
hx-0.19.0 spec/pathops_spec.rb
hx-0.18.0 spec/pathops_spec.rb
hx-0.17.0 spec/pathops_spec.rb
hx-0.16.0 spec/pathops_spec.rb
hx-0.15.0 spec/pathops_spec.rb
hx-0.14.0 spec/pathops_spec.rb
hx-0.13.0 spec/pathops_spec.rb
hx-0.12.0 spec/pathops_spec.rb
hx-0.11.0 spec/pathops_spec.rb
hx-0.10.0 spec/pathops_spec.rb
hx-0.9.0 spec/pathops_spec.rb
hx-0.8.4 spec/pathops_spec.rb