From 811389afafec068262fba4ce56ad0b757b7e4cc2 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 19 Jul 2010 10:38:53 +0300 Subject: [PATCH] updated, cleaned up, and fixed a bug in the Redistat::Date spec --- spec/date_spec.rb | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/spec/date_spec.rb b/spec/date_spec.rb index 13e9cc9..1a3f56d 100644 --- a/spec/date_spec.rb +++ b/spec/date_spec.rb @@ -37,19 +37,13 @@ describe Redistat::Date do it "should convert to string with correct depths" do today = Date.today - rdate = Redistat::Date.new(today) - props = [:year, :month, :day, nil] - props.each do - rdate.to_s(props.last).should == props.map { |k| today.send(k).to_s.rjust(2, '0') if !k.nil? }.join - props.pop - end - now = Time.now - rdate = Redistat::Date.new(now) - props = [:year, :month, :day, :hour, :min, :sec, nil] - props.each do - rdate.to_s(props.last).should == props.map { |k| now.send(k).to_s.rjust(2, '0') if !k.nil? }.join - props.pop + [[now, Redistat::Date.new(now)], [today, Redistat::Date.new(today)]].each do |current, rdate| + props = [:year, :month, :day, :hour, :min, :sec, nil] + props.clone.each do + rdate.to_s(props.last).should == props.map { |k| current.send(k).to_s.rjust(2, '0') if !k.nil? }.join + props.pop + end end end