Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 322c846

Browse files
committed
Merge pull request #281 from rspec/ignore_bundler_warnings
Ignore bundler warnings on windows
2 parents d612952 + b8e5016 commit 322c846

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

lib/rspec/support/spec/library_wide_checks.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ def load_all_files(files, preamble, postamble=nil)
6868
run_ruby_with_current_load_path(command, *options)
6969
end
7070

71-
# Ignore bundler warning.
72-
stderr = stderr.split("\n").reject { |l| l =~ %r{bundler/source/rubygems} }.join("\n")
73-
[stdout, stderr, status.exitstatus]
71+
[stdout, strip_known_warnings(stderr), status.exitstatus]
7472
end
7573

7674
define_method :load_all_lib_files do

lib/rspec/support/spec/shell_out.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ def run_ruby_with_current_load_path(ruby_command, *flags)
5353
end
5454
end
5555

56+
def strip_known_warnings(input)
57+
input.split("\n").reject do |l|
58+
# Ignore bundler warning.
59+
l =~ %r{bundler/source/rubygems} ||
60+
# Ignore bundler + rubygems warning.
61+
l =~ %r{site_ruby/\d\.\d\.\d/rubygems} ||
62+
# This is required for windows for some reason
63+
l =~ %r{lib/bundler/rubygems}
64+
end.join("\n")
65+
end
66+
5667
private
5768

5869
if Ruby.jruby?

spec/rspec/support/spec/shell_out_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
it 'passes along the provided ruby flags' do
3434
out, err, status = run_ruby_with_current_load_path('puts "version"', '-v')
3535
expect(out).to include('version', RUBY_DESCRIPTION)
36-
expect(err).to eq('')
36+
expect(strip_known_warnings err).to eq('')
3737
expect(status.exitstatus).to eq(0)
3838
end
3939

4040
it 'filters out the annoying output issued by `ruby -w` when the GC ENV vars are set' do
4141
with_env 'RUBY_GC_HEAP_FREE_SLOTS' => '10001', 'RUBY_GC_MALLOC_LIMIT' => '16777217', 'RUBY_FREE_MIN' => '10001' do
4242
out, err, status = run_ruby_with_current_load_path('', '-w')
4343
expect(out).to eq('')
44-
expect(err).to eq('')
44+
expect(strip_known_warnings err).to eq('')
4545
expect(status.exitstatus).to eq(0)
4646
end
4747
end

0 commit comments

Comments
 (0)