nemah 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nemah/ration.rb +4 -3
- data/lib/nemah/version.rb +1 -1
- data/spec/nemah/ration_spec.rb +69 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0a20a9d85e8d302565a1a258b5f458e07db694f
|
4
|
+
data.tar.gz: bf21a669e521a9a061f4ce4ade75e6b70bac309e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45ad23b5bcda18eea0b1e3f2a701a8012391ffaf94a9964e543aef0c1a2ba88bb516ae76042e398e130fdd86a5cc1f934a5ce8d1e3d2f6ca1689f4849004f3ca
|
7
|
+
data.tar.gz: 22babc655a4e9425ba6a366fd9943aa4ce70b15173908d7d66e08d6ed8c10deba4ea51a5703b837dd7a4e8b6679edb4859680c4e17fcf56f8025898ea42c951f
|
data/lib/nemah/ration.rb
CHANGED
@@ -23,9 +23,10 @@ module Nemah
|
|
23
23
|
balance(:protein, :energy) >= 6.0
|
24
24
|
end
|
25
25
|
|
26
|
-
Nemah::Nutrients.names.each do |nutrient|
|
27
|
-
define_method("enough_#{nutrient}?") { enough?(nutrient) }
|
28
|
-
|
26
|
+
Nemah::Nutrients.names.each do |nutrient|
|
27
|
+
define_method("enough_#{nutrient}?") { enough?(nutrient) }
|
28
|
+
define_method("total_#{nutrient}") { total(nutrient) }
|
29
|
+
end
|
29
30
|
|
30
31
|
private
|
31
32
|
|
data/lib/nemah/version.rb
CHANGED
data/spec/nemah/ration_spec.rb
CHANGED
@@ -170,4 +170,73 @@ describe Nemah::Ration do
|
|
170
170
|
Nemah::Ration.new(need, fodder_list)
|
171
171
|
end
|
172
172
|
end
|
173
|
+
|
174
|
+
shared_examples_for 'the total of a nutrient' do
|
175
|
+
it 'returns the total nutritional value of a nutrient for all fodders' do
|
176
|
+
need = double('fake_need', nutrient => double("fake_#{nutrient}", unit: unit))
|
177
|
+
hay = Nemah::Fodder.new('hay', nutrient => 12)
|
178
|
+
grass = Nemah::Fodder.new('grass', nutrient => 2.6)
|
179
|
+
fodders = { hay => 5, grass => 8 }
|
180
|
+
fodder_list = Nemah::FodderList.new(fodders)
|
181
|
+
rations = Nemah::Ration.new(need, fodder_list)
|
182
|
+
|
183
|
+
expect(rations.public_send("total_#{nutrient}")).to eq expected
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe '#total_energy' do
|
188
|
+
it_behaves_like 'the total of a nutrient' do
|
189
|
+
let(:nutrient) { :energy }
|
190
|
+
let(:unit) { :MJ }
|
191
|
+
let(:expected) { 80.8 }
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
describe '#total_protein' do
|
196
|
+
it_behaves_like 'the total of a nutrient' do
|
197
|
+
let(:nutrient) { :protein }
|
198
|
+
let(:unit) { :g }
|
199
|
+
let(:expected) { 80.8 }
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe '#total_calcium' do
|
204
|
+
it_behaves_like 'the total of a nutrient' do
|
205
|
+
let(:nutrient) { :calcium }
|
206
|
+
let(:unit) { :g }
|
207
|
+
let(:expected) { 80.8 }
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe '#total_phosphor' do
|
212
|
+
it_behaves_like 'the total of a nutrient' do
|
213
|
+
let(:nutrient) { :phosphor }
|
214
|
+
let(:unit) { :g }
|
215
|
+
let(:expected) { 80.8 }
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe '#total_selenium' do
|
220
|
+
it_behaves_like 'the total of a nutrient' do
|
221
|
+
let(:nutrient) { :selenium }
|
222
|
+
let(:unit) { :mg }
|
223
|
+
let(:expected) { 80.8 }
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe '#total_salt' do
|
228
|
+
it_behaves_like 'the total of a nutrient' do
|
229
|
+
let(:nutrient) { :salt }
|
230
|
+
let(:unit) { :g }
|
231
|
+
let(:expected) { 80.8 }
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe '#total_solids' do
|
236
|
+
it_behaves_like 'the total of a nutrient' do
|
237
|
+
let(:nutrient) { :solids }
|
238
|
+
let(:unit) { :kg }
|
239
|
+
let(:expected) { 0.808 }
|
240
|
+
end
|
241
|
+
end
|
173
242
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nemah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kim Persson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|