diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2022-07-09 21:00:51 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-07-24 14:59:33 +0900 |
commit | c31a9cf829b529fa25903fcee7e9a70d8a08522b (patch) | |
tree | 0a4290458dcaaac68c533e172dc0a741b2adf440 /spec | |
parent | ebc3174123c62bb20fb34a8a778a659aa4f1146d (diff) | |
download | ruby-c31a9cf829b529fa25903fcee7e9a70d8a08522b.tar.gz |
[rubygems/rubygems] Refactor spec helpers for reading lockfiles
https://github.com/rubygems/rubygems/commit/ea2a30ba08
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/commands/lock_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/support/helpers.rb | 16 |
2 files changed, 14 insertions, 6 deletions
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index cbf5394588..76ea4178ae 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -1,10 +1,6 @@ # frozen_string_literal: true RSpec.describe "bundle lock" do - def read_lockfile(file = "Gemfile.lock") - bundled_app(file).read - end - let(:repo) { gem_repo1 } before :each do diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 7b8c56b6ad..73621685ba 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -244,7 +244,7 @@ module Spec contents = args.pop if contents.nil? - File.open(bundled_app_gemfile, "r", &:read) + read_gemfile else create_file(args.pop || "Gemfile", contents) end @@ -254,12 +254,24 @@ module Spec contents = args.pop if contents.nil? - File.open(bundled_app_lock, "r", &:read) + read_lockfile else create_file(args.pop || "Gemfile.lock", contents) end end + def read_gemfile(file = "Gemfile") + read_bundled_app_file(file) + end + + def read_lockfile(file = "Gemfile.lock") + read_bundled_app_file(file) + end + + def read_bundled_app_file(file) + bundled_app(file).read + end + def strip_whitespace(str) # Trim the leading spaces spaces = str[/\A\s+/, 0] || "" |