summaryrefslogtreecommitdiff
path: root/spec/bundler/quality_spec.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-01 12:49:40 +0300
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-09 12:44:10 +0900
commit8f37629519ad330032a38ac0e871b2912ed38a1b (patch)
treebb0529b77583d47993d8b0d608d68896aa3a5298 /spec/bundler/quality_spec.rb
parent66508992483ae5d77b56a98427c50c772341c0ac (diff)
Merge bundler master from upstream.
Pick from 8dd59e3ba97eb80a599f8149f31bf40773b69dc0
Diffstat (limited to 'spec/bundler/quality_spec.rb')
-rw-r--r--spec/bundler/quality_spec.rb23
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