Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add specs for Forgery::Date.date

  • Loading branch information...
commit a56ddf80392899f1cff127e0c3eb76a5bb1a943e 1 parent 2707afb
Akira Matsuda authored April 25, 2011

Showing 1 changed file with 50 additions and 0 deletions. Show diff stats Hide diff stats

  1. 50  spec/forgery/date_spec.rb
50  spec/forgery/date_spec.rb
@@ -81,4 +81,54 @@
81 81
       (0..5).map { |i| Date.today.year - i - 5 }.should include(year)
82 82
     end
83 83
   end
  84
+
  85
+  describe '.date' do
  86
+    it 'should return a valid date within 7300 days of the current date' do
  87
+      date = Forgery::Date.date
  88
+      date.should > Date.today - 7300
  89
+      date.should < Date.today + 7300
  90
+    end
  91
+  end
  92
+
  93
+  describe '.date(:future => true)' do
  94
+    it 'should return a date greater than the current one' do
  95
+      date = Forgery::Date.date(:future => true)
  96
+      date.should >= Date.today
  97
+    end
  98
+  end
  99
+
  100
+  describe '.date(:min_delta => 5, :max_delta => 5, :future => true)' do
  101
+    it 'should return a date 5 days from the current one' do
  102
+      date = Forgery::Date.date(:min_delta => 5, :max_delta => 5, :future => true)
  103
+      date.should >= Date.today + 5
  104
+    end
  105
+  end
  106
+
  107
+  describe '.date(:min_delta => 5, :max_delta => 10, :future => true)' do
  108
+    it 'should return a date that is between 5 and 10 days greater than the current one' do
  109
+      date = Forgery::Date.date(:min_delta => 5, :max_delta => 10, :future => true)
  110
+      (0..5).map { |i| Date.today + i + 5 }.should include(date)
  111
+    end
  112
+  end
  113
+
  114
+  describe '.date(:past => true)' do
  115
+    it 'should return a date less than the current one' do
  116
+      date = Forgery::Date.date(:past => true)
  117
+      date.should <= Date.today
  118
+    end
  119
+  end
  120
+
  121
+  describe '.date(:min_delta => 5, :max_delta => 5, :past => true)' do
  122
+    it 'should return a date 5 days until the current one' do
  123
+      date = Forgery::Date.date(:min_delta => 5, :max_delta => 5, :past => true)
  124
+      date.should == Date.today - 5
  125
+    end
  126
+  end
  127
+
  128
+  describe '.date(:min_delta => 5, :max_delta => 10, :past => true)' do
  129
+    it 'should return a date that is between 5 and 10 days less than the current one' do
  130
+      date = Forgery::Date.date(:min_delta => 5, :max_delta => 10, :past => true)
  131
+      (0..5).map { |i| Date.today - i - 5 }.should include(date)
  132
+    end
  133
+  end
84 134
 end

0 notes on commit a56ddf8

Please sign in to comment.
Something went wrong with that request. Please try again.