diff options
Diffstat (limited to 'spec/quality_spec.rb')
-rw-r--r-- | spec/quality_spec.rb | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 3ddc775fae..87279ebb74 100644 --- a/spec/quality_spec.rb +++ b/spec/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") @@ -97,7 +99,7 @@ RSpec.describe "The library itself" do end it "has no malformed whitespace" do - exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|vcr_cassettes/ + exempt = /\.gitmodules|\.marshal|fixtures|vendor|LICENSE|vcr_cassettes/ error_messages = [] Dir.chdir(root) do lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib` @@ -167,16 +169,13 @@ RSpec.describe "The library itself" do exemptions = %w[ auto_config_jobs cache_command_is_package - console_command deployment_means_frozen forget_cli_options gem.coc gem.mit github.https inline - lockfile_uses_separate_rubygems_sources use_gem_version_promoter_for_major_updates - viz_command ] all_settings = Hash.new {|h, k| h[k] = [] } @@ -228,9 +227,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") @@ -238,7 +237,7 @@ RSpec.describe "The library itself" do end end - it "ships the correct set of files" do + it "ships the correct set of files", :ruby_repo do Dir.chdir(root) do git_list = IO.popen("git ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) } git_list += %w[CHANGELOG.md LICENSE.md README.md bundler.gemspec] @@ -276,4 +275,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 |