Sha256: 588062ad29eadd8bfe8c590146c5f3cd1a7c7bffa5fdc4f7efcdfacb9c63829c

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

#
# This set of tests ensures that the Puppetfile has been written correctly
# Anything relating to the syntax or content of the Puppetfile should be
# in this file
#
require 'r10k/puppetfile'

describe "The Puppetfile" do
  # Load in the Puppetfile using the r10k gem
  # This handles all of the parsing for us so that we don't need to write
  # complicated regular expressions or anything like that.
  @puppetfile = R10K::Puppetfile.new('./etc/puppetlabs/code/environments/production')
  @puppetfile.load!

  @puppetfile.modules.each do |current_module|
    describe current_module.name do
      #require 'pry'
      #binding.pry
      it "should be pinned to a version" do
        if current_module.is_a? R10K::Module::Git
          # It should be pinned to a version or commit
          semver_regex = /^v?\d+\.?\d*\.*\w*$/
          commit_regex = /^[0-9a-f]{7,40}$/
          expect(current_module.version).to match Regexp.union(semver_regex,commit_regex)
        else
          # If it's a forge module it should not be pinned to latest
          expect(current_module.instance_variable_get('@args')).not_to eq(:latest)
          # It should also not have blank args
          expect(current_module.instance_variable_get('@args')).not_to eq(nil)
        end
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
onceover-4.0.0 spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/03_puppetfile_spec_example.rb
onceover-3.22.0 spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/03_puppetfile_spec_example.rb