diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb index 05fb46e89a..dbe6c5ae85 100644 --- a/lib/rdoc/token_stream.rb +++ b/lib/rdoc/token_stream.rb @@ -107,7 +107,7 @@ def token_stream # Returns a string representation of the token stream def tokens_to_s - token_stream.compact.map { |token| token.text }.join '' + token_stream.compact.map { |token| token[:text] }.join '' end end diff --git a/test/test_rdoc_token_stream.rb b/test/test_rdoc_token_stream.rb index abf1469bbc..8a4d26eab0 100644 --- a/test/test_rdoc_token_stream.rb +++ b/test/test_rdoc_token_stream.rb @@ -39,5 +39,20 @@ def test_class_to_html_empty assert_equal '', RDoc::TokenStream.to_html([]) end + def test_tokens_to_s + foo = Class.new do + include RDoc::TokenStream + + def initialize + @token_stream = [ + { line_no: 0, char_no: 0, kind: :on_ident, text: "foo" }, + { line_no: 0, char_no: 0, kind: :on_sp, text: " " }, + { line_no: 0, char_no: 0, kind: :on_tstring, text: "'bar'" }, + ] + end + end.new + + assert_equal "foo 'bar'", foo.tokens_to_s + end end