diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-01 23:29:38 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-01 23:29:38 +0000 |
commit | be7b5929126cb3e696ef222339237faba9b8fe5a (patch) | |
tree | 51eae376f93c09bc82dde5a657a91df2c89062e4 /spec/bundler/quality_spec.rb | |
parent | ae49dbd392083f69026f2a0fff4a1d5f42d172a7 (diff) | |
download | ruby-be7b5929126cb3e696ef222339237faba9b8fe5a.tar.gz |
Update bundled bundler to 1.16.0.
* lib/bundler, spec/bundler: Merge bundler-1.16.0.
* common.mk: rspec examples of bundler-1.16.0 needs require option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/quality_spec.rb')
-rw-r--r-- | spec/bundler/quality_spec.rb | 105 |
1 files changed, 47 insertions, 58 deletions
diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb index b87b4a0731..9fc03b486b 100644 --- a/spec/bundler/quality_spec.rb +++ b/spec/bundler/quality_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -require "spec_helper" if defined?(Encoding) && Encoding.default_external.name != "UTF-8" # Poor man's ruby -E UTF-8, since it works on 1.8.7 @@ -7,17 +6,6 @@ if defined?(Encoding) && Encoding.default_external.name != "UTF-8" end RSpec.describe "The library itself" do - def check_for_spec_defs_with_single_quotes(filename) - failing_lines = [] - - File.readlines(filename).each_with_index do |line, number| - failing_lines << number + 1 if line =~ /^ *(describe|it|context) {1}'{1}/ - end - - return if failing_lines.empty? - "#{filename} uses inconsistent single quotes on lines #{failing_lines.join(", ")}" - end - def check_for_debugging_mechanisms(filename) debugging_mechanisms_regex = / (binding\.pry)| @@ -67,7 +55,7 @@ RSpec.describe "The library itself" do failing_lines = [] File.readlines(filename).each_with_index do |line, number| next if line =~ /^\s+#.*\s+\n$/ - next if %w(LICENCE.md).include?(line) + next if %w[LICENCE.md].include?(line) failing_lines << number + 1 if line =~ /\s+\n$/ end @@ -77,7 +65,7 @@ RSpec.describe "The library itself" do def check_for_expendable_words(filename) failing_line_message = [] - useless_words = %w( + useless_words = %w[ actually basically clearly @@ -85,12 +73,12 @@ RSpec.describe "The library itself" do obviously really simply - ) + ] pattern = /\b#{Regexp.union(useless_words)}\b/i File.readlines(filename).each_with_index do |line, number| next unless word_found = pattern.match(line) - failing_line_message << "#{filename} has '#{word_found}' on line #{number + 1}. Avoid using these kinds of weak modifiers." + failing_line_message << "#{filename}:#{number.succ} has '#{word_found}'. Avoid using these kinds of weak modifiers." end failing_line_message unless failing_line_message.empty? @@ -102,7 +90,7 @@ RSpec.describe "The library itself" do File.readlines(filename).each_with_index do |line, number| next unless word_found = specific_pronouns.match(line) - failing_line_message << "#{filename} has '#{word_found}' on line #{number + 1}. Use more generic pronouns in documentation." + failing_line_message << "#{filename}:#{number.succ} has '#{word_found}'. Use more generic pronouns in documentation." end failing_line_message unless failing_line_message.empty? @@ -117,9 +105,9 @@ RSpec.describe "The library itself" do end it "has no malformed whitespace", :ruby_repo do - exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE/ + exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|vcr_cassettes/ error_messages = [] - Dir.chdir(File.expand_path("../..", __FILE__)) do + Dir.chdir(root) do `git ls-files -z`.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_tab_characters(filename) @@ -129,22 +117,10 @@ RSpec.describe "The library itself" do expect(error_messages.compact).to be_well_formed end - it "uses double-quotes consistently in specs", :ruby_repo do - included = /spec/ - error_messages = [] - Dir.chdir(File.expand_path("../", __FILE__)) do - `git ls-files -z`.split("\x0").each do |filename| - next unless filename =~ included - error_messages << check_for_spec_defs_with_single_quotes(filename) - end - end - expect(error_messages.compact).to be_well_formed - end - it "does not include any leftover debugging or development mechanisms", :ruby_repo do - exempt = %r{quality_spec.rb|support/helpers} + exempt = %r{quality_spec.rb|support/helpers|vcr_cassettes|\.md|\.ronn} error_messages = [] - Dir.chdir(File.expand_path("../", __FILE__)) do + Dir.chdir(root) do `git ls-files -z`.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_debugging_mechanisms(filename) @@ -155,8 +131,8 @@ RSpec.describe "The library itself" do it "does not include any unresolved merge conflicts", :ruby_repo do error_messages = [] - exempt = %r{lock/lockfile_spec|quality_spec} - Dir.chdir(File.expand_path("../", __FILE__)) do + exempt = %r{lock/lockfile_(bundler_1_)?spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb} + Dir.chdir(root) do `git ls-files -z`.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_git_merge_conflicts(filename) @@ -168,8 +144,8 @@ RSpec.describe "The library itself" do it "maintains language quality of the documentation", :ruby_repo do included = /ronn/ error_messages = [] - Dir.chdir(File.expand_path("../../man", __FILE__)) do - `git ls-files -z`.split("\x0").each do |filename| + 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) @@ -181,8 +157,8 @@ RSpec.describe "The library itself" do it "maintains language quality of sentences used in source code", :ruby_repo do error_messages = [] exempt = /vendor/ - Dir.chdir(File.expand_path("../../lib", __FILE__)) do - `git ls-files -z`.split("\x0").each do |filename| + Dir.chdir(root) do + `git ls-files -z -- lib`.split("\x0").each do |filename| next if filename =~ exempt error_messages << check_for_expendable_words(filename) error_messages << check_for_specific_pronouns(filename) @@ -192,27 +168,34 @@ RSpec.describe "The library itself" do end it "documents all used settings", :ruby_repo do - exemptions = %w( + exemptions = %w[ + cache_command_is_package + console_command + default_cli_command + deployment_means_frozen + forget_cli_options gem.coc gem.mit inline + lockfile_uses_separate_rubygems_sources warned_version - ) + ] all_settings = Hash.new {|h, k| h[k] = [] } documented_settings = exemptions Bundler::Settings::BOOL_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::BOOL_KEYS" } 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(File.expand_path("../../lib", __FILE__)) do + Dir.chdir(root) do key_pattern = /([a-z\._-]+)/i - `git ls-files -z`.split("\x0").each do |filename| + `git ls-files -z -- lib`.split("\x0").each do |filename| File.readlines(filename).each_with_index do |line, number| - line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `lib/#{filename}:#{number.succ}`" } + line.scan(/Bundler\.settings\[:#{key_pattern}\]/).flatten.each {|s| all_settings[s] << "referenced at `#{filename}:#{number.succ}`" } end end - documented_settings = File.read("../man/bundle-config.ronn").scan(/^\* `#{key_pattern}`/).flatten + documented_settings = File.read("man/bundle-config.ronn")[/LIST OF AVAILABLE KEYS.*/m].scan(/^\* `#{key_pattern}`/).flatten end documented_settings.each {|s| all_settings.delete(s) } @@ -222,6 +205,8 @@ RSpec.describe "The library itself" do end expect(error_messages.sort).to be_well_formed + + expect(documented_settings).to be_sorted end it "can still be built", :ruby_repo do @@ -229,9 +214,12 @@ RSpec.describe "The library itself" do begin gem_command! :build, "bundler.gemspec" if Bundler.rubygems.provides?(">= 2.4") + # there's no way aroudn this warning + last_command.stderr.sub!(/^YAML safe loading.*/, "") + # older rubygems have weird warnings, and we won't actually be using them # to build the gem for releases anyways - expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}" + expect(last_command.stderr).to be_empty, "bundler should build as a gem without warnings, but\n#{err}" end ensure # clean up the .gem generated @@ -241,23 +229,24 @@ RSpec.describe "The library itself" do end it "does not contain any warnings", :ruby_repo do - Dir.chdir(root.join("lib")) do - exclusions = %w( - bundler/capistrano.rb - bundler/gem_tasks.rb - bundler/vlad.rb - ) - lib_files = `git ls-files -z`.split("\x0").grep(/\.rb$/) - exclusions - lib_files.reject! {|f| f.start_with?("bundler/vendor") } + 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 + ] + lib_files = `git ls-files -z -- lib`.split("\x0").grep(/\.rb$/) - exclusions + lib_files.reject! {|f| f.start_with?("lib/bundler/vendor") } lib_files.map! {|f| f.chomp(".rb") } - sys_exec!("ruby -w -I.") do |input, _, _| + sys_exec!("ruby -w -Ilib") do |input, _, _| lib_files.each do |f| - input.puts "require '#{f}'" + input.puts "require '#{f.sub(%r{\Alib/}, "")}'" end end - expect(@err.split("\n")).to be_well_formed - expect(@out.split("\n")).to be_well_formed + expect(last_command.stdboth.split("\n")).to be_well_formed end end end |