aboutsummaryrefslogtreecommitdiffstats
path: root/test/csv/test_interface.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/csv/test_interface.rb')
-rwxr-xr-xtest/csv/test_interface.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/csv/test_interface.rb b/test/csv/test_interface.rb
index ad310fae49..22907d2dd0 100755
--- a/test/csv/test_interface.rb
+++ b/test/csv/test_interface.rb
@@ -198,6 +198,25 @@ class TestCSV::Interface < TestCSV
end
end
+ def test_write_hash_with_string_keys
+ File.unlink(@path)
+
+ lines = [{a: 1, b: 2, c: 3}, {a: 4, b: 5, c: 6}]
+ CSV.open( @path, "wb", headers: true ) do |csv|
+ csv << lines.first.keys
+ lines.each { |line| csv << line }
+ end
+ CSV.open( @path, "rb", headers: true ) do |csv|
+ csv.each do |line|
+ csv.headers.each_with_index do |header, h|
+ keys = line.to_hash.keys
+ assert_instance_of(String, keys[h])
+ assert_same(header, keys[h])
+ end
+ end
+ end
+ end
+
def test_write_hash_with_headers_array
File.unlink(@path)