diff options
Diffstat (limited to 'spec/ruby/library/date')
-rw-r--r-- | spec/ruby/library/date/day_spec.rb | 5 | ||||
-rw-r--r-- | spec/ruby/library/date/month_spec.rb | 5 | ||||
-rw-r--r-- | spec/ruby/library/date/next_month_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/library/date/prev_day_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/library/date/prev_month_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/library/date/year_spec.rb | 5 |
6 files changed, 54 insertions, 3 deletions
diff --git a/spec/ruby/library/date/day_spec.rb b/spec/ruby/library/date/day_spec.rb index 7dfca4d77c..d3561d802d 100644 --- a/spec/ruby/library/date/day_spec.rb +++ b/spec/ruby/library/date/day_spec.rb @@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "Date#day" do - it "needs to be reviewed for spec completeness" + it "returns the day" do + d = Date.new(2000, 7, 1).day + d.should == 1 + end end diff --git a/spec/ruby/library/date/month_spec.rb b/spec/ruby/library/date/month_spec.rb index 7a98f572b6..ea35430d6b 100644 --- a/spec/ruby/library/date/month_spec.rb +++ b/spec/ruby/library/date/month_spec.rb @@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "Date#month" do - it "needs to be reviewed for spec completeness" + it "returns the month" do + m = Date.new(2000, 7, 1).month + m.should == 7 + end end diff --git a/spec/ruby/library/date/next_month_spec.rb b/spec/ruby/library/date/next_month_spec.rb new file mode 100644 index 0000000000..22699a39a5 --- /dev/null +++ b/spec/ruby/library/date/next_month_spec.rb @@ -0,0 +1,14 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#next_month" do + it "returns the next month" do + d = Date.new(2000, 7, 1).next_month + d.should == Date.new(2000, 8, 1) + end + + it "returns three months later" do + d = Date.new(2000, 7, 1).next_month(3) + d.should == Date.new(2000, 10, 1) + end +end diff --git a/spec/ruby/library/date/prev_day_spec.rb b/spec/ruby/library/date/prev_day_spec.rb new file mode 100644 index 0000000000..8a42824154 --- /dev/null +++ b/spec/ruby/library/date/prev_day_spec.rb @@ -0,0 +1,14 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#prev_day" do + it "returns previous day" do + d = Date.new(2000, 7, 2).prev_day + d.should == Date.new(2000, 7, 1) + end + + it "returns three days ago" do + d = Date.new(2000, 7, 4).prev_day(3) + d.should == Date.new(2000, 7, 1) + end +end diff --git a/spec/ruby/library/date/prev_month_spec.rb b/spec/ruby/library/date/prev_month_spec.rb new file mode 100644 index 0000000000..eaf7f67ee0 --- /dev/null +++ b/spec/ruby/library/date/prev_month_spec.rb @@ -0,0 +1,14 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "Date#prev_month" do + it "returns previous month" do + d = Date.new(2000, 9, 1).prev_month + d.should == Date.new(2000, 8, 1) + end + + it "returns three months ago" do + d = Date.new(2000, 10, 1).prev_month(3) + d.should == Date.new(2000, 7, 1) + end +end diff --git a/spec/ruby/library/date/year_spec.rb b/spec/ruby/library/date/year_spec.rb index cca95dbe2a..4720ddcd9a 100644 --- a/spec/ruby/library/date/year_spec.rb +++ b/spec/ruby/library/date/year_spec.rb @@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' describe "Date#year" do - it "needs to be reviewed for spec completeness" + it "returns the year" do + y = Date.new(2000, 7, 1).year + y.should == 2000 + end end |