summaryrefslogtreecommitdiff
path: root/spec/bundler/quality_spec.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 14:19:04 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-13 07:54:37 +0900
commit0e60b59d5884edb8f9aea023efd9b24f1ff02049 (patch)
treee52935ce510440872ca5ce6b0e092cbc94f18bc9 /spec/bundler/quality_spec.rb
parent68224651a4d4dc3ce0cea666f5423dd8b6ba6cfc (diff)
Update the bundler version with master branch
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3086
Diffstat (limited to 'spec/bundler/quality_spec.rb')
-rw-r--r--spec/bundler/quality_spec.rb133
1 files changed, 56 insertions, 77 deletions
diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb
index 09e59d88ae..177eb505a1 100644
--- a/spec/bundler/quality_spec.rb
+++ b/spec/bundler/quality_spec.rb
@@ -107,12 +107,10 @@ RSpec.describe "The library itself" do
it "has no malformed whitespace" do
exempt = /\.gitmodules|fixtures|vendor|LICENSE|vcr_cassettes|rbreadline\.diff|\.txt$/
error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_tab_characters(filename)
- error_messages << check_for_extra_spaces(filename)
- end
+ tracked_files.each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_tab_characters(filename)
+ error_messages << check_for_extra_spaces(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -120,11 +118,9 @@ RSpec.describe "The library itself" do
it "has no estraneous quotes" do
exempt = /vendor|vcr_cassettes|LICENSE|rbreadline\.diff/
error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_straneous_quotes(filename)
- end
+ tracked_files.each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_straneous_quotes(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -132,11 +128,9 @@ RSpec.describe "The library itself" do
it "does not include any leftover debugging or development mechanisms" do
exempt = %r{quality_spec.rb|support/helpers|vcr_cassettes|\.md|\.ronn|\.txt|\.5|\.1}
error_messages = []
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_debugging_mechanisms(filename)
- end
+ tracked_files.each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_debugging_mechanisms(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -144,11 +138,9 @@ RSpec.describe "The library itself" do
it "does not include any unresolved merge conflicts" do
error_messages = []
exempt = %r{lock/lockfile_spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb}
- Dir.chdir(root) do
- tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_git_merge_conflicts(filename)
- end
+ tracked_files.each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_git_merge_conflicts(filename)
end
expect(error_messages.compact).to be_well_formed
end
@@ -156,32 +148,27 @@ RSpec.describe "The library itself" do
it "maintains language quality of the documentation" do
included = /ronn/
error_messages = []
- Dir.chdir(root) do
- `git ls-files -z -- man`.split("\x0").each do |filename|
- next unless filename =~ included
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
+ man_tracked_files.each do |filename|
+ next unless filename =~ included
+ error_messages << check_for_expendable_words(filename)
+ error_messages << check_for_specific_pronouns(filename)
end
expect(error_messages.compact).to be_well_formed
end
it "maintains language quality of sentences used in source code" do
error_messages = []
- exempt = /vendor|vcr_cassettes/
- Dir.chdir(root) do
- lib_tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- error_messages << check_for_expendable_words(filename)
- error_messages << check_for_specific_pronouns(filename)
- end
+ exempt = /vendor|vcr_cassettes|CODE_OF_CONDUCT/
+ lib_tracked_files.each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_expendable_words(filename)
+ error_messages << check_for_specific_pronouns(filename)
end
expect(error_messages.compact).to be_well_formed
end
it "documents all used settings" do
exemptions = %w[
- auto_config_jobs
deployment_means_frozen
forget_cli_options
gem.coc
@@ -197,15 +184,13 @@ RSpec.describe "The library itself" do
Bundler::Settings::NUMBER_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::NUMBER_KEYS" }
Bundler::Settings::ARRAY_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::ARRAY_KEYS" }
- Dir.chdir(root) do
- key_pattern = /([a-z\._-]+)/i
- lib_tracked_files.split("\x0").each do |filename|
- each_line(filename) do |line, number|
- line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" }
- end
+ key_pattern = /([a-z\._-]+)/i
+ lib_tracked_files.each do |filename|
+ each_line(filename) do |line, number|
+ line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" }
end
- documented_settings = File.read("man/bundle-config.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten
end
+ documented_settings = File.read("man/bundle-config.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten
documented_settings.each do |s|
all_settings.delete(s)
@@ -231,54 +216,48 @@ RSpec.describe "The library itself" do
end
it "ships the correct set of files" do
- Dir.chdir(root) do
- git_list = shipped_files.split("\x0")
+ git_list = shipped_files
- gem_list = Gem::Specification.load(gemspec.to_s).files
+ gem_list = Gem::Specification.load(gemspec.to_s).files
- expect(git_list.to_set).to eq(gem_list.to_set)
- end
+ expect(git_list.to_set).to eq(gem_list.to_set)
end
it "does not contain any warnings" do
- Dir.chdir(root) do
- exclusions = %w[
- lib/bundler/capistrano.rb
- lib/bundler/deployment.rb
- lib/bundler/gem_tasks.rb
- lib/bundler/vlad.rb
- lib/bundler/templates/gems.rb
- ]
- files_to_require = lib_tracked_files.split("\x0").grep(/\.rb$/) - exclusions
- files_to_require.reject! {|f| f.start_with?("lib/bundler/vendor") }
- files_to_require.map! {|f| f.chomp(".rb") }
- sys_exec!("ruby -w -Ilib") do |input, _, _|
- files_to_require.each do |f|
- input.puts "require '#{f.sub(%r{\Alib/}, "")}'"
- end
+ exclusions = %w[
+ lib/bundler/capistrano.rb
+ lib/bundler/deployment.rb
+ lib/bundler/gem_tasks.rb
+ lib/bundler/vlad.rb
+ lib/bundler/templates/gems.rb
+ ]
+ files_to_require = lib_tracked_files.grep(/\.rb$/) - exclusions
+ files_to_require.reject! {|f| f.start_with?("lib/bundler/vendor") }
+ files_to_require.map! {|f| File.expand_path("../#{f}", __dir__) }
+ sys_exec!("ruby -w") do |input, _, _|
+ files_to_require.each do |f|
+ input.puts "require '#{f}'"
end
+ end
- warnings = last_command.stdboth.split("\n")
- # ignore warnings around deprecated Object#=~ method in RubyGems
- warnings.reject! {|w| w =~ %r{rubygems\/version.rb.*deprecated\ Object#=~} }
+ warnings = last_command.stdboth.split("\n")
+ # ignore warnings around deprecated Object#=~ method in RubyGems
+ warnings.reject! {|w| w =~ %r{rubygems\/version.rb.*deprecated\ Object#=~} }
- expect(warnings).to be_well_formed
- end
+ expect(warnings).to be_well_formed
end
it "does not use require internally, but require_relative" do
- Dir.chdir(root) do
- exempt = %r{templates/|vendor/}
- all_bad_requires = []
- lib_tracked_files.split("\x0").each do |filename|
- next if filename =~ exempt
- each_line(filename) do |line, number|
- line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
- end
+ exempt = %r{templates/|vendor/}
+ all_bad_requires = []
+ lib_tracked_files.each do |filename|
+ next if filename =~ exempt
+ each_line(filename) do |line, number|
+ line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
end
-
- expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}"
end
+
+ expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}"
end
private