Skip to content

Commit 29e01c6

Browse files
committed
skip if DidYouMean.formatter= is not defined
ruby/test_default_gems.rb can define empty `DidYouMean` module because of the following line (second require) in the `lib/did_you_mean/did_you_mean.gemspec`: ```ruby begin require_relative "lib/did_you_mean/version" rescue LoadError # Fallback to load version file in ruby core repository require_relative "version" end ``` It defines only `::DidYouMean::VERSION`. However, in the `test/ruby/test_patten_matching.rb` assumes that if `defined?(DidYouMean)` is true, then there is a method `DidYouMean.formatter=` and this assumption fails all tests in `test/ruby/test_patten_matching.rb` if there is only a `::DidYouMean::VERSION`. To reproduce the failures, we need to repeat the following command: `make test-all TESTS='-v ruby/test_default_gems.rb ruby/pattern_matching'` (because the ruby/test_default_gems.rb should be run before the ruby/pattern_matching`) This patch introduces more strict gurds.
1 parent 52449b5 commit 29e01c6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/ruby/test_pattern_matching.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ def message_for(corrections)
99
end
1010

1111
def setup
12-
if defined?(DidYouMean)
12+
if defined?(DidYouMean.formatter=nil)
1313
@original_formatter = DidYouMean.formatter
1414
DidYouMean.formatter = NullFormatter.new
1515
end
1616
end
1717

1818
def teardown
19-
if defined?(DidYouMean)
19+
if defined?(DidYouMean.formatter=nil)
2020
DidYouMean.formatter = @original_formatter
2121
end
2222
end

0 commit comments

Comments
 (0)