Sha256: 9fa03e8aa07c2e85d175508417ebc3c3cc3ba8c283b4262cb71303158d4e30cc

Contents?: true

Size: 1.6 KB

Versions: 340

Compression:

Stored size: 1.6 KB

Contents

require 'puppet/util/json'

module PuppetSpec
  module ModuleTool
    module SharedFunctions
      def remote_release(name, version)
        remote_source.available_releases[name][version]
      end

      def preinstall(name, version, options = { :into => primary_dir })
        release = remote_release(name, version)
        raise "Could not preinstall #{name} v#{version}" if release.nil?

        name = release.name[/-(.*)/, 1]
        moddir = File.join(options[:into], name)
        FileUtils.mkdir_p(moddir)
        File.open(File.join(moddir, 'metadata.json'), 'w') do |file|
          file.puts(Puppet::Util::Json.dump(release.metadata))
        end
      end

      def mark_changed(path)
        app = Puppet::ModuleTool::Applications::Checksummer
        allow(app).to receive(:run).with(path).and_return(['README'])
      end

      def graph_should_include(name, options)
        releases = flatten_graph(subject[:graph] || [])
        release = releases.find { |x| x[:name] == name }

        if options.nil?
          expect(release).to be_nil
        else
          from = options.keys.find { |k| k.nil? || k.is_a?(SemanticPuppet::Version) }
          to   = options.delete(from)

          if to or from
            options[:previous_version] ||= from
            options[:version] ||= to
          end

          expect(release).not_to be_nil
          expect(release).to include options
        end
      end

      def flatten_graph(graph)
        graph + graph.map { |sub| flatten_graph(sub[:dependencies]) }.flatten
      end

      def v(str)
        SemanticPuppet::Version.parse(str)
      end
    end
  end
end

Version data entries

340 entries across 340 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.3.0-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.3.0-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.3.0-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.4.0 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.4.0-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.4.0-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.4.0-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-7.28.0 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-7.28.0-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-7.28.0-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-7.28.0-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.3.1 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.3.1-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.3.1-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-8.3.1-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-7.27.0 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-7.27.0-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-7.27.0-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-7.27.0-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb