Skip to content

Commit

Permalink
Add missing tests for CSV.build with custom separator/quote_char (cry…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija authored and chris-huxtable committed Jun 6, 2018
1 parent 32aca6e commit 3c550f7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/std/csv/csv_build_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ describe CSV do
string.should eq(%("hello,world"\n))
end

it "builds with custom separator" do
string = CSV.build(separator: ';') do |csv|
csv.row do |row|
row << "one"
row << "two"
row << "thr;ee"
end
end
string.should eq(%(one;two;"thr;ee"\n))
end

it "builds with quotes" do
string = CSV.build do |csv|
csv.row do |row|
Expand All @@ -49,6 +60,15 @@ describe CSV do
string.should eq(%("he said ""no"""\n))
end

it "builds with custom quote character" do
string = CSV.build(quote_char: '\'') do |csv|
csv.row do |row|
row << %(he said 'no')
end
end
string.should eq(%('he said ''no'''\n))
end

it "builds row from enumerable" do
string = CSV.build do |csv|
csv.row [1, 2, 3]
Expand Down

0 comments on commit 3c550f7

Please sign in to comment.