Skip to content

Commit

Permalink
Merge branch 'main' into improved-auto-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tilo committed Jul 10, 2024
2 parents 7a13aec + f8048f0 commit 769d470
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/features/formating/column_separator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
end.to raise_exception SmarterCSV::NoColSepDetected
end

it 'does not detect separators that are between quotes' do
data = SmarterCSV.process("#{fixture_path}/separator_chars_between_quotes.csv", options)


expect(data.first.keys.size).to eq 5
expect(data.size).to eq 3
end

context 'when auto is given as a string' do
let(:options) do
{
Expand Down Expand Up @@ -148,6 +156,16 @@
end.to raise_exception SmarterCSV::NoColSepDetected
end

it 'does not detect separators that are between quotes' do
data = SmarterCSV.process(
"#{fixture_path}/separator_chars_between_quotes_no_headers.csv",
options.merge(user_provided_headers: %w[Name Age Job Department Project])
)

expect(data.first.keys.size).to eq 5
expect(data.size).to eq 3
end

context 'when auto is given as a string' do
let(:options) do
{
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/separator_chars_between_quotes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"name, info":"age, years":"job, title":"department, info":"project, code"
"John, Doe":"35, years":"Senior, Developer":"Engineering, Dept":"Code, 1234"
"Jane, Smith":"29, years":"Project, Manager":"Product, Development":"Code,5678"
"Emily, Jones":"42, years":"CTO,":"Technology,Dept":"Code,9012"
3 changes: 3 additions & 0 deletions spec/fixtures/separator_chars_between_quotes_no_headers.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"John, Doe":"35, years":"Senior, Developer":"Engineering, Dept":"Code, 1234"
"Jane, Smith":"29, years":"Project, Manager":"Product, Development":"Code,5678"
"Emily, Jones":"42, years":"CTO,":"Technology,Dept":"Code,9012"

0 comments on commit 769d470

Please sign in to comment.