aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/csv/generate_line_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/csv/generate_line_spec.rb')
-rw-r--r--spec/ruby/library/csv/generate_line_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/ruby/library/csv/generate_line_spec.rb b/spec/ruby/library/csv/generate_line_spec.rb
new file mode 100644
index 0000000000..cc7c8de4f0
--- /dev/null
+++ b/spec/ruby/library/csv/generate_line_spec.rb
@@ -0,0 +1,30 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'csv'
+
+describe "CSV.generate_line" do
+
+ it "generates an empty string" do
+ result = CSV.generate_line([])
+ result.should == "\n"
+ end
+
+ it "generates the string 'foo,bar'" do
+ result = CSV.generate_line(["foo", "bar"])
+ result.should == "foo,bar\n"
+ end
+
+ it "generates the string 'foo;bar'" do
+ result = CSV.generate_line(["foo", "bar"], col_sep: ?;)
+ result.should == "foo;bar\n"
+ end
+
+ it "generates the string 'foo,,bar'" do
+ result = CSV.generate_line(["foo", nil, "bar"])
+ result.should == "foo,,bar\n"
+ end
+
+ it "generates the string 'foo;;bar'" do
+ result = CSV.generate_line(["foo", nil, "bar"], col_sep: ?;)
+ result.should == "foo;;bar\n"
+ end
+end