Skip to content

Commit 769d470

Browse files
committed
Merge branch 'main' into improved-auto-detection
2 parents 7a13aec + f8048f0 commit 769d470

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

spec/features/formating/column_separator_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@
8787
end.to raise_exception SmarterCSV::NoColSepDetected
8888
end
8989

90+
it 'does not detect separators that are between quotes' do
91+
data = SmarterCSV.process("#{fixture_path}/separator_chars_between_quotes.csv", options)
92+
93+
94+
expect(data.first.keys.size).to eq 5
95+
expect(data.size).to eq 3
96+
end
97+
9098
context 'when auto is given as a string' do
9199
let(:options) do
92100
{
@@ -148,6 +156,16 @@
148156
end.to raise_exception SmarterCSV::NoColSepDetected
149157
end
150158

159+
it 'does not detect separators that are between quotes' do
160+
data = SmarterCSV.process(
161+
"#{fixture_path}/separator_chars_between_quotes_no_headers.csv",
162+
options.merge(user_provided_headers: %w[Name Age Job Department Project])
163+
)
164+
165+
expect(data.first.keys.size).to eq 5
166+
expect(data.size).to eq 3
167+
end
168+
151169
context 'when auto is given as a string' do
152170
let(:options) do
153171
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"name, info":"age, years":"job, title":"department, info":"project, code"
2+
"John, Doe":"35, years":"Senior, Developer":"Engineering, Dept":"Code, 1234"
3+
"Jane, Smith":"29, years":"Project, Manager":"Product, Development":"Code,5678"
4+
"Emily, Jones":"42, years":"CTO,":"Technology,Dept":"Code,9012"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"John, Doe":"35, years":"Senior, Developer":"Engineering, Dept":"Code, 1234"
2+
"Jane, Smith":"29, years":"Project, Manager":"Product, Development":"Code,5678"
3+
"Emily, Jones":"42, years":"CTO,":"Technology,Dept":"Code,9012"

0 commit comments

Comments
 (0)