Sha256: 3ada3ff3d568de00d7416c41a19fead8f0139c64303a7075223e2e51342b776c

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

module DependencyHelpers
  def build_gem(gem_name, version = '1.0.0')
    ENV['GEM_HOME'] = TMP_GEM_ROOT

    unless File.exist? "tmp/gems/gems/#{gem_name}-#{version}"
      FileUtils.mkdir_p "tmp/gems/#{gem_name}/lib"

      FileUtils.cd "tmp/gems/#{gem_name}" do
        gemspec = "#{gem_name}.gemspec"
        lib_file = "lib/#{gem_name}.rb"

        File.open gemspec, 'w' do |file|
          file.puts <<-gemspec
            Gem::Specification.new do |s|
              s.name    = #{gem_name.inspect}
              s.version = #{version.inspect}
              s.authors = 'Mr. Smith'
              s.summary = 'summary'
              s.files   = #{lib_file.inspect}
            end
          gemspec
        end

        File.open lib_file, 'w' do |file|
          file.puts "$#{gem_name}_version = '#{version}'"
        end

        `gem build #{gemspec} 2>&1`
        `gem install -lN #{gem_name}-#{version}.gem -v #{version} 2>&1`
      end
    end
  end

  def build_gems(gems)
    gems.each { |gem| build_gem(gem) }
  end

  def build_git_gem(gem_name, version = '1.0.0')
    build_gem gem_name, version

    Dir.chdir "tmp/gems/#{gem_name}" do
      `git init .`
      `git config user.email "appraisal@thoughtbot.com"`
      `git config user.name "Appraisal"`
      `git add .`
      `git commit -a -m "initial commit"`
    end

    # Cleanup Bundler cache path manually for now
    git_cache_path = File.join(ENV["GEM_HOME"], "cache", "bundler", "git")

    Dir[File.join(git_cache_path, "#{gem_name}-*")].each do |path|
      FileUtils.rm_r(path)
    end
  end

  def build_git_gems(gems)
    gems.each { |gem| build_git_gem(gem) }
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/appraisal-2.5.0/spec/support/dependency_helpers.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/appraisal-2.5.0/spec/support/dependency_helpers.rb
appraisal-2.5.0 spec/support/dependency_helpers.rb
appraisal-2.4.1 spec/support/dependency_helpers.rb
appraisal-2.4.0 spec/support/dependency_helpers.rb
appraisal-2.3.0 spec/support/dependency_helpers.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/appraisal-2.2.0/spec/support/dependency_helpers.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/appraisal-2.2.0/spec/support/dependency_helpers.rb
appraisal-2.2.0 spec/support/dependency_helpers.rb