summaryrefslogtreecommitdiff
path: root/test/csv
diff options
context:
space:
mode:
authorjeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-23 23:12:11 +0000
committerjeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-23 23:12:11 +0000
commit80c4b4b3d72c7841b9c2453713a5b96258f2ca90 (patch)
treee53f259797b83c2999f7d07d2b29543810731404 /test/csv
parent10ca8a4b07ea925c4a71c5da6067688fd8ff0bff (diff)
* lib/csv.rb: If skip_lines is set to a String, convert it to a Regexp
to prevent the alternative, which is that each line in the CSV gets converted to a Regexp when calling skip_lines#match. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv')
-rwxr-xr-xtest/csv/test_features.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/csv/test_features.rb b/test/csv/test_features.rb
index 8c2b3eb..9324af7 100755
--- a/test/csv/test_features.rb
+++ b/test/csv/test_features.rb
@@ -299,12 +299,19 @@ class TestCSV::Features < TestCSV
def test_comment_rows_are_ignored
sample_data = "line,1,a\n#not,a,line\nline,2,b\n #also,no,line"
c = CSV.new sample_data, :skip_lines => /\A\s*#/
- assert_equal c.each.to_a, [["line", "1", "a"], ["line", "2", "b"]]
+ assert_equal [["line", "1", "a"], ["line", "2", "b"]], c.each.to_a
end
def test_quoted_skip_line_markers_are_ignored
sample_data = "line,1,a\n\"#not\",a,line\nline,2,b"
c = CSV.new sample_data, :skip_lines => /\A\s*#/
- assert_equal c.each.to_a, [["line", "1", "a"], ["#not", "a", "line"], ["line", "2", "b"]]
+ assert_equal [["line", "1", "a"], ["#not", "a", "line"], ["line", "2", "b"]], c.each.to_a
end
+
+ def test_string_works_like_a_regexp
+ sample_data = "line,1,a\n#(not,a,line\nline,2,b\n also,#no,line"
+ c = CSV.new sample_data, :skip_lines => "#"
+ assert_equal [["line", "1", "a"], ["line", "2", "b"]], c.each.to_a
+ end
+
end