Sha256: 172c3f6f8023777bcfa3bec813a7a1645657147d72b732ba45df2a1904bf2793

Contents?: true

Size: 1.83 KB

Versions: 35

Compression:

Stored size: 1.83 KB

Contents

#!/usr/bin/env rspec
require '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

35 entries across 35 versions & 3 rubygems

Version Path
puppet-2.7.26 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.25 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.24 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.23 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.22 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.21 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.20 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.20.rc1 spec/unit/file_serving/mount/plugins_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.19 spec/unit/file_serving/mount/plugins_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/plugins_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/file_serving/mount/plugins_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.18 spec/unit/file_serving/mount/plugins_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/plugins_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.17 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.16 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.14 spec/unit/file_serving/mount/plugins_spec.rb
puppet-2.7.13 spec/unit/file_serving/mount/plugins_spec.rb