Sha256: 8e00cf39f058c344980eaf9241572fe80c08b1ae4f4e737637cf8fba925e786e
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
class BundlerFixture attr_reader :dir def initialize @dir = File.join(Dir.tmpdir, 'fake_project_root') FileUtils.makedirs @dir end def clean_up FileUtils.rmtree @dir end def create_lockfile(gem_specs:) dir = @dir index = Bundler::Index.new deps = [] gem_specs.each do |g| index << g deps << Bundler::DepProxy.new(Bundler::Dependency.new(g.name, g.version), g.platform) end spec_set = Bundler::Resolver.resolve(deps, index) sources = Bundler::SourceList.new sources.add_rubygems_remote('https://rubygems.org') spec_set.each { |s| s.source = sources.rubygems_sources.first } gemfile_fn = File.join(dir, 'Gemfile.lock') defn = Bundler::Definition.new(gemfile_fn, deps.map(&:dep), sources, true) defn.instance_variable_set('@index', index) defn.instance_variable_set('@resolve', spec_set) defn.lock(gemfile_fn) end def create_spec(name, version, dependencies={}) Gem::Specification.new do |s| s.name = name s.version = Gem::Version.new(version) s.platform = 'ruby' dependencies.each do |name, requirement| s.add_dependency name, requirement end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bundler-advise-1.0.1 | spec/fixture/bundler_fixture.rb |