-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from masa21kik/development
Development
- Loading branch information
Showing
8 changed files
with
119 additions
and
24 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
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
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,40 @@ | ||
require 'spec_helper' | ||
|
||
describe CSVConv::Converter do | ||
shared_examples_for 'convert file format stream' do | ||
before do | ||
@input = File.open(input_path) | ||
@output = StringIO.new | ||
end | ||
|
||
it 'convert file format stream' do | ||
cv = CSVConv::Converter.new(format, options) | ||
cv.convert_stream(@input, @output) | ||
actual = @output.string | ||
expected = File.read(input_path.sub(/[^\.]+$/, format)) | ||
expect(actual).to eq expected | ||
end | ||
|
||
after do | ||
@input.close | ||
@output.close | ||
end | ||
end | ||
|
||
let(:fixture_dir) { File.expand_path('../../fixtures', __FILE__) } | ||
|
||
context 'CSV with header (books.csv)' do | ||
let(:input_path) { File.join(fixture_dir, 'books.csv') } | ||
let(:options) { {} } | ||
|
||
context 'json' do | ||
let(:format) { 'json' } | ||
it_behaves_like 'convert file format stream' | ||
end | ||
|
||
context 'ltsv' do | ||
let(:format) { 'ltsv' } | ||
it_behaves_like 'convert file format stream' | ||
end | ||
end | ||
end |
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,6 @@ | ||
Title Author Price | ||
The Fault in Our Stars John Green 12.99 | ||
City of Heavenly Fire (The Mortal Instruments) Cassandra Clare 24.99 | ||
Oh, The Places You'll Go! Dr. Seuss 17.99 | ||
Capital in the Twenty-First Century Thomas Piketty 39.95 | ||
Skin Game (Dresden Files) Jim Butcher 27.95 |
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,5 @@ | ||
The Fault in Our Stars,John Green,12.99 | ||
City of Heavenly Fire (The Mortal Instruments),Cassandra Clare,24.99 | ||
"Oh, The Places You'll Go!",Dr. Seuss,17.99 | ||
Capital in the Twenty-First Century,Thomas Piketty,39.95 | ||
Skin Game (Dresden Files),Jim Butcher,27.95 |