spec/nsdate_spec.rb in sugarcube-0.20.1 vs spec/nsdate_spec.rb in sugarcube-0.20.3
- old
+ new
@@ -5,9 +5,40 @@
date.year.should == 2012
date.month.should == 1
date.day.should == 2
end
+ it "Should have an NSDate##today method" do
+ now = NSDate.new
+ date = NSDate.today
+ date.year.should == now.year
+ date.month.should == now.month
+ date.day.should == now.day
+ date.hour.should == 0
+ date.min.should == 0
+ date.sec.should == 0
+ end
+
+ it "Should have an NSDate##yesterday method" do
+ now = NSDate.today
+ date = NSDate.yesterday
+ date.hour.should == 0
+ date.min.should == 0
+ date.sec.should == 0
+ (now - date).in_hours.should >= 23 # keep in mind daylight
+ (now - date).in_hours.should <= 25 # savings time.
+ end
+
+ it "Should have an NSDate##tomorrow method" do
+ now = NSDate.today
+ date = NSDate.tomorrow
+ date.hour.should == 0
+ date.min.should == 0
+ date.sec.should == 0
+ (date - now).in_hours.should >= 23 # keep in mind daylight
+ (date - now).in_hours.should <= 25 # savings time.
+ end
+
before do
@date = NSDate.from_components(year: 2013, month: 1, day: 2, hour:12, minute: 15, second: 30)
end
it "should have an NSDate#string_with_style(date_style, time_style) method that accepts symbols" do