spec/FitFile_spec.rb in fit4ruby-0.0.4 vs spec/FitFile_spec.rb in fit4ruby-0.0.5
- old
+ new
@@ -14,18 +14,19 @@
describe Fit4Ruby do
before(:each) do
a = Fit4Ruby::Activity.new
- a.total_timer_time = 30 * 60
+ a.total_timer_time = 30 * 60.0
a.new_user_profile({ :age => 33, :height => 1.78, :weight => 73.0,
:gender => 'male', :activity_class => 4.0,
:max_hr => 178 })
a.new_event({ :event => 'timer', :event_type => 'start_time' })
- a.new_device_info({ :device_index => 0 })
- a.new_device_info({ :device_index => 1, :battery_status => 'ok' })
+ a.new_device_info({ :device_index => 0, :manufacturer => 'garmin' })
+ a.new_device_info({ :device_index => 1, :manufacturer => 'garmin',
+ :battery_status => 'ok' })
ts = Time.now
0.upto(a.total_timer_time / 60) do |mins|
ts += 60
a.new_record({
:timestamp => ts,
@@ -42,28 +43,30 @@
:activity_type => 'running',
:fractional_cadence => (mins % 2) / 2.0
})
if mins > 0 && mins % 5 == 0
- a.new_lap({ :timestamp => ts })
+ a.new_lap({ :timestamp => ts, :sport => 'running',
+ :total_cycles => 195 })
end
end
- a.new_session({ :timestamp => ts })
+ a.new_session({ :timestamp => ts, :sport => 'running' })
a.new_event({ :timestamp => ts, :event => 'recovery_time',
:event_type => 'marker',
- :data => 2160 })
+ :recovery_time => 2160 })
a.new_event({ :timestamp => ts, :event => 'vo2max',
- :event_type => 'marker', :data => 52 })
+ :event_type => 'marker', :vo2max => 52 })
a.new_event({ :timestamp => ts, :event => 'timer',
:event_type => 'stop_all' })
- a.new_device_info({ :timestamp => ts, :device_index => 0 })
+ a.new_device_info({ :timestamp => ts, :device_index => 0,
+ :manufacturer => 'garmin' })
ts += 1
- a.new_device_info({ :timestamp => ts, :device_index => 1,
- :battery_status => 'low' })
+ a.new_device_info({ :timestamp => ts, :manufacturer => 'garmin',
+ :device_index => 1, :battery_status => 'low' })
ts += 120
a.new_event({ :timestamp => ts, :event => 'recovery_hr',
- :event_type => 'marker', :data => 132 })
+ :event_type => 'marker', :recovery_hr => 132 })
a.aggregate
@activity = a
end
@@ -72,13 +75,14 @@
fit_file = 'test.fit'
File.delete(fit_file) if File.exists?(fit_file)
Fit4Ruby.write(fit_file, @activity)
File.exists?(fit_file).should be_true
+ puts File.absolute_path(fit_file)
b = Fit4Ruby.read(fit_file)
b.should == @activity
- #File.delete(fit_file)
+ File.delete(fit_file)
end
end