-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to provide options for CSV loading
- Loading branch information
1 parent
f67cdaf
commit 6031f2d
Showing
3 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
user_id;name;email | ||
1;Jane;[email protected] | ||
2;John;[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe ROM::CSV do | ||
let(:configuration) do | ||
ROM::Configuration.new(:csv, uri, csv_options) | ||
end | ||
|
||
let(:rom) { ROM.container(configuration) } | ||
|
||
context 'when CSV options provided' do | ||
let(:uri) { File.expand_path('./spec/fixtures/semicolon.csv') } | ||
let(:csv_options) { { col_sep: ';' } } | ||
|
||
before do | ||
configuration.relation(:users) do | ||
schema(:semicolon) do | ||
end | ||
end | ||
end | ||
|
||
it 'uses csv options for load data' do | ||
expect(rom.relations[:users].to_a).to eql [ | ||
{ user_id: 1, name: "Jane", email: "[email protected]" }, | ||
{ user_id: 2, name: "John", email: "[email protected]" } | ||
] | ||
end | ||
end | ||
end |