smilodon 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.2.7
data/lib/smilodon.rb CHANGED
@@ -65,11 +65,10 @@ module Smilodon
65
65
  # @usage
66
66
  # populates 'TestFile', :before => :inactivate
67
67
  send(before) if before
68
-
69
68
  rows = parser.parse(read(f))
70
69
  rows.each_with_index do |row, index|
71
70
  if index == 0 && header
72
- row = header = rows.shift
71
+ self.header = row
73
72
  else
74
73
  process(row)
75
74
  end
data/smilodon.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{smilodon}
8
- s.version = "0.2.6"
8
+ s.version = "0.2.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Umang Chouhan"]
@@ -63,3 +63,46 @@ describe FakePopulator, '.files' do
63
63
  FakePopulatorWithMultipleFiles.run
64
64
  end
65
65
  end
66
+
67
+ describe FakePopulator, '.run' do
68
+ module TestPopulator
69
+ extend Smilodon::Populator
70
+ populates 'abc'
71
+ end
72
+
73
+ context 'header is true' do
74
+ let!(:csv) { ["id,name", "1,atsuya"].join("\n") }
75
+
76
+ before do
77
+ TestPopulator.header = true
78
+ TestPopulator.stub(:read).and_return(csv)
79
+ TestPopulator.should_receive(:process).once
80
+ TestPopulator.run
81
+ end
82
+
83
+ it 'should process csv file' do
84
+ TestPopulator.header.should == ["id", "name"]
85
+ end
86
+
87
+ it 'calls process for each non-header row' do
88
+ end
89
+ end
90
+
91
+ context 'header is false' do
92
+ let!(:csv) { ["id,name", "1,atsuya"].join("\n") }
93
+
94
+ before do
95
+ TestPopulator.header = false
96
+ TestPopulator.stub(:read).and_return(csv)
97
+ TestPopulator.should_receive(:process).twice
98
+ TestPopulator.run
99
+ end
100
+
101
+ it 'should process csv file' do
102
+ TestPopulator.header.should == false
103
+ end
104
+
105
+ it 'calls process for each row' do
106
+ end
107
+ end
108
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smilodon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 6
10
- version: 0.2.6
9
+ - 7
10
+ version: 0.2.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Umang Chouhan