Sha256: 927cc4148d12080c37808d9e1a329bf43a60ddc961f7cd3255f9a16db4246b99

Contents?: true

Size: 1.86 KB

Versions: 19

Compression:

Stored size: 1.86 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/file_serving/mount/plugins'

describe Puppet::FileServing::Mount::Plugins do
  before do
    @mount = Puppet::FileServing::Mount::Plugins.new("plugins")

    @environment = stub 'environment', :module => nil
    @request = stub 'request', :environment => @environment
  end

  describe  "when finding files" do
    it "should use the provided environment to find the modules" do
      @environment.expects(:modules).returns []

      @mount.find("foo", @request)
    end

    it "should return nil if no module can be found with a matching plugin" do
      mod = mock 'module'
      mod.stubs(:plugin).with("foo/bar").returns nil

      @environment.stubs(:modules).returns [mod]
      @mount.find("foo/bar", @request).should be_nil
    end

    it "should return the file path from the module" do
      mod = mock 'module'
      mod.stubs(:plugin).with("foo/bar").returns "eh"

      @environment.stubs(:modules).returns [mod]
      @mount.find("foo/bar", @request).should == "eh"
    end
  end

  describe "when searching for files" do
    it "should use the node's environment to find the modules" do
      @environment.expects(:modules).returns []

      @mount.search("foo", @request)
    end

    it "should return nil if no modules can be found that have plugins" do
      mod = mock 'module'
      mod.stubs(:plugins?).returns false

      @environment.stubs(:modules).returns []
      @mount.search("foo/bar", @request).should be_nil
    end

    it "should return the plugin paths for each module that has plugins" do
      one = stub 'module', :plugins? => true, :plugin_directory => "/one"
      two = stub 'module', :plugins? => true, :plugin_directory => "/two"

      @environment.stubs(:modules).returns [one, two]
      @mount.search("foo/bar", @request).should == %w{/one /two}
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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