mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
This is a first pass to improve the way errors are handled and raised in bundler's tests. The goal is to clean up tests and modernize them - these were some obvious areas that could be cleaned up. - Instead of raising "ZOMG" in the load error tests, it now tests for the actual error and gem raising. - Improve error messages where applicable. - All errors raise a specific error class, rather than falling back to a default and just setting a message. - Removed arguments and `bundle_dir` option from `TheBundle` class as it wasn't actually used so therefore we don't need to raise an error for extra arguments. - Removed error from `BundlerBuilder`, as it won't work if it's not `bundler`, also it never uses `name`. The only reaon `name` is passed in is because of metaprogramming on loading the right builder. I think that should eventually be refactored. - Replaced and removed `update_repo3` and `update_repo4` in favor of just `build_repo3` and `build_repo4`. Rather than tell someone writing tests to use a different method, automatically use the right method. https://github.com/ruby/rubygems/commit/68c39c8451
42 lines
716 B
Ruby
42 lines
716 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "path"
|
|
|
|
module Spec
|
|
class TheBundle
|
|
include Spec::Path
|
|
|
|
attr_accessor :bundle_dir
|
|
|
|
def initialize
|
|
@bundle_dir = Pathname.new(bundled_app)
|
|
end
|
|
|
|
def to_s
|
|
"the bundle"
|
|
end
|
|
alias_method :inspect, :to_s
|
|
|
|
def locked?
|
|
lockfile.file?
|
|
end
|
|
|
|
def lockfile
|
|
bundle_dir.join("Gemfile.lock")
|
|
end
|
|
|
|
def locked_gems
|
|
raise ArgumentError, "Cannot read lockfile if it doesn't exist" unless locked?
|
|
Bundler::LockfileParser.new(lockfile.read)
|
|
end
|
|
|
|
def locked_specs
|
|
locked_gems.specs.map(&:full_name)
|
|
end
|
|
|
|
def locked_platforms
|
|
locked_gems.platforms.map(&:to_s)
|
|
end
|
|
end
|
|
end
|