File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,11 @@ def corrections
33
33
) . correct ( visit_method )
34
34
end
35
35
36
- DidYouMean . correct_error ( VisitMethodError , self )
36
+ # In some setups with Ruby you can turn off DidYouMean, so we're going to
37
+ # respect that setting here.
38
+ if defined? ( DidYouMean ) && DidYouMean . method_defined? ( :correct_error )
39
+ DidYouMean . correct_error ( VisitMethodError , self )
40
+ end
37
41
end
38
42
39
43
class << self
Original file line number Diff line number Diff line change @@ -40,9 +40,18 @@ def initialize
40
40
end
41
41
end
42
42
43
- def test_visit_method_correction
44
- error = assert_raises { Visitor . visit_method ( :visit_binar ) }
45
- assert_match ( /visit_binary/ , error . message )
43
+ if defined? ( DidYouMean ) && DidYouMean . method_defined? ( :correct_error )
44
+ def test_visit_method_correction
45
+ error = assert_raises { Visitor . visit_method ( :visit_binar ) }
46
+ message =
47
+ if Exception . method_defined? ( :detailed_message )
48
+ error . detailed_message
49
+ else
50
+ error . message
51
+ end
52
+
53
+ assert_match ( /visit_binary/ , message )
54
+ end
46
55
end
47
56
end
48
57
end
You can’t perform that action at this time.
0 commit comments