Sha256: 4d0c80b0637080afaf3d18a123dbcf08ad677ec30e572817afba85781eaa3d36
Contents?: true
Size: 1.64 KB
Versions: 7
Compression:
Stored size: 1.64 KB
Contents
require 'spec_helper' module Alf module CSV describe Reader do describe "without options" do let(:input){ StringIO.new << "size\n10\n20\n" } let(:expected){ [{:size => "10"}, {:size => "20"}] } subject{ reader.to_a } describe "when called on a reader directly" do let(:reader){ ::Alf::CSV::Reader.new(input) } it{ should eq(expected) } end describe "when called through registered one" do let(:reader){ ::Alf::Reader.reader(_('input.csv', __FILE__)) } it{ should eq(expected) } end describe "when called through factory method" do let(:reader){ ::Alf::Reader.csv(input) } it{ should eq(expected) } end end describe "with options" do let(:input){ StringIO.new << "size;name\n10;blambeau\n20;mmathieu\n" } let(:options){ {:col_sep => ";"} } let(:expected){ [{:size => "10", :name => 'blambeau'}, {:size => "20", :name => 'mmathieu'}] } subject{ reader.to_a } describe "when called on a reader directly" do let(:reader){ ::Alf::CSV::Reader.new(input, options) } it{ should eq(expected) } end describe "when called through factory method" do let(:reader){ ::Alf::Reader.csv(input, options) } it{ should eq(expected) } end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems