Sha256: 4b7b549ec57bbf9cba5209b0d8626c3f0dd28833db4d7d4350a4549d89dae225

Contents?: true

Size: 888 Bytes

Versions: 26

Compression:

Stored size: 888 Bytes

Contents

require 'spec_helper'

describe Sources::CSV do
  
  context "without file" do
    it "should fail correctly" do
      lambda { @source = Sources::CSV.new(:a, :b, :c) }.should raise_error(Sources::NoCSVFileGiven)
    end
  end
  context "with file" do
    before(:each) do
      @source = Sources::CSV.new :a, :b, :c, :file => :some_file
      ::CSV.should_receive(:foreach).any_number_of_times.and_yield ['7', 'a data', 'b data', 'c data']
    end
    describe "harvest" do
      it "should yield the right data" do
        field = stub :b, :name => :b
        @source.harvest :anything, field do |id, token|
          [id, token].should == [7, 'b data']
        end
      end
    end
    describe "get_data" do
      it "should yield each line" do
        @source.get_data do |data|
          data.should == ['7', 'a data', 'b data', 'c data']
        end
      end
    end
  end
  
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
picky-0.12.1 spec/lib/sources/csv_spec.rb
picky-0.12.0 spec/lib/sources/csv_spec.rb
picky-0.11.2 spec/lib/sources/csv_spec.rb
picky-0.11.1 spec/lib/sources/csv_spec.rb
picky-0.11.0 spec/lib/sources/csv_spec.rb
picky-0.10.5 spec/lib/sources/csv_spec.rb
picky-0.10.4 spec/lib/sources/csv_spec.rb
picky-0.10.2 spec/lib/sources/csv_spec.rb
picky-0.10.1 spec/lib/sources/csv_spec.rb
picky-0.10.0 spec/lib/sources/csv_spec.rb
picky-0.9.4 spec/lib/sources/csv_spec.rb
picky-0.9.3 spec/lib/sources/csv_spec.rb
picky-0.9.2 spec/lib/sources/csv_spec.rb
picky-0.9.1 spec/lib/sources/csv_spec.rb
picky-0.9.0 spec/lib/sources/csv_spec.rb
picky-0.3.0 spec/lib/sources/csv_spec.rb
picky-0.2.4 spec/lib/sources/csv_spec.rb
picky-0.2.3 spec/lib/sources/csv_spec.rb
picky-0.2.2 spec/lib/sources/csv_spec.rb
picky-0.2.1 spec/lib/sources/csv_spec.rb