amee-data-abstraction 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/CHANGELOG.txt +3 -0
  2. data/README.txt +28 -15
  3. data/Rakefile +1 -16
  4. data/VERSION +1 -1
  5. data/amee-data-abstraction.gemspec +6 -5
  6. data/lib/amee-data-abstraction/calculation.rb +1 -1
  7. data/lib/amee-data-abstraction/calculation_set.rb +152 -10
  8. data/lib/amee-data-abstraction/drill.rb +8 -2
  9. data/lib/amee-data-abstraction/input.rb +24 -0
  10. data/lib/amee-data-abstraction/ongoing_calculation.rb +13 -9
  11. data/lib/amee-data-abstraction/term.rb +31 -13
  12. data/spec/amee-data-abstraction/calculation_set_spec.rb +244 -8
  13. data/spec/amee-data-abstraction/calculation_spec.rb +23 -18
  14. data/spec/amee-data-abstraction/drill_spec.rb +34 -7
  15. data/spec/amee-data-abstraction/input_spec.rb +113 -73
  16. data/spec/amee-data-abstraction/metadatum_spec.rb +1 -1
  17. data/spec/amee-data-abstraction/ongoing_calculation_spec.rb +45 -29
  18. data/spec/amee-data-abstraction/profile_spec.rb +2 -2
  19. data/spec/amee-data-abstraction/prototype_calculation_spec.rb +12 -8
  20. data/spec/amee-data-abstraction/term_spec.rb +49 -5
  21. data/spec/amee-data-abstraction/terms_list_spec.rb +16 -12
  22. data/spec/config/amee_units_spec.rb +1 -2
  23. data/spec/core-extensions/class_spec.rb +18 -18
  24. data/spec/core-extensions/hash_spec.rb +1 -2
  25. data/spec/core-extensions/ordered_hash_spec.rb +1 -2
  26. data/spec/core-extensions/proc_spec.rb +1 -1
  27. data/spec/fixtures/{electricity.rb → config/calculations/electricity.rb} +2 -2
  28. data/spec/fixtures/config/calculations/electricity_and_transport.rb +53 -0
  29. data/spec/fixtures/{transport.rb → config/calculations/transport.rb} +2 -2
  30. data/spec/fixtures/config/electricity.rb +35 -0
  31. data/spec/spec_helper.rb +38 -6
  32. metadata +8 -7
  33. data/spec/fixtures/electricity_and_transport.rb +0 -55
@@ -1,21 +1,30 @@
1
- require File.dirname(File.dirname(__FILE__)) + '/spec_helper.rb'
1
+ require 'spec_helper'
2
+
2
3
  describe Drill do
4
+
5
+
6
+ before :all do
7
+ @calc = CalculationSet.find("transport")[:transport]
8
+ end
9
+
3
10
  it 'knows its options when it is the first choice' do
4
11
  AMEEMocker.new(self,:path=>'transport/car/generic',
5
12
  :selections=>[],
6
13
  :choices=>['diesel','petrol']).drill
7
- Transport.begin_calculation[:fuel].send(:choices).should eql ['diesel','petrol']
14
+ @calc.begin_calculation[:fuel].send(:choices).should eql ['diesel','petrol']
8
15
  end
16
+
9
17
  it 'knows its options when it is a later choice' do
10
18
  AMEEMocker.new(self,:path=>'transport/car/generic',
11
19
  :selections=>[['fuel','diesel']],
12
20
  :choices=>['large','small']).drill
13
- t=Transport.begin_calculation
21
+ t=@calc.begin_calculation
14
22
  t[:fuel].value 'diesel'
15
23
  t[:size].send(:choices).should eql ['large','small']
16
24
  end
17
- it 'is enabled iff it is the next choice or has been chosen' do
18
- t=Transport.begin_calculation
25
+
26
+ it 'is enabled if it is the next choice or has been chosen' do
27
+ t=@calc.begin_calculation
19
28
  t[:fuel].enabled?.should be_true
20
29
  t[:size].enabled?.should be_false
21
30
  t[:fuel].value 'diesel'
@@ -25,14 +34,32 @@ describe Drill do
25
34
  t[:fuel].enabled?.should be_true
26
35
  t[:size].enabled?.should be_true
27
36
  end
28
- it 'is valid iff assigned a choice in the choices' do
37
+
38
+ it 'is valid if assigned a choice in the choices' do
29
39
  AMEEMocker.new(self,:path=>'transport/car/generic',
30
40
  :selections=>[],
31
41
  :choices=>['diesel','petrol']).drill
32
- t=Transport.begin_calculation
42
+ t=@calc.begin_calculation
33
43
  t[:fuel].value 'diesel'
34
44
  t[:fuel].send(:valid?).should be_true
35
45
  t[:fuel].value 'banana'
36
46
  t[:fuel].send(:valid?).should be_false
37
47
  end
48
+
49
+ it "should set and get custom choices" do
50
+ t=@calc.begin_calculation
51
+ t[:fuel].choices 'anthracite', 'lignite'
52
+ t[:fuel].choices.should eql ['anthracite', 'lignite']
53
+ end
54
+
55
+ it 'is sets correct single choice if AMEE skips during drill' do
56
+ mocker = AMEEMocker.new(self,:path=>'transport/car/generic',
57
+ :selections=>[['fuel','diesel']])
58
+ mocker.drill_with_skip('size'=>'small')
59
+ t=@calc.begin_calculation
60
+ t[:fuel].value 'diesel'
61
+ t[:fuel].should_not be_disabled
62
+ t[:size].choices.should eql ['small']
63
+ t[:size].should be_disabled
64
+ end
38
65
  end
@@ -1,77 +1,117 @@
1
- require File.dirname(File.dirname(__FILE__)) + '/spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Input do
4
- it 'can be given a fixed value' do
5
- i=Input.new{fixed 6}
6
- i.value.should eql 6
7
- i.fixed?.should be_true
8
- lambda{i.value 7}.should raise_error Exceptions::FixedValueInterference
9
- end
10
- it 'raises exception when invalid' do
11
- i=Input.new{validation /bark/}
12
- i.value 'barking'
13
- lambda{i.validate!}.should_not raise_error
14
- i.value.should eql 'barking'
15
- i.value 'marking'
16
- lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation
17
- j=Input.new{}
18
- j.value 'marking'
19
- j.value.should eql 'marking'
20
- end
21
- it "can accept a numeric symbol validation" do
22
- i=Input.new{validation :numeric}
23
- i.value 3
24
- lambda{i.validate!}.should_not raise_error
25
- i.value '3'
26
- lambda{i.validate!}.should_not raise_error
27
- i.value 'e'
28
- lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation
29
- end
30
- it "can accept a date symbol validation" do
31
- i=Input.new{validation :date}
32
- i.value Date.today
33
- lambda{i.validate!}.should_not raise_error
34
- i.value '2011-01-01'
35
- lambda{i.validate!}.should_not raise_error
36
- i.value 'e'
37
- lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation
38
- end
4
+
5
+ it 'can be given a fixed value' do
6
+ i=Input.new{fixed 6}
7
+ i.value.should eql 6
8
+ i.fixed?.should be_true
9
+ lambda{i.value 7}.should raise_error Exceptions::FixedValueInterference
10
+ end
39
11
 
40
- it "can accept a time symbol validation" do
41
- i=Input.new{validation :datetime}
42
- i.value DateTime.now
43
- lambda{i.validate!}.should_not raise_error
44
- i.value '2011-01-01 09:00:00'
45
- lambda{i.validate!}.should_not raise_error
46
- i.value 'e'
47
- lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation
48
- end
49
- it 'can have custom validation message' do
50
- i=Input.new{label :woof; validation /bark/; validation_message {"#{value} does not match pattern /bark/"}}
51
- i.value 'marking'
52
- lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation,"marking does not match pattern /bark/"
53
- j=Input.new{}
54
- j.value 'marking'
55
- j.value.should eql 'marking'
56
- end
57
- it 'can have default validation message' do
58
- i=Input.new{label :woof; validation /bark/}
59
- i.value 'barking'
60
- lambda{i.validate!}.should_not raise_error
61
- i.value.should eql 'barking'
62
- i.value 'marking'
63
- lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation,"Woof is invalid."
64
- j=Input.new{}
65
- j.value 'marking'
66
- j.value.should eql 'marking'
67
- end
68
- it 'is always valid if it is fixed' do
69
- i=Input.new{fixed 5; validation /7/}
70
- lambda{i.validate!}.should_not raise_error
71
- i.value.should eql 5
72
- end
73
- it 'is always disabled if it is fixed' do
74
- i=Input.new{fixed 5}
75
- i.disabled?.should eql true
76
- end
12
+ it "can be made optional" do
13
+ i=Input.new{label :mass; value 6}
14
+ i.should_not be_optional
15
+ i.should be_compulsory
16
+ i.optional!
17
+ i.should be_optional
18
+ i.should_not be_compulsory
19
+ end
20
+
21
+ it "can be made compulsory" do
22
+ i=Input.new{label :mass; value 6}
23
+ i.should_not be_optional
24
+ i.optional!
25
+ i.should be_optional
26
+ i.should_not be_compulsory
27
+ i.compulsory!
28
+ i.should_not be_optional
29
+ i.should be_compulsory
30
+ end
31
+
32
+ it 'raises exception when invalid' do
33
+ i=Input.new{validation /bark/}
34
+ i.value 'barking'
35
+ lambda{i.validate!}.should_not raise_error
36
+ i.value.should eql 'barking'
37
+ i.value 'marking'
38
+ lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation
39
+ j=Input.new{}
40
+ j.value 'marking'
41
+ j.value.should eql 'marking'
42
+ end
43
+
44
+ it "can accept a numeric symbol validation" do
45
+ i=Input.new{validation :numeric}
46
+ i.value 3
47
+ lambda{i.validate!}.should_not raise_error
48
+ i.value '3'
49
+ lambda{i.validate!}.should_not raise_error
50
+ i.value 'e'
51
+ lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation
52
+ end
53
+
54
+ it "can accept a date symbol validation" do
55
+ i=Input.new{validation :date}
56
+ i.value Date.today
57
+ lambda{i.validate!}.should_not raise_error
58
+ i.value '2011-01-01'
59
+ lambda{i.validate!}.should_not raise_error
60
+ i.value 'e'
61
+ lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation
62
+ end
63
+
64
+ it "can accept a time symbol validation" do
65
+ i=Input.new{validation :datetime}
66
+ i.value DateTime.now
67
+ lambda{i.validate!}.should_not raise_error
68
+ i.value '2011-01-01 09:00:00'
69
+ lambda{i.validate!}.should_not raise_error
70
+ i.value 'e'
71
+ lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation
72
+ end
73
+
74
+ it "should start with dirty set as false" do
75
+ i=Input.new{fixed 5}
76
+ i.dirty?.should eql false
77
+ end
78
+
79
+ it "should be dirty when the value is changed" do
80
+ i=Input.new
81
+ i.value 5
82
+ i.dirty?.should eql true
83
+ end
84
+
85
+ it 'can have custom validation message' do
86
+ i=Input.new{label :woof; validation /bark/; validation_message {"#{value} does not match pattern /bark/"}}
87
+ i.value 'marking'
88
+ lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation,"marking does not match pattern /bark/"
89
+ j=Input.new{}
90
+ j.value 'marking'
91
+ j.value.should eql 'marking'
92
+ end
93
+
94
+ it 'can have default validation message' do
95
+ i=Input.new{label :woof; validation /bark/}
96
+ i.value 'barking'
97
+ lambda{i.validate!}.should_not raise_error
98
+ i.value.should eql 'barking'
99
+ i.value 'marking'
100
+ lambda{i.validate!}.should raise_error Exceptions::ChoiceValidation,"Woof is invalid."
101
+ j=Input.new{}
102
+ j.value 'marking'
103
+ j.value.should eql 'marking'
104
+ end
105
+
106
+ it 'is always valid if it is fixed' do
107
+ i=Input.new{fixed 5; validation /7/}
108
+ lambda{i.validate!}.should_not raise_error
109
+ i.value.should eql 5
110
+ end
111
+
112
+ it 'is always disabled if it is fixed' do
113
+ i=Input.new{fixed 5}
114
+ i.disabled?.should eql true
115
+ end
116
+
77
117
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(File.dirname(__FILE__)) + '/spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Metadatum do
4
4
  it 'defaults to be a drop-down' do
@@ -1,7 +1,15 @@
1
- require File.dirname(File.dirname(__FILE__)) + '/spec_helper.rb'
1
+ require 'spec_helper'
2
+
2
3
  describe OngoingCalculation do
4
+
5
+ before :all do
6
+ @elec = CalculationSet.find("electricity")[:electricity]
7
+ @transport = CalculationSet.find("transport")[:transport]
8
+ @elec_and_transport = CalculationSet.find("electricity_and_transport")
9
+ end
10
+
3
11
  it 'can return set and unset inputs' do
4
- d=Electricity.begin_calculation
12
+ d=@elec.begin_calculation
5
13
  d.inputs.set.labels.should eql [:country]
6
14
  d.inputs.unset.labels.should eql [:energy_used]
7
15
  d[:energy_used].value :somevalue
@@ -9,7 +17,7 @@ describe OngoingCalculation do
9
17
  d.inputs.unset.labels.should eql []
10
18
  end
11
19
  it 'can return set and unset terms' do
12
- d=Electricity.begin_calculation
20
+ d=@elec.begin_calculation
13
21
  d.set.labels.should eql [:country]
14
22
  d.unset.labels.should eql [:energy_used,:co2]
15
23
  d[:energy_used].value :somevalue
@@ -17,19 +25,27 @@ describe OngoingCalculation do
17
25
  d.unset.labels.should eql [:co2]
18
26
  end
19
27
  it 'can return set and unset outputs' do
20
- d=Electricity.begin_calculation
28
+ d=@elec.begin_calculation
21
29
  d.outputs.set.labels.should eql []
22
30
  d.outputs.unset.labels.should eql [:co2]
23
31
  d[:co2].value 5
24
32
  d.outputs.set.labels.should eql [:co2]
25
33
  d.outputs.unset.labels.should eql []
26
34
  end
35
+ it 'can clear outputs' do
36
+ d=@elec.begin_calculation
37
+ d.outputs.unset.labels.should eql [:co2]
38
+ d[:co2].value 5
39
+ d[:co2].value.should eql 5
40
+ d.clear_outputs
41
+ d[:co2].value.should be_nil
42
+ end
27
43
  it 'can have values chosen' do
28
44
  AMEEMocker.new(self,:path=>'business/energy/electricity/grid',
29
45
  :selections=>[['country','argentina']],
30
46
  :choices=>[]).drill
31
47
 
32
- d=Electricity.begin_calculation
48
+ d=@elec.begin_calculation
33
49
 
34
50
  d.inputs.set.values.should eql ['argentina']
35
51
  d.inputs.unset.values.should eql [nil]
@@ -43,7 +59,7 @@ describe OngoingCalculation do
43
59
  AMEEMocker.new(self,:path=>'business/energy/electricity/grid',
44
60
  :selections=>[['country','argentina']],
45
61
  :choices=>[]).drill
46
- d=Electricity.begin_calculation
62
+ d=@elec.begin_calculation
47
63
  d.satisfied?.should be_false
48
64
  d.choose!(:energy_used=>5.0)
49
65
  d.satisfied?.should be_true
@@ -58,7 +74,7 @@ describe OngoingCalculation do
58
74
  mocker.select('size'=>'large')
59
75
  mocker.choices=[]
60
76
  mocker.drill
61
- t=Transport.begin_calculation
77
+ t=@transport.begin_calculation
62
78
  t.terms.labels.should eql [:fuel,:size,:distance,:co2]
63
79
  t.satisfied?.should be_false
64
80
 
@@ -67,13 +83,13 @@ describe OngoingCalculation do
67
83
  t.inputs.unset.labels.should eql [:size,:distance]
68
84
  t.satisfied?.should be_false
69
85
 
70
- t2=Transport.begin_calculation
86
+ t2=@transport.begin_calculation
71
87
  t2.choose!('fuel'=>'diesel','size'=>'large')
72
88
  t2.inputs.set.labels.should eql [:fuel,:size]
73
89
  t2.inputs.unset.labels.should eql [:distance]
74
90
  t2.satisfied?.should be_false
75
91
 
76
- t3=Transport.begin_calculation
92
+ t3=@transport.begin_calculation
77
93
  t3.choose!('fuel'=>'diesel','size'=>'large','distance'=>5)
78
94
  t3.inputs.set.labels.should eql [:fuel,:size,:distance]
79
95
  t3.inputs.unset.labels.should eql []
@@ -92,7 +108,7 @@ describe OngoingCalculation do
92
108
  mocker.choices=[]
93
109
  mocker.drill
94
110
  mocker.profile_list.profile_category.timestamp.create_and_get
95
- mycalc=Transport.begin_calculation
111
+ mycalc=@transport.begin_calculation
96
112
  mycalc.choose!('fuel'=>'diesel','size'=>'large','distance'=>5)
97
113
  mycalc.calculate!
98
114
  mycalc.outputs.first.value.should eql :somenumber
@@ -110,7 +126,7 @@ describe OngoingCalculation do
110
126
  mocker.choices=[]
111
127
  mocker.drill
112
128
  mocker.profile_list.profile_category.timestamp.create_and_get
113
- mycalc=ElectricityAndTransport[:transport].begin_calculation
129
+ mycalc=@elec_and_transport[:transport].begin_calculation
114
130
  mycalc.choose!('fuel'=>'diesel','size'=>'large','distance'=>5,'department'=>'stuff')
115
131
  mycalc.calculate!
116
132
  mycalc.outputs.first.value.should eql :somenumber
@@ -134,7 +150,7 @@ describe OngoingCalculation do
134
150
  #end
135
151
 
136
152
  it 'can be supplied just a UID, and recover PIVs and drill values from AMEE' do
137
- mycalc=Transport.begin_calculation
153
+ mycalc=@transport.begin_calculation
138
154
  mocker=AMEEMocker.new(self,:path=>'transport/car/generic',
139
155
  :result=>:somenumber,
140
156
  :existing=>{'distance'=>5},:choices=>['petrol','diesel'])
@@ -151,7 +167,7 @@ describe OngoingCalculation do
151
167
  end
152
168
 
153
169
  it 'refuses to load values from AMEE which conflict with local drill values' do
154
- mycalc=Transport.begin_calculation
170
+ mycalc=@transport.begin_calculation
155
171
  mocker=AMEEMocker.new(self,:path=>'transport/car/generic',
156
172
  :result=>:somenumber,
157
173
  :existing=>{'distance'=>7},
@@ -187,7 +203,7 @@ describe OngoingCalculation do
187
203
  mocker.choices=[]
188
204
  mocker.drill
189
205
  mocker.profile_list.update.get(true)
190
- mycalc=Transport.begin_calculation
206
+ mycalc=@transport.begin_calculation
191
207
  mycalc.choose!(:profile_item_uid=>mocker.uid,'fuel'=>'diesel','size'=>'large','distance'=>9)
192
208
  mycalc.calculate!
193
209
  mycalc[:distance].value.should eql 9
@@ -211,7 +227,7 @@ describe OngoingCalculation do
211
227
  mocker.params={'distance'=>9}
212
228
  mocker.update.get(true)
213
229
 
214
- mycalc=Transport.begin_calculation
230
+ mycalc=@transport.begin_calculation
215
231
  mycalc.choose!('fuel'=>'diesel','size'=>'large','distance'=>5)
216
232
  mycalc.calculate!
217
233
  mycalc.choose!('fuel'=>'diesel','size'=>'large','distance'=>9)
@@ -236,7 +252,7 @@ describe OngoingCalculation do
236
252
  mocker.select('size'=>'small')
237
253
  mocker.drill.create_and_get
238
254
 
239
- mycalc=Transport.begin_calculation
255
+ mycalc=@transport.begin_calculation
240
256
  mycalc.choose!('fuel'=>'diesel','size'=>'large','distance'=>5)
241
257
  mycalc.calculate!
242
258
  mycalc.choose!('fuel'=>'diesel','size'=>'small')
@@ -245,7 +261,7 @@ describe OngoingCalculation do
245
261
  end
246
262
 
247
263
  it 'memoizes profile information, but not across a pass' do
248
- mycalc=Transport.begin_calculation
264
+ mycalc=@transport.begin_calculation
249
265
  mocker=AMEEMocker.new(self,:path=>'transport/car/generic',
250
266
  :result=>:somenumber,
251
267
  :existing=>{'distance'=>5},:choices=>['petrol','diesel'])
@@ -277,7 +293,7 @@ describe OngoingCalculation do
277
293
  mocker.choices=[]
278
294
  mocker.drill
279
295
  mocker.profile_list.profile_category.timestamp.create_and_get
280
- myproto=Transport.clone
296
+ myproto=@transport.clone
281
297
  myproto.instance_eval{
282
298
  start_and_end_dates
283
299
  }
@@ -300,7 +316,7 @@ describe OngoingCalculation do
300
316
  mocker.select('size'=>'large')
301
317
  mocker.choices=[]
302
318
  mocker.drill
303
- myproto=Transport.clone
319
+ myproto=@transport.clone
304
320
  myproto.instance_eval{
305
321
  start_and_end_dates
306
322
  }
@@ -310,7 +326,7 @@ describe OngoingCalculation do
310
326
  end
311
327
 
312
328
  it 'starts off dirty' do
313
- mycalc=Transport.begin_calculation
329
+ mycalc=@transport.begin_calculation
314
330
  mycalc.should be_dirty
315
331
  end
316
332
 
@@ -327,7 +343,7 @@ describe OngoingCalculation do
327
343
  mocker.choices=[]
328
344
  mocker.drill
329
345
  mocker.profile_list.profile_category.timestamp.create_and_get
330
- mycalc=Transport.begin_calculation
346
+ mycalc=@transport.begin_calculation
331
347
  mycalc.should be_dirty
332
348
  mycalc.choose!('fuel'=>'diesel','size'=>'large','distance'=>5)
333
349
  mycalc.calculate!
@@ -349,7 +365,7 @@ describe OngoingCalculation do
349
365
  mocker.choices=[]
350
366
  mocker.drill
351
367
  mocker.profile_list.profile_category.timestamp.create_and_get
352
- mycalc=Transport.begin_calculation
368
+ mycalc=@transport.begin_calculation
353
369
  mycalc.should be_dirty
354
370
  mycalc.choose!('fuel'=>'diesel','size'=>'large','distance'=>5)
355
371
  mycalc.calculate!
@@ -372,7 +388,7 @@ describe OngoingCalculation do
372
388
  mocker.select('size'=>'marge')
373
389
  mocker.choices=[]
374
390
  mocker.drill
375
- mycalc=Transport.begin_calculation
391
+ mycalc=@transport.begin_calculation
376
392
  lambda{mycalc.choose!('fuel'=>'diesel','size'=>'marge','distance'=>5)}.should raise_error Exceptions::ChoiceValidation
377
393
  mycalc.invalidity_messages.keys.should eql [:size]
378
394
  end
@@ -389,7 +405,7 @@ describe OngoingCalculation do
389
405
  mocker.select('size'=>'marge')
390
406
  mocker.choices=[]
391
407
  mocker.drill
392
- mycalc=Transport.begin_calculation
408
+ mycalc=@transport.begin_calculation
393
409
  mycalc.choose('fuel'=>'diesel','size'=>'marge','distance'=>5).should be_false
394
410
  mycalc.invalidity_messages.keys.should eql [:size]
395
411
  end
@@ -406,12 +422,12 @@ describe OngoingCalculation do
406
422
  mocker.select('size'=>'large')
407
423
  mocker.choices=[]
408
424
  mocker.drill
409
- mycalc=Transport.begin_calculation
425
+ mycalc=@transport.begin_calculation
410
426
  mycalc.choose('fuel'=>'diesel','size'=>'large','distance'=>5).should be_true
411
427
  end
412
428
 
413
429
  it 'can blank individual term attributes with empty string' do
414
- myproto=Transport.clone
430
+ myproto=@transport.clone
415
431
  mycalc=myproto.begin_calculation
416
432
  mycalc.choose_without_validation!('fuel'=>'diesel','size'=>'large','distance'=>{:value =>5, :unit=> Unit.km})
417
433
  mycalc['fuel'].value.should eql 'diesel'
@@ -426,7 +442,7 @@ describe OngoingCalculation do
426
442
  end
427
443
 
428
444
  it 'can blank individual term attributes with nil' do
429
- myproto=Transport.clone
445
+ myproto=@transport.clone
430
446
  mycalc=myproto.begin_calculation
431
447
  mycalc.choose_without_validation!('fuel'=>'diesel','size'=>'large','distance'=>{:value =>5, :unit=> Unit.km})
432
448
  mycalc['fuel'].value.should eql 'diesel'
@@ -441,7 +457,7 @@ describe OngoingCalculation do
441
457
  end
442
458
 
443
459
  it 'can update individual term attributes without nullifying others' do
444
- myproto=Transport.clone
460
+ myproto=@transport.clone
445
461
  mycalc=myproto.begin_calculation
446
462
  mycalc.choose_without_validation!('fuel'=>'diesel','size'=>'large','distance'=>{:value =>5, :unit=> Unit.km})
447
463
  mycalc['fuel'].value.should eql 'diesel'
@@ -482,7 +498,7 @@ describe OngoingCalculation do
482
498
  mocker.select('size'=>'marge')
483
499
  mocker.choices=[]
484
500
  mocker.drill
485
- mycalc=Transport.begin_calculation
501
+ mycalc=@transport.begin_calculation
486
502
  mycalc.choose('fuel'=>'diesel','size'=>'marge','distance'=>5).should be_false
487
503
  mycalc.invalidity_messages.keys.should eql [:size]
488
504
  mycalc[:size].value.should eql 'marge'