Sha256: 7ab1b27bc78facf50c734e6e4e98e54288e6715730c59b5923c25d776e0a6e1b

Contents?: true

Size: 1.57 KB

Versions: 112

Compression:

Stored size: 1.57 KB

Contents

require '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(JSON.generate(release.metadata))
        end
      end

      def mark_changed(path)
        app = Puppet::ModuleTool::Applications::Checksummer
        app.stubs(:run).with(path).returns(['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

112 entries across 112 versions & 1 rubygems

Version Path
puppet-5.3.7 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.3.7-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.3.7-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.3.7-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.10.12 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.10.12-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.10.12-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.10.12-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.10.11 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.10.11-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.10.11-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.10.11-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.3.6 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.3.6-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.3.6-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.3.6-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.4.0 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.4.0-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.4.0-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-5.4.0-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb