Sha256: 4513a1975cf4b4418048d753d75eb44bbc3f459ba8c7ebadcfb015bd2b351ec9

Contents?: true

Size: 1.95 KB

Versions: 23

Compression:

Stored size: 1.95 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'
require 'puppet/file_serving/mount/modules'

describe Puppet::FileServing::Mount::Modules do
  before do
    @mount = Puppet::FileServing::Mount::Modules.new("modules")

    @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 module" do
      @environment.expects(:module)

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

    it "should treat the first field of the relative path as the module name" do
      @environment.expects(:module).with("foo")
      @mount.find("foo/bar/baz", @request)
    end

    it "should return nil if the specified module does not exist" do
      @environment.expects(:module).with("foo").returns nil
      @mount.find("foo/bar/baz", @request)
    end

    it "should return the file path from the module" do
      mod = mock 'module'
      mod.expects(:file).with("bar/baz").returns "eh"
      @environment.expects(:module).with("foo").returns mod
      @mount.find("foo/bar/baz", @request).should == "eh"
    end
  end

  describe "when searching for files" do
    it "should use the node's environment to search the module" do
      @environment.expects(:module)

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

    it "should treat the first field of the relative path as the module name" do
      @environment.expects(:module).with("foo")
      @mount.search("foo/bar/baz", @request)
    end

    it "should return nil if the specified module does not exist" do
      @environment.expects(:module).with("foo").returns nil
      @mount.search("foo/bar/baz", @request)
    end

    it "should return the file path as an array from the module" do
      mod = mock 'module'
      mod.expects(:file).with("bar/baz").returns "eh"
      @environment.expects(:module).with("foo").returns mod
      @mount.search("foo/bar/baz", @request).should == ["eh"]
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.17 spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.16 spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.14 spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.13 spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.12 spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.11 spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.9 spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.8 spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.6 spec/unit/file_serving/mount/modules_spec.rb
puppet-2.7.5 spec/unit/file_serving/mount/modules_spec.rb