summaryrefslogtreecommitdiff
path: root/spec/ruby/library/csv/parse_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/csv/parse_spec.rb')
-rw-r--r--spec/ruby/library/csv/parse_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/library/csv/parse_spec.rb b/spec/ruby/library/csv/parse_spec.rb
index 41d37ca9a4..47d7ebbde1 100644
--- a/spec/ruby/library/csv/parse_spec.rb
+++ b/spec/ruby/library/csv/parse_spec.rb
@@ -78,4 +78,18 @@ describe "CSV.parse" do
result = CSV.parse "foo;bar\nbaz;quz", col_sep: ?;
result.should == [['foo','bar'],['baz','quz']]
end
+
+ it "raises CSV::MalformedCSVError exception if input is illegal" do
+ -> {
+ CSV.parse('"quoted" field')
+ }.should raise_error(CSV::MalformedCSVError)
+ end
+
+ ruby_version_is '2.4' do
+ it "handles illegal input with the liberal_parsing option" do
+ illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
+ result = CSV.parse(illegal_input, liberal_parsing: true)
+ result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
+ end
+ end
end