Sha256: a715547f6c3454f5e159ec1067f5995187659c8369016790d8c33bc34542dc60

Contents?: true

Size: 1.55 KB

Versions: 86

Compression:

Stored size: 1.55 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?(Semantic::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)
        Semantic::Version.parse(str)
      end
    end
  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
puppet-4.8.2 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.2-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.2-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.2-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.7.1 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.7.1-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.7.1-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.7.1-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.1 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.1-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.1-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.1-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.0 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.0-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.0-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.8.0-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.7.0 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.7.0-x86-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.7.0-x64-mingw32 spec/lib/puppet_spec/module_tool/shared_functions.rb
puppet-4.7.0-universal-darwin spec/lib/puppet_spec/module_tool/shared_functions.rb