spec/lib/sources/csv_spec.rb in picky-2.7.0 vs spec/lib/sources/csv_spec.rb in picky-3.0.0.pre1
- old
+ new
@@ -1,20 +1,20 @@
require 'spec_helper'
require 'csv'
-describe Sources::CSV do
+describe Picky::Sources::CSV do
describe 'to_s' do
let(:source) { described_class.new :a, :b, :c, file:'some/file.csv' }
it 'outputs the correct string' do
- source.to_s.should == 'Sources::CSV(a, b, c, {:file=>"some/file.csv"})'
+ source.to_s.should == 'Picky::Sources::CSV(a, b, c, {:file=>"some/file.csv"})'
end
end
describe 'without separator' do
before(:each) do
- @source = Sources::CSV.new :a, :b, :c, :file => :some_file
+ @source = described_class.new :a, :b, :c, :file => :some_file
end
it 'calls foreach correctly' do
block = lambda { |*args| }
::CSV.should_receive(:foreach).once.with :some_file, {}, &block
@@ -22,11 +22,11 @@
@source.get_data &block
end
end
describe 'with separator' do
before(:each) do
- @source = Sources::CSV.new :a, :b, :c, :file => :some_file, :col_sep => 'some_separator'
+ @source = described_class.new :a, :b, :c, :file => :some_file, :col_sep => 'some_separator'
end
it 'calls foreach correctly' do
block = lambda { |*args| }
::CSV.should_receive(:foreach).once.with :some_file, :col_sep => 'some_separator', &block
@@ -35,20 +35,20 @@
end
end
context "without file" do
it "should fail correctly" do
- lambda { @source = Sources::CSV.new(:a, :b, :c) }.should raise_error(Sources::NoCSVFileGiven)
+ lambda { @source = described_class.new(:a, :b, :c) }.should raise_error(described_class::NoFileGiven)
end
end
context "with file" do
before(:each) do
::CSV.should_receive(:foreach).any_number_of_times.and_yield [' 7', 'a data', 'b data', 'c data']
end
context 'without separator' do
before(:each) do
- @source = Sources::CSV.new :a, :b, :c, :file => :some_file
+ @source = described_class.new :a, :b, :c, :file => :some_file
end
describe "harvest" do
it "should yield the right data" do
category = stub :b, :from => :b
@source.harvest category do |id, token|
@@ -64,10 +64,10 @@
end
end
end
context 'with key_format method' do
before(:each) do
- @source = Sources::CSV.new :a, :b, :c, :file => :some_file, :key_format => :strip
+ @source = described_class.new :a, :b, :c, :file => :some_file, :key_format => :strip
end
describe "harvest" do
it "should yield the right data" do
category = stub :b, :from => :b
@source.harvest category do |id, token|
\ No newline at end of file