[ruby/rdoc] fix: fix NoMethodError
when token_stream
is nil
The change in #1055 might be a breaking change. So, just simply wrap `token_stream` with `Array` https://github.com/ruby/rdoc/commit/d8c19d7fa1 Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
This commit is contained in:
parent
09ce41a01e
commit
cda431f538
@ -105,14 +105,14 @@ module RDoc::TokenStream
|
||||
# Current token stream
|
||||
|
||||
def token_stream
|
||||
@token_stream || []
|
||||
@token_stream
|
||||
end
|
||||
|
||||
##
|
||||
# Returns a string representation of the token stream
|
||||
|
||||
def tokens_to_s
|
||||
token_stream.compact.map { |token| token[:text] }.join ''
|
||||
Array(token_stream).compact.map { |token| token[:text] }.join ''
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -39,6 +39,13 @@ class TestRDocTokenStream < RDoc::TestCase
|
||||
assert_equal '', RDoc::TokenStream.to_html([])
|
||||
end
|
||||
|
||||
def test_token_stream
|
||||
foo = Class.new do
|
||||
include RDoc::TokenStream
|
||||
end.new
|
||||
assert_equal nil, foo.token_stream
|
||||
end
|
||||
|
||||
def test_tokens_to_s
|
||||
foo = Class.new do
|
||||
include RDoc::TokenStream
|
||||
|
Loading…
x
Reference in New Issue
Block a user