Sha256: 163d62b40281d5d1bd3c9a5cea0af34cf8a5a168f0e9d835e8e8d5ee487f559a

Contents?: true

Size: 1.2 KB

Versions: 19

Compression:

Stored size: 1.2 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../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

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.17 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.16 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.15 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.14 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.13 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.12 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.11 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.10 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.9 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.8 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.7 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.6 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.5 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.4 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.3 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.2 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.1 spec/unit/file_collection/lookup_spec.rb
puppet-2.6.0 spec/unit/file_collection/lookup_spec.rb