Sha256: 630f67ab74a99bc9c467c88d95dab094c9a43a68ad8a09a6df378d55492c9697

Contents?: true

Size: 1.62 KB

Versions: 27

Compression:

Stored size: 1.62 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

require 'puppet/file_collection'

describe Puppet::FileCollection do
  before do
    @collection = Puppet::FileCollection.new
  end

  it "should be able to convert a file name into an index" do
    @collection.index("/my/file").should be_instance_of(Fixnum)
  end

  it "should be able to convert an index into a file name" do
    index = @collection.index("/path/to/file")
    @collection.path(index).should == "/path/to/file"
  end

  it "should always give the same file name for a given index" do
    index = @collection.index("/path/to/file")
    @collection.path(index).should == @collection.path(index)
  end

  it "should always give the same index for a given file name" do
    @collection.index("/my/file").should == @collection.index("/my/file")
  end

  it "should always correctly relate a file name and its index even when multiple files are in the collection" do
    indexes = %w{a b c d e f}.inject({}) do |hash, letter|
      hash[letter] = @collection.index("/path/to/file/#{letter}")
      hash
    end

    indexes.each do |letter, index|
      @collection.index("/path/to/file/#{letter}").should == indexes[letter]
      @collection.path(index).should == @collection.path(index)
    end
  end

  it "should return nil as the file name when an unknown index is provided" do
    @collection.path(50).should be_nil
  end

  it "should provide a global collection" do
    Puppet::FileCollection.collection.should be_instance_of(Puppet::FileCollection)
  end

  it "should reuse the global collection" do
    Puppet::FileCollection.collection.should equal(Puppet::FileCollection.collection)
  end
end

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/file_collection_spec.rb
puppet-2.7.19 spec/unit/file_collection_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/file_collection_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
puppet-2.7.18 spec/unit/file_collection_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
puppet-2.7.17 spec/unit/file_collection_spec.rb
puppet-2.7.16 spec/unit/file_collection_spec.rb
puppet-2.7.14 spec/unit/file_collection_spec.rb
puppet-2.7.13 spec/unit/file_collection_spec.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
puppet-2.7.12 spec/unit/file_collection_spec.rb
puppet-2.7.11 spec/unit/file_collection_spec.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection_spec.rb