spec/time_spec.rb in time_distribution-2.1.2 vs spec/time_spec.rb in time_distribution-2.1.3
- old
+ new
@@ -3,21 +3,27 @@
require 'chronic'
include TimeDistribution
using TimeRefinement
+def hours_in_seconds(hours)
+ return hours * 60 * 60
+end
+
+DATE_TO_AVOID_DSL_PROBLEMS = '1/01/0001'
+
describe Time do
describe '#count_forward_to' do
it 'counts duration properly when both times are in AM' do
- Chronic.parse('10am').count_forward_to(Chronic.parse('11:30am')).must_equal 1.5.hours
+ Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 10am").count_forward_to(Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 11:30am")).must_equal hours_in_seconds(1.5)
end
it 'counts duration properly when both times are in PM' do
- Chronic.parse('10pm').count_forward_to(Chronic.parse('11:30pm')).must_equal 1.5.hours
+ Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 10pm").count_forward_to(Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 11:30pm")).must_equal hours_in_seconds(1.5)
end
it 'counts duration properly when it crosses from AM to PM' do
- Chronic.parse('11am').count_forward_to(Chronic.parse('12:30pm')).must_equal 1.5.hours
+ Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 11am").count_forward_to(Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 12:30pm")).must_equal hours_in_seconds(1.5)
end
it 'counts duration properly when it crosses from PM to AM' do
- Chronic.parse('11pm').count_forward_to(Chronic.parse('12:30am')).must_equal 1.5.hours
+ Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 11pm").count_forward_to(Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 12:30am")).must_equal hours_in_seconds(1.5)
end
end
end
\ No newline at end of file