Skip to content

Commit

Permalink
Add test for parsing frozen string and fixed related bug (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
guycall authored and sferik committed Dec 6, 2016
1 parent 47ec807 commit 0c280a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/multi_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def parse(xml, options = {}) # rubocop:disable AbcSize, CyclomaticComplexity, Me

options = DEFAULT_OPTIONS.merge(options)

xml.strip! if xml.respond_to?(:strip!)
xml = xml.strip if xml.respond_to?(:strip)
begin
xml = StringIO.new(xml) unless xml.respond_to?(:read)

Expand Down
10 changes: 10 additions & 0 deletions spec/parser_shared_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
end
end

context 'a frozen string' do
before do
@xml = ' '.freeze
end

it 'returns an empty Hash' do
expect(MultiXml.parse(@xml)).to eq({})
end
end

unless parser == 'Oga'
context 'an invalid XML document' do
before do
Expand Down

0 comments on commit 0c280a7

Please sign in to comment.