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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cf97baf48299379410e2eba6a236517e9f466c3
4
- data.tar.gz: 164041b7b1042eaacabcbe5d08169d08c9cee769
3
+ metadata.gz: f0a20a9d85e8d302565a1a258b5f458e07db694f
4
+ data.tar.gz: bf21a669e521a9a061f4ce4ade75e6b70bac309e
5
5
  SHA512:
6
- metadata.gz: d3d16f09f03c521916efbf78140e8c6644eccfa664a7096462131a5612c96255fa08635b7a8cd01c07bbf60dd5a7a79a4bef02e42382ca41f5299638d46ce93f
7
- data.tar.gz: f76931c24a2c49dd9ee521d508bf824d76fa34a6b6bbfb77dee2424c6fd8929b26bf4156967250619fe9578acfe3615facdb3caf63de6c92db645865004d9d29
6
+ metadata.gz: 45ad23b5bcda18eea0b1e3f2a701a8012391ffaf94a9964e543aef0c1a2ba88bb516ae76042e398e130fdd86a5cc1f934a5ce8d1e3d2f6ca1689f4849004f3ca
7
+ data.tar.gz: 22babc655a4e9425ba6a366fd9943aa4ce70b15173908d7d66e08d6ed8c10deba4ea51a5703b837dd7a4e8b6679edb4859680c4e17fcf56f8025898ea42c951f
@@ -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| # def enough_nutrient?
27
- define_method("enough_#{nutrient}?") { enough?(nutrient) } # enough?(:nutrient)
28
- end # end
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
 
@@ -1,3 +1,3 @@
1
1
  module Nemah
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -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.2.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-08 00:00:00.000000000 Z
12
+ date: 2014-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler