diff options
Diffstat (limited to 'spec/bundler/quality_spec.rb')
-rw-r--r-- | spec/bundler/quality_spec.rb | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb index ca622508c6..b8f2d6ed1b 100644 --- a/spec/bundler/quality_spec.rb +++ b/spec/bundler/quality_spec.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "set" + if defined?(Encoding) && Encoding.default_external.name != "UTF-8" # An approximation of ruby -E UTF-8, since it works on 1.8.7 Encoding.default_external = Encoding.find("UTF-8") @@ -171,7 +173,6 @@ RSpec.describe "The library itself" do forget_cli_options gem.coc gem.mit - github.https inline use_gem_version_promoter_for_major_updates ] @@ -225,9 +226,9 @@ RSpec.describe "The library itself" do end # there's no way around this warning - last_command.stderr.sub!(/^YAML safe loading.*/, "") + err.sub!(/^YAML safe loading.*/, "") - expect(last_command.stderr).to be_empty, "bundler should build as a gem without warnings, but\n#{err}" + expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}" ensure # clean up the .gem generated FileUtils.rm("bundler-#{Bundler::VERSION}.gem") @@ -273,4 +274,20 @@ RSpec.describe "The library itself" do expect(warnings).to be_well_formed end end + + it "does not use require internally, but require_relative" do + Dir.chdir(root) do + exempt = %r{templates/|vendor/} + all_bad_requires = [] + lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib` + lib_files.split("\x0").each do |filename| + next if filename =~ exempt + File.readlines(filename).each_with_index do |line, number| + line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" } + end + end + + expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}" + end + end end |