summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/csv/fields_converter.rb2
-rw-r--r--test/csv/write/test_converters.rb8
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/csv/fields_converter.rb b/lib/csv/fields_converter.rb
index a751c9ea1d4..178ffb37bc8 100644
--- a/lib/csv/fields_converter.rb
+++ b/lib/csv/fields_converter.rb
@@ -50,7 +50,7 @@ class CSV
fields.collect.with_index do |field, index|
if field.nil?
field = @nil_value
- elsif field.empty?
+ elsif field.is_a?(String) and field.empty?
field = @empty_value unless @empty_value_is_empty_string
end
@converters.each do |converter|
diff --git a/test/csv/write/test_converters.rb b/test/csv/write/test_converters.rb
index a93b1040ac6..0e0080b4c5c 100644
--- a/test/csv/write/test_converters.rb
+++ b/test/csv/write/test_converters.rb
@@ -20,14 +20,14 @@ module TestCSVWriteConverters
end
def test_nil_value
- assert_equal(%Q[a,NaN,c\n],
- generate_line(["a", nil, "c"],
+ assert_equal(%Q[a,NaN,29\n],
+ generate_line(["a", nil, 29],
write_nil_value: "NaN"))
end
def test_empty_value
- assert_equal(%Q[a,,c\n],
- generate_line(["a", "", "c"],
+ assert_equal(%Q[a,,29\n],
+ generate_line(["a", "", 29],
write_empty_value: nil))
end
end