Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rexml/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def read_until(term)
@scanner << readline(term)
end
if str
read if @scanner.eos? and [email protected]?
read if @scanner.eos? and @source and [email protected]?
str
else
rest = @scanner.rest
Expand Down
19 changes: 19 additions & 0 deletions test/test_io_source.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: false

require "rexml/source"

module REXMLTests
class TestIOSource < Test::Unit::TestCase
def setup
@source = REXML::SourceFactory.create_from('<?xml version="1.0"?>')
end

sub_test_case("#read_until") do
test("eof") do
assert_true(@source.read("nonexistent")) # Consume all data
assert_false(@source.read("nonexistent")) # Set EOF
assert_equal('<?xml version="1.0"?>', @source.read_until(">"))
end
end
end
end
Loading