Sha256: b9436788a9152e96c7fa49a5eb4daefad420258632c4b1a69f449386aa434434

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

#! /usr/bin/env ruby -S rspec
require 'spec_helper'

require 'puppet_spec/files'

describe Puppet::Node::Environment do
  include PuppetSpec::Files

  it "should be able to return each module from its environment with the environment, name, and path set correctly" do
    base = tmpfile("env_modules")
    Dir.mkdir(base)

    dirs = []
    mods = {}
    %w{1 2}.each do |num|
      dir = File.join(base, "dir#{num}")
      dirs << dir
      Dir.mkdir(dir)
      mod = "mod#{num}"
      moddir = File.join(dir, mod)
      mods[mod] = moddir
      Dir.mkdir(moddir)
    end

    environment = Puppet::Node::Environment.new("foo")
    environment.stubs(:modulepath).returns dirs

    environment.modules.each do |mod|
      mod.environment.should == environment
      mod.path.should == mods[mod.name]
    end
  end

  it "should not yield the same module from different module paths" do
    base = tmpfile("env_modules")
    Dir.mkdir(base)

    dirs = []
    mods = {}
    %w{1 2}.each do |num|
      dir = File.join(base, "dir#{num}")
      dirs << dir
      Dir.mkdir(dir)
      mod = "mod"
      moddir = File.join(dir, mod)
      mods[mod] = moddir
      Dir.mkdir(moddir)
    end

    environment = Puppet::Node::Environment.new("foo")
    environment.stubs(:modulepath).returns dirs

    mods = environment.modules
    mods.length.should == 1
    mods[0].path.should == File.join(base, "dir1", "mod")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-3.0.0.rc8 spec/integration/node/environment_spec.rb
puppet-3.0.0.rc7 spec/integration/node/environment_spec.rb
puppet-3.0.0.rc5 spec/integration/node/environment_spec.rb
puppet-3.0.0.rc4 spec/integration/node/environment_spec.rb