|
2 | 2 | require 'open3'
|
3 | 3 |
|
4 | 4 | class ExeTest < Minitest::Test
|
5 |
| - GEM_PATH = File.join(__dir__, '..', 'tmp', 'gems') |
6 |
| - CMD = File.join(GEM_PATH, 'bin', 'json_schemer') |
7 | 5 | SCHEMA1 = File.join(__dir__, 'schemas', 'schema1.json')
|
8 | 6 | VALID = { 'id' => 1, 'a' => 'valid' }
|
9 | 7 | INVALID1 = { 'a' => 'invalid' }
|
10 | 8 | INVALID2 = { 'id' => 1 }
|
11 | 9 | INVALID3 = { 'id' => 1, 'a' => -1 }
|
12 | 10 | INVALID4 = { 'id' => 'invalid', 'a' => 'valid' }
|
13 | 11 | INVALID5 = { 'x' => 'invalid' }
|
| 12 | + RUBY_2_5_WARNING_REGEX = /Your RubyGems version \([\d\.]+\) has a bug that prevents `required_ruby_version` from working for Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running `gem update --system [\d\.]+`\n/ |
14 | 13 |
|
15 | 14 | def test_help
|
16 | 15 | stdout, stderr, status = exe('-h')
|
@@ -175,13 +174,9 @@ def test_stdin
|
175 | 174 | private
|
176 | 175 |
|
177 | 176 | def exe(*args, **kwargs)
|
178 |
| - env = { |
179 |
| - 'GEM_HOME' => Gem.dir, |
180 |
| - 'GEM_PATH' => [GEM_PATH, *Gem.path].uniq.join(File::PATH_SEPARATOR), |
181 |
| - 'GEM_SPEC_CACHE' => Gem.spec_cache_dir, |
182 |
| - 'RUBYOPT' => nil # prevent bundler/setup |
183 |
| - } |
184 |
| - Open3.capture3(env, CMD, *args, **kwargs) |
| 177 | + Open3.capture3('bundle', 'exec', 'json_schemer', *args, **kwargs).tap do |_stdout, stderr, _status| |
| 178 | + stderr.gsub!(RUBY_2_5_WARNING_REGEX, '') if RUBY_ENGINE == 'ruby' && RUBY_VERSION.match?(/\A2\.5\.\d+\z/) |
| 179 | + end |
185 | 180 | end
|
186 | 181 |
|
187 | 182 | def tmp_json(*json)
|
|
0 commit comments