[rubygems/rubygems] Prefer squiggly heredocs over custom helper

258476c38a
This commit is contained in:
David Rodríguez 2023-06-30 12:27:03 +02:00 committed by Hiroshi SHIBATA
parent 5a43b0ddd5
commit 0e7536bf49
17 changed files with 51 additions and 51 deletions

View file

@ -76,7 +76,7 @@ RSpec.describe Bundler do
context "with incorrect YAML file" do
before do
File.open(app_gemspec_path, "wb") do |f|
f.write strip_whitespace(<<-GEMSPEC)
f.write <<~GEMSPEC
---
{:!00 ao=gu\g1= 7~f
GEMSPEC
@ -147,7 +147,7 @@ RSpec.describe Bundler do
context "with gemspec containing local variables" do
before do
File.open(app_gemspec_path, "wb") do |f|
f.write strip_whitespace(<<-GEMSPEC)
f.write <<~GEMSPEC
must_not_leak = true
Gem::Specification.new do |gem|
gem.name = "leak check"

View file

@ -139,7 +139,7 @@ RSpec.describe Bundler::Env do
context "when Gemfile contains a gemspec and print_gemspecs is true" do
let(:gemspec) do
strip_whitespace(<<-GEMSPEC)
<<~GEMSPEC
Gem::Specification.new do |gem|
gem.name = "foo"
gem.author = "Fumofu"
@ -178,7 +178,7 @@ RSpec.describe Bundler::Env do
allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
output = described_class.report(:print_gemspecs => true)
expect(output).to include(strip_whitespace(<<-ENV))
expect(output).to include(<<~ENV)
## Gemfile
### Gemfile

View file

@ -3,7 +3,7 @@
require "bundler/lockfile_parser"
RSpec.describe Bundler::LockfileParser do
let(:lockfile_contents) { strip_whitespace(<<-L) }
let(:lockfile_contents) { <<~L }
GIT
remote: https://github.com/alloy/peiji-san.git
revision: eca485d8dc95f12aaec1a434b49d295c7e91844b
@ -39,7 +39,7 @@ RSpec.describe Bundler::LockfileParser do
end
describe ".unknown_sections_in_lockfile" do
let(:lockfile_contents) { strip_whitespace(<<-L) }
let(:lockfile_contents) { <<~L }
UNKNOWN ATTR
UNKNOWN ATTR 2

View file

@ -51,7 +51,7 @@ RSpec.describe Bundler::Plugin::API::Source do
context "to_lock" do
it "returns the string with remote and type" do
expected = strip_whitespace <<-L
expected = <<~L
PLUGIN SOURCE
remote: #{uri}
type: #{type}
@ -67,7 +67,7 @@ RSpec.describe Bundler::Plugin::API::Source do
end
it "includes them" do
expected = strip_whitespace <<-L
expected = <<~L
PLUGIN SOURCE
remote: #{uri}
type: #{type}

View file

@ -44,14 +44,14 @@ RSpec.describe Bundler::Settings::Validator do
validate!("without", "b:c", "BUNDLE_WITH" => "a")
end.not_to raise_error
expect { validate!("with", "b:c", "BUNDLE_WITHOUT" => "c:d") }.to raise_error Bundler::InvalidOption, strip_whitespace(<<-EOS).strip
expect { validate!("with", "b:c", "BUNDLE_WITHOUT" => "c:d") }.to raise_error Bundler::InvalidOption, <<~EOS.strip
Setting `with` to "b:c" failed:
- a group cannot be in both `with` & `without` simultaneously
- `without` is current set to [:c, :d]
- the `c` groups conflict
EOS
expect { validate!("without", "b:c", "BUNDLE_WITH" => "c:d") }.to raise_error Bundler::InvalidOption, strip_whitespace(<<-EOS).strip
expect { validate!("without", "b:c", "BUNDLE_WITH" => "c:d") }.to raise_error Bundler::InvalidOption, <<~EOS.strip
Setting `without` to "b:c" failed:
- a group cannot be in both `with` & `without` simultaneously
- `with` is current set to [:c, :d]
@ -74,7 +74,7 @@ RSpec.describe Bundler::Settings::Validator do
describe "#fail!" do
it "raises with a helpful message" do
expect { subject.fail!("key", "value", "reason1", "reason2") }.to raise_error Bundler::InvalidOption, strip_whitespace(<<-EOS).strip
expect { subject.fail!("key", "value", "reason1", "reason2") }.to raise_error Bundler::InvalidOption, <<~EOS.strip
Setting `key` to "value" failed:
- rule description
- reason1

View file

@ -9,7 +9,7 @@ RSpec.describe Bundler::YAMLSerializer do
it "works for simple hash" do
hash = { "Q" => "Where does Thursday come before Wednesday? In the dictionary. :P" }
expected = strip_whitespace <<-YAML
expected = <<~YAML
---
Q: "Where does Thursday come before Wednesday? In the dictionary. :P"
YAML
@ -24,7 +24,7 @@ RSpec.describe Bundler::YAMLSerializer do
},
}
expected = strip_whitespace <<-YAML
expected = <<~YAML
---
nice-one:
read_ahead: "All generalizations are false, including this one"
@ -45,7 +45,7 @@ RSpec.describe Bundler::YAMLSerializer do
},
}
expected = strip_whitespace <<-YAML
expected = <<~YAML
---
nested_hash:
contains_array:
@ -61,7 +61,7 @@ RSpec.describe Bundler::YAMLSerializer do
describe "#load" do
it "works for simple hash" do
yaml = strip_whitespace <<-YAML
yaml = <<~YAML
---
Jon: "Air is free dude!"
Jack: "Yes.. until you buy a bag of chips!"
@ -76,7 +76,7 @@ RSpec.describe Bundler::YAMLSerializer do
end
it "works for nested hash" do
yaml = strip_whitespace <<-YAML
yaml = <<~YAML
---
baa:
baa: "black sheep"
@ -98,7 +98,7 @@ RSpec.describe Bundler::YAMLSerializer do
end
it "handles colon in key/value" do
yaml = strip_whitespace <<-YAML
yaml = <<~YAML
BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/: http://rubygems-mirror.org
YAML
@ -106,7 +106,7 @@ RSpec.describe Bundler::YAMLSerializer do
end
it "handles arrays inside hashes" do
yaml = strip_whitespace <<-YAML
yaml = <<~YAML
---
nested_hash:
contains_array:
@ -127,7 +127,7 @@ RSpec.describe Bundler::YAMLSerializer do
end
it "handles windows-style CRLF line endings" do
yaml = strip_whitespace(<<-YAML).gsub("\n", "\r\n")
yaml = <<~YAML.gsub("\n", "\r\n")
---
nested_hash:
contains_array:

View file

@ -59,7 +59,7 @@ RSpec.describe "bundle doctor" do
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib"]
allow(Fiddle).to receive(:dlopen).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_raise(Fiddle::DLError)
expect { doctor.run }.to raise_error(Bundler::ProductionError, strip_whitespace(<<-E).strip), @stdout.string
expect { doctor.run }.to raise_error(Bundler::ProductionError, <<~E.strip), @stdout.string
The following gems are missing OS dependencies:
* bundler: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib
* rack: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib

View file

@ -1024,7 +1024,7 @@ __FILE__: #{path.to_s.inspect}
end
context "signals being trapped by bundler" do
let(:executable) { strip_whitespace <<-RUBY }
let(:executable) { <<~RUBY }
#{shebang}
begin
Thread.new do
@ -1051,7 +1051,7 @@ __FILE__: #{path.to_s.inspect}
end
context "signals not being trapped by bunder" do
let(:executable) { strip_whitespace <<-RUBY }
let(:executable) { <<~RUBY }
#{shebang}
signals = #{test_signals.inspect}

View file

@ -651,7 +651,7 @@ RSpec.describe "bundle gem" do
system_gems ["rake-13.0.1"]
rakefile = strip_whitespace <<-RAKEFILE
rakefile = <<~RAKEFILE
task :default do
puts 'SUCCESS'
end
@ -797,7 +797,7 @@ RSpec.describe "bundle gem" do
end
it "creates a default rake task to run the test suite" do
rakefile = strip_whitespace <<-RAKEFILE
rakefile = <<~RAKEFILE
# frozen_string_literal: true
require "bundler/gem_tasks"
@ -855,7 +855,7 @@ RSpec.describe "bundle gem" do
end
it "creates a default rake task to run the test suite" do
rakefile = strip_whitespace <<-RAKEFILE
rakefile = <<~RAKEFILE
# frozen_string_literal: true
require "bundler/gem_tasks"
@ -1419,7 +1419,7 @@ RSpec.describe "bundle gem" do
end
it "depends on compile task for build" do
rakefile = strip_whitespace <<-RAKEFILE
rakefile = <<~RAKEFILE
# frozen_string_literal: true
require "bundler/gem_tasks"
@ -1477,7 +1477,7 @@ RSpec.describe "bundle gem" do
end
it "depends on compile task for build" do
rakefile = strip_whitespace <<-RAKEFILE
rakefile = <<~RAKEFILE
# frozen_string_literal: true
require "bundler/gem_tasks"
@ -1583,7 +1583,7 @@ Usage: "bundle gem NAME [OPTIONS]"
end
expect(bundled_app("foobar/spec/spec_helper.rb")).to exist
rakefile = strip_whitespace <<-RAKEFILE
rakefile = <<~RAKEFILE
# frozen_string_literal: true
require "bundler/gem_tasks"

View file

@ -16,7 +16,7 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot"), :re
expect(out).to include("gem_graph.png")
bundle "viz", :format => "debug"
expect(out).to eq(strip_whitespace(<<-DOT).strip)
expect(out).to eq(<<~DOT.strip)
digraph Gemfile {
concentrate = "true";
normalize = "true";
@ -50,7 +50,7 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot"), :re
expect(out).to include("gem_graph.png")
bundle "viz", :format => :debug, :version => true
expect(out).to eq(strip_whitespace(<<-EOS).strip)
expect(out).to eq(<<~EOS.strip)
digraph Gemfile {
concentrate = "true";
normalize = "true";
@ -88,7 +88,7 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot"), :re
G
bundle "viz", :format => "debug"
expect(out).to eq(strip_whitespace(<<-DOT).strip)
expect(out).to eq(<<~DOT.strip)
digraph Gemfile {
concentrate = "true";
normalize = "true";

View file

@ -51,7 +51,7 @@ RSpec.describe "bundle install with :allow_offline_install" do
def break_git_remote_ops!
FileUtils.mkdir_p(tmp("broken_path"))
File.open(tmp("broken_path/git"), "w", 0o755) do |f|
f.puts strip_whitespace(<<-RUBY)
f.puts <<~RUBY
#!/usr/bin/env ruby
fetch_args = %w(fetch --force --quiet)
clone_args = %w(clone --bare --no-hardlinks --quiet)

View file

@ -506,7 +506,7 @@ RSpec.describe "install in deployment or frozen mode" do
G
run "require 'rack'", :raise_on_error => false
expect(err).to include strip_whitespace(<<-E).strip
expect(err).to include <<~E.strip
The dependencies in your gemfile changed, but the lockfile can't be updated because frozen mode is set (Bundler::ProductionError)
You have added to the Gemfile:

View file

@ -448,7 +448,7 @@ RSpec.describe "bundle install from an existing gemspec" do
context "as a runtime dependency" do
it "keeps all platform dependencies in the lockfile" do
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
expect(lockfile).to eq <<~L
PATH
remote: .
specs:
@ -481,7 +481,7 @@ RSpec.describe "bundle install from an existing gemspec" do
it "keeps all platform dependencies in the lockfile" do
expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
expect(lockfile).to eq <<~L
PATH
remote: .
specs:
@ -515,7 +515,7 @@ RSpec.describe "bundle install from an existing gemspec" do
it "keeps all platform dependencies in the lockfile" do
expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY"
expect(lockfile).to eq strip_whitespace(<<-L)
expect(lockfile).to eq <<~L
PATH
remote: .
specs:

View file

@ -1374,7 +1374,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem "thin"
end
G
expect(err).to eq strip_whitespace(<<-EOS).strip
expect(err).to eq <<~EOS.strip
Warning: The gem 'rack' was found in multiple relevant sources.
* rubygems repository https://gem.repo1/
* rubygems repository https://gem.repo4/
@ -1404,7 +1404,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
G
expect(last_command).to be_failure
expect(err).to eq strip_whitespace(<<-EOS).strip
expect(err).to eq <<~EOS.strip
The gem 'rack' was found in multiple relevant sources.
* rubygems repository https://gem.repo1/
* rubygems repository https://gem.repo4/

View file

@ -289,7 +289,7 @@ The checksum of /versions does not match the checksum provided by the server! So
system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0], :gem_repo => gem_repo2
bundle "config set --local path.system true"
ENV["BUNDLER_SPEC_ALL_REQUESTS"] = strip_whitespace(<<-EOS).strip
ENV["BUNDLER_SPEC_ALL_REQUESTS"] = <<~EOS.strip
#{source_uri}/versions
#{source_uri}/info/rack
EOS

View file

@ -415,7 +415,7 @@ RSpec.describe "bundle install with install-time dependencies" do
bundle "install", :raise_on_error => false
end
nice_error = strip_whitespace(<<-E).strip
nice_error = <<~E.strip
Could not find gem 'sorbet-static (= 0.5.10554)' with platforms 'arm64-darwin-21', 'aarch64-linux' in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally.
The source contains the following gems matching 'sorbet-static (= 0.5.10554)':
@ -521,7 +521,7 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000")
nice_error = strip_whitespace(<<-E).strip
nice_error = <<~E.strip
Could not find compatible versions
Because every version of require_ruby depends on Ruby > 9000
@ -543,7 +543,7 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000")
nice_error = strip_whitespace(<<-E).strip
nice_error = <<~E.strip
Could not find compatible versions
Because every version of require_ruby depends on Ruby > 9000
@ -587,7 +587,7 @@ RSpec.describe "bundle install with install-time dependencies" do
G
expect(err).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000")
nice_error = strip_whitespace(<<-E).strip
nice_error = <<~E.strip
Because every version of require_rubygems depends on RubyGems > 9000
and Gemfile depends on require_rubygems >= 0,
RubyGems > 9000 is required.

View file

@ -1316,7 +1316,7 @@ end
exempts
end
let(:activation_warning_hack) { strip_whitespace(<<-RUBY) }
let(:activation_warning_hack) { <<~RUBY }
require #{spec_dir.join("support/hax").to_s.dump}
Gem::Specification.send(:alias_method, :bundler_spec_activate, :activate)
@ -1336,7 +1336,7 @@ end
"-r#{bundled_app("activation_warning_hack.rb")} #{ENV["RUBYOPT"]}"
end
let(:code) { strip_whitespace(<<-RUBY) }
let(:code) { <<~RUBY }
require "pp"
loaded_specs = Gem.loaded_specs.dup
#{exemptions.inspect}.each {|s| loaded_specs.delete(s) }