smilodon 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/smilodon.rb +1 -2
- data/smilodon.gemspec +1 -1
- data/spec/lib/smilodon_spec.rb +43 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
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
|
-
|
71
|
+
self.header = row
|
73
72
|
else
|
74
73
|
process(row)
|
75
74
|
end
|
data/smilodon.gemspec
CHANGED
data/spec/lib/smilodon_spec.rb
CHANGED
@@ -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:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 7
|
10
|
+
version: 0.2.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Umang Chouhan
|