Sha256: ccfb090c8403faccc0399e7efc1c4bec8f7e80c275ef3e226b83e5dc680d8f90

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 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

8 entries across 8 versions & 1 rubygems

Version Path
puppet-0.25.5 spec/unit/file_collection/lookup.rb
puppet-0.25.4 spec/unit/file_collection/lookup.rb
puppet-0.25.3 spec/unit/file_collection/lookup.rb
puppet-0.24.9 spec/unit/file_collection/lookup.rb
puppet-0.25.2 spec/unit/file_collection/lookup.rb
puppet-0.25.1 spec/unit/file_collection/lookup.rb
puppet-0.25.0 spec/unit/file_collection/lookup.rb
puppet-0.24.8 spec/unit/file_collection/lookup.rb