spec/amee/analytics/calculation_collection_spec.rb in amee-analytics-1.1.0 vs spec/amee/analytics/calculation_collection_spec.rb in amee-analytics-2.0.0
- old
+ new
@@ -3,10 +3,11 @@
include AMEE::DataAbstraction
describe CalculationCollection do
before(:each) do
+ initialize_calculation_set
@calcs = []
@calcs << add_elec_calc(500,240)
@calcs << add_elec_calc(1000,480)
@calcs << add_elec_calc(1234,600)
@coll = CalculationCollection.new @calcs
@@ -142,19 +143,19 @@
@coll.first['usage'].unit 'J'
@coll.first['usage'].value.should eql 500
@coll.first['usage'].unit.label.should eql 'J'
@coll.standardize_units!(:usage,:kWh)
@coll.first['usage'].unit 'kWh'
- @coll.first['usage'].value.should be_close 0.000138888888888889,0.000001
+ @coll.first['usage'].value.should be_within(0.000001).of(0.000138888888888889)
end
it "should standardize units returning new collection" do
@coll.first['co2'].value.should eql 240
@coll.first['co2'].unit.label.should eql 't'
coll = @coll.standardize_units(:co2,:lb)
coll.first['co2'].unit 'lb'
- coll.first['co2'].value.should be_close 529109.429243706,0.01
+ coll.first['co2'].value.should be_within(0.01).of(529109.429243706)
end
it "should handle 'type' as a terms filter" do
calcs = []
calcs << add_transport_calc(500,240)
@@ -199,14 +200,14 @@
@coll3.first['distance'].value.should eql 1234
end
it "should add to calculation collection using += syntax" do
@coll = CalculationCollection.new
- @coll += add_transport_calc(500,240)
+ @coll += [add_transport_calc(500,240)]
@coll.should be_a CalculationCollection
- @coll += add_transport_calc(1000,480)
+ @coll += [add_transport_calc(1000,480)]
@coll.should be_a CalculationCollection
- @coll += add_transport_calc(1234,600)
+ @coll += [add_transport_calc(1234,600)]
@coll.should be_a CalculationCollection
@coll.size.should eql 3
end
it "should subtract from calculation collection using -= syntax" do
\ No newline at end of file