Sha256: ccf0baff114b67b857b64bbf943a1b9a5918c2b4cef60a490d7d2593b9f68f28

Contents?: true

Size: 1.17 KB

Versions: 27

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'
require 'puppet/file_collection/lookup'

class LookupTester
  include Puppet::FileCollection::Lookup
end

describe Puppet::FileCollection::Lookup do
  before do
    @tester = LookupTester.new

    @file_collection = mock 'file_collection'
    Puppet::FileCollection.stubs(:collection).returns @file_collection
  end

  it "should use the file collection to determine the index of the file name" do
    @file_collection.expects(:index).with("/my/file").returns 50

    @tester.file = "/my/file"
    @tester.file_index.should == 50
  end

  it "should return nil as the file name if no index is set" do
    @tester.file.should be_nil
  end

  it "should use the file collection to convert the index to a file name" do
    @file_collection.expects(:path).with(25).returns "/path/to/file"

    @tester.file_index = 25

    @tester.file.should == "/path/to/file"
  end

  it "should support a line attribute" do
    @tester.line = 50
    @tester.line.should == 50
  end

  it "should default to the global file collection" do
    Puppet::FileCollection.expects(:collection).returns "collection"
    @tester.file_collection.should == "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/lookup_spec.rb
puppet-2.7.19 spec/unit/file_collection/lookup_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/file_collection/lookup_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
puppet-2.7.18 spec/unit/file_collection/lookup_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
puppet-2.7.17 spec/unit/file_collection/lookup_spec.rb
puppet-2.7.16 spec/unit/file_collection/lookup_spec.rb
puppet-2.7.14 spec/unit/file_collection/lookup_spec.rb
puppet-2.7.13 spec/unit/file_collection/lookup_spec.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
puppet-2.7.12 spec/unit/file_collection/lookup_spec.rb
puppet-2.7.11 spec/unit/file_collection/lookup_spec.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_collection/lookup_spec.rb