This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ Bug Fixes:
4
4
5
5
* Use ` Mutex#owned? ` to allow ` RSpec::Support::ReentrantMutex ` to work in
6
6
nested Fibers on Ruby 3.0 and later. (Benoit Daloze, #503 , #504 )
7
+ * Support ` end ` -less methods in ` RSpec::Support::Source::Token `
8
+ so that RSpec won't hang when an ` end ` -less method raises an error. (Yuji Nakayama, #505 )
7
9
8
10
### 3.10.2 / 2021-01-28
9
11
[ Full Changelog] ( http://github.com/rspec/rspec-support/compare/v3.10.1...v3.10.2 )
Original file line number Diff line number Diff line change @@ -54,12 +54,16 @@ def keyword?
54
54
type == :on_kw
55
55
end
56
56
57
+ def equals_operator?
58
+ type == :on_op && string == '='
59
+ end
60
+
57
61
def opening?
58
62
opening_delimiter? || opening_keyword?
59
63
end
60
64
61
65
def closed_by? ( other )
62
- closed_by_delimiter ?( other ) || closed_by_keyword ?( other )
66
+ delimiter_closed_by ?( other ) || keyword_closed_by ?( other )
63
67
end
64
68
65
69
private
@@ -73,13 +77,16 @@ def opening_keyword?
73
77
CLOSING_KEYWORDS_BY_OPENING_KEYWORD . key? ( string )
74
78
end
75
79
76
- def closed_by_delimiter ?( other )
80
+ def delimiter_closed_by ?( other )
77
81
other . type == CLOSING_TYPES_BY_OPENING_TYPE [ type ]
78
82
end
79
83
80
- def closed_by_keyword? ( other )
81
- return false unless other . keyword?
82
- other . string == CLOSING_KEYWORDS_BY_OPENING_KEYWORD [ string ]
84
+ def keyword_closed_by? ( other )
85
+ return false unless keyword?
86
+ return true if other . string == CLOSING_KEYWORDS_BY_OPENING_KEYWORD [ string ]
87
+
88
+ # Ruby 3's `end`-less method definition: `def method_name = body`
89
+ string == 'def' && other . equals_operator? && location . line == other . location . line
83
90
end
84
91
end
85
92
end
You can’t perform that action at this time.
0 commit comments