Sha256: 82064fca291485aaf17a9bf5ce81599d16b08502cd3bbb446f37905875579633

Contents?: true

Size: 1.76 KB

Versions: 57

Compression:

Stored size: 1.76 KB

Contents

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

require 'puppet/indirector/file_metadata/file'

describe Puppet::Indirector::FileMetadata::File do
  it "should be registered with the file_metadata indirection" do
    Puppet::Indirector::Terminus.terminus_class(:file_metadata, :file).should equal(Puppet::Indirector::FileMetadata::File)
  end

  it "should be a subclass of the DirectFileServer terminus" do
    Puppet::Indirector::FileMetadata::File.superclass.should equal(Puppet::Indirector::DirectFileServer)
  end

  describe "when creating the instance for a single found file" do
    before do
      @metadata = Puppet::Indirector::FileMetadata::File.new
      @path = File.expand_path('/my/local')
      @uri = Puppet::Util.path_to_uri(@path).to_s
      @data = mock 'metadata'
      @data.stubs(:collect)
      Puppet::FileSystem.expects(:exist?).with(@path).returns true

      @request = Puppet::Indirector::Request.new(:file_metadata, :find, @uri, nil)
    end

    it "should collect its attributes when a file is found" do
      @data.expects(:collect)

      Puppet::FileServing::Metadata.expects(:new).returns(@data)
      @metadata.find(@request).should == @data
    end
  end

  describe "when searching for multiple files" do
    before do
      @metadata = Puppet::Indirector::FileMetadata::File.new
      @path = File.expand_path('/my/local')
      @uri = Puppet::Util.path_to_uri(@path).to_s

      @request = Puppet::Indirector::Request.new(:file_metadata, :find, @uri, nil)
    end

    it "should collect the attributes of the instances returned" do
      Puppet::FileSystem.expects(:exist?).with(@path).returns true
      @metadata.expects(:path2instances).returns( [mock("one", :collect => nil), mock("two", :collect => nil)] )
      @metadata.search(@request)
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.6 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.5 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.4 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.3 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.2 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.1 spec/unit/indirector/file_metadata/file_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/indirector/file_metadata/file_spec.rb