aboutsummaryrefslogtreecommitdiffstats
path: root/test/csv/test_headers.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-05 13:33:21 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-05 13:33:21 +0000
commit60ebd4e26a1b6ed3ad11bade520db0a19e9be190 (patch)
tree7fd02799a27da1ab9c7f57ab5705100c4dab1d3b /test/csv/test_headers.rb
parent21ce539f20b1376ab4644f9620b0cd1487ae99d6 (diff)
downloadruby-60ebd4e26a1b6ed3ad11bade520db0a19e9be190.tar.gz
Merge csv-3.0.0 from ruby/csv repository.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/csv/test_headers.rb')
-rwxr-xr-xtest/csv/test_headers.rb43
1 files changed, 29 insertions, 14 deletions
diff --git a/test/csv/test_headers.rb b/test/csv/test_headers.rb
index 94f4359671..3ebb5cfc85 100755
--- a/test/csv/test_headers.rb
+++ b/test/csv/test_headers.rb
@@ -13,11 +13,11 @@ class TestCSV::Headers < TestCSV
def setup
super
- @data = <<-END_CSV.gsub(/^\s+/, "")
- first,second,third
- A,B,C
- 1,2,3
- END_CSV
+ @data = <<-CSV
+first,second,third
+A,B,C
+1,2,3
+ CSV
end
def test_first_row
@@ -183,10 +183,10 @@ class TestCSV::Headers < TestCSV
def test_converters
# create test data where headers and fields look alike
- data = <<-END_MATCHING_CSV.gsub(/^\s+/, "")
- 1,2,3
- 1,2,3
- END_MATCHING_CSV
+ data = <<-CSV
+1,2,3
+1,2,3
+ CSV
# normal converters do not affect headers
csv = CSV.parse( data, headers: true,
@@ -256,16 +256,16 @@ class TestCSV::Headers < TestCSV
end
def test_skip_blanks
- @data = <<-END_CSV.gsub(/^ +/, "")
+ @data = <<-CSV
- A,B,C
+A,B,C
- 1,2,3
+1,2,3
- END_CSV
+ CSV
expected = [%w[1 2 3]]
CSV.parse(@data, headers: true, skip_blanks: true) do |row|
@@ -292,7 +292,7 @@ class TestCSV::Headers < TestCSV
assert_equal(%w[first second third], csv.headers) # after headers are read
end
- def test_blank_row_bug_fix
+ def test_blank_row
@data += "\n#{@data}" # add a blank row
# ensure that everything returned is a Row object
@@ -300,4 +300,19 @@ class TestCSV::Headers < TestCSV
assert_instance_of(CSV::Row, row)
end
end
+
+ def test_nil_row_header
+ @data = <<-CSV
+A
+
+1
+ CSV
+
+ csv = CSV.parse(@data, headers: true)
+
+ # ensure nil row creates Row object with headers
+ row = csv[0]
+ assert_equal([["A"], [nil]],
+ [row.headers, row.fields])
+ end
end