sixarm_ruby_week 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dec5e39582357dfbf6d7472430a0eed49753fe5
4
- data.tar.gz: 56a4eb5324a009dd60e5d111738da350ccb4ebb0
3
+ metadata.gz: 43c2bf247a81648d563528f841600bfce4b615c0
4
+ data.tar.gz: b8c6242e092844a4ba41d2dbacece6b8a2e36954
5
5
  SHA512:
6
- metadata.gz: 4b24edfb3248bdb394b169f04393d6f80597363c2b3bb1152fd7d3705fc13eb6be7fe56c9c23e778fc13c807650c8490cbcfd83611c00ee260c7bdc0eedae8e2
7
- data.tar.gz: 09c857e3cde0c8bbc846b9fc6823f3547182dd5a0c31427a2d3ca7c269f00e4b84b3619ab57d0d0948a397c81eda617910b54a142c0f059c1ec9db4587d77571
6
+ metadata.gz: e9eced63ee4ac973570d7e4c44e460a57a1480cc845e6faf8753e3aa8091ff131c8e7bfaa1a522ab81564a4305e5d2a46183c0607fc0d728e8edfe440cbe6d39
7
+ data.tar.gz: c77d05a7d6edc1400ecf4ae1def478bb9c4759e8085c333909a72d0617bbf17a98621e5e0fc2a30067a357c48ba0f90aa57f43497f26c98e4d0d2ba4eaf34b88
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -3,13 +3,10 @@ require "rake"
3
3
  require "rake/testtask"
4
4
 
5
5
  Rake::TestTask.new(:test) do |t|
6
- t.libs << 'lib' << 'test'
7
- t.pattern = 'test/*.rb'
6
+ t.libs.push("lib", "test")
7
+ t.pattern = "test/**/*.rb"
8
8
  end
9
9
 
10
10
  task :default => [:test]
11
11
  task :default => [:test]
12
12
  task :default => [:test]
13
- task :default => [:test]
14
- task :default => [:test]
15
- task :default => [:test]
@@ -3,221 +3,4 @@
3
3
  Please see README
4
4
  =end
5
5
 
6
- require "date"
7
-
8
-
9
- class Week
10
-
11
- attr :date
12
-
13
- def initialize(date)
14
- @date = date
15
- end
16
-
17
-
18
- # Return date.to_s
19
-
20
- def to_s
21
- @date.to_s
22
- end
23
-
24
-
25
- ### Instantiations
26
-
27
-
28
- # Return the week that starts today
29
-
30
- def self.now
31
- Week.new(Date.today)
32
- end
33
-
34
-
35
- # Parse date text to a week.
36
- #
37
- # @example
38
- # week = Week.parse('2012-01-02')
39
-
40
- def self.parse(date_text)
41
- Week.new(Date.parse(date_text))
42
- end
43
-
44
-
45
- ### Comparable
46
-
47
-
48
- # Return the hash for object comparison.
49
- #
50
- # This is simply the has of the date, which means
51
- # that two week objects created with the same date
52
- # will compare equally.
53
-
54
- def hash
55
- date.hash
56
- end
57
-
58
-
59
- # Return week1.date == week2.date
60
-
61
- def ==(other)
62
- self.date == other.date
63
- end
64
-
65
-
66
- # Return week1.date.eql? week2.date
67
-
68
- def eql?(other)
69
- self.date == other.date
70
- end
71
-
72
-
73
- # Return week1.date <=> week2.date
74
-
75
- def <=>(other)
76
- return self.date <=> other.date
77
- end
78
-
79
-
80
- # Return week1.date < week2.date
81
-
82
- def <(other)
83
- self.date < other.date
84
- end
85
-
86
-
87
- # Return week1.date <= week2.date
88
-
89
- def <=(other)
90
- self.date <= other.date
91
- end
92
-
93
-
94
- # Return week1.date > week2.date
95
-
96
- def >(other)
97
- self.date > other.date
98
- end
99
-
100
-
101
- # Return week1.date >= week2.date
102
-
103
- def >=(other)
104
- self.date >= other.date
105
- end
106
-
107
-
108
- ### Math
109
-
110
-
111
- # Addition: week + other => week
112
- #
113
- # Return a date object pointing other weeks after self.
114
- # The other should be a numeric value.
115
- #
116
- # @example
117
- # week = Week.parse('2012-01-02')
118
- # week + 3 => three weeks later
119
-
120
- def +(other)
121
- if other.is_a? Numeric
122
- return Week.new(date + (other.to_i * 7))
123
- else
124
- raise TypeError
125
- end
126
- end
127
-
128
-
129
- # Subtraction: week - other => week or integer
130
- #
131
- # If the other is a numeric value, return a week object pointing other weeks before self.
132
- #
133
- # If the other is a week object, then return the difference between the two weeks.
134
- #
135
- # @example
136
- # date = date.parse('2012-01-02')
137
- # week = Week.new(date)
138
- # week - 3 => three weeks earlier
139
- #
140
- # @example
141
- # date = date.parse('2012-01-02')
142
- # start_week = Week.new(date)
143
- # end_week = Week.new(date + 21)
144
- # end_week - start_week => 3
145
-
146
- def -(other)
147
- if other.is_a? Numeric
148
- return Week.new(date - (other * 7))
149
- elsif other.is_a? Week
150
- return ((self.date - other.date) / 7).round
151
- else
152
- raise TypeError
153
- end
154
- end
155
-
156
-
157
- ### Enumerable
158
-
159
- # Return the previous week, i.e. seven day earlier.
160
-
161
- def previous
162
- return self - 1
163
- end
164
-
165
-
166
- # Return the next week, i.e. seven day later.
167
-
168
- def next
169
- return self + 1
170
- end
171
-
172
-
173
- ### Ranges
174
-
175
-
176
- # Return the start date of this week.
177
- # This is the same as week.date.
178
- #
179
- # @example
180
- # week = Week.parse('2012-01-02')
181
- # week.start_date.to_s => '2012-01-02'
182
-
183
- def start_date
184
- @date
185
- end
186
-
187
-
188
- # Return the end date of this week.
189
- # This is the same as week.date + 6 days
190
- #
191
- # @example
192
- # week = Week.parse('2012-01-02')
193
- # week.end_date.to_s => '2012-01-08'
194
-
195
- def end_date
196
- @date + 6
197
- end
198
-
199
-
200
- # Return the range start_date..end_date
201
- #
202
- # @example
203
- # week = Week.parse('2012-01-02')
204
- # week.date_range => Range(2012-01-02..2012-01-08)
205
-
206
- def date_range
207
- start_date..end_date
208
- end
209
-
210
-
211
- # Return true iif the week includes the date, i.e. if the date is in start_date..end_date
212
- #
213
- # @example
214
- # week = Week.parse('2012-01-02')
215
- # week.include?(Date.parse('2012-01-05')) => true
216
- # week.include?(Date.parse('2012-01-10')) => false
217
-
218
- def include?(date)
219
- (start_date..end_date).include?(date)
220
- end
221
-
222
-
223
- end
6
+ require "sixarm_ruby_week/week"
@@ -1,379 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require "minitest/autorun"
3
+ require "coveralls"
3
4
  require "simplecov"
5
+ Coveralls.wear!
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
4
10
  SimpleCov.start
5
-
6
- require "sixarm_ruby_week"
7
-
8
- describe Week do
9
-
10
- before do
11
- TEXT ||= '2012-01-02'
12
- DATE ||= Date.parse(TEXT)
13
- WEEK ||= Week.new(DATE)
14
- WEEK_PREV ||= Week.new(DATE-7)
15
- WEEK_NEXT ||= Week.new(DATE+7)
16
- end
17
-
18
- describe ".initialize" do
19
-
20
- it "must initialize the year, week, and day" do
21
- WEEK.date.cwyear.must_equal 2012
22
- WEEK.date.cweek.must_equal 1
23
- WEEK.date.cwday.must_equal 1
24
- end
25
-
26
- end
27
-
28
- describe "#date" do
29
-
30
- it "=> Date" do
31
- WEEK.date.must_be_kind_of Date
32
- end
33
-
34
- it "=> the date that initiazed the week" do
35
- WEEK.date.must_equal DATE
36
- end
37
-
38
- end
39
-
40
- describe "#to_s" do
41
-
42
- it "=> String" do
43
- WEEK.to_s.must_be_kind_of String
44
- end
45
-
46
- it "=> the week's date formatted as YYYY-MM-DD" do
47
- WEEK.to_s.must_equal TEXT
48
- end
49
-
50
- end
51
-
52
- describe ".now" do
53
-
54
- it "=> Week" do
55
- Week.now.must_be_kind_of Week
56
- end
57
-
58
- it "=> a week based on today's date" do
59
- Week.now.date.must_equal Date.today
60
- end
61
-
62
- end
63
-
64
- describe ".parse" do
65
-
66
- it "=> Week" do
67
- Week.parse(TEXT).must_be_kind_of Week
68
- end
69
-
70
- it "=> a week based on the date text" do
71
- s = '2012-01-02'
72
- Week.parse(s).date.must_equal Date.parse(s)
73
- end
74
-
75
- end
76
-
77
- describe "#hash" do
78
-
79
- it "=> Fixnum" do
80
- WEEK.hash.must_be_kind_of Fixnum
81
- end
82
-
83
- it "=> the week's date's hash" do
84
- WEEK.hash.must_equal WEEK.date.hash
85
- end
86
-
87
- end
88
-
89
- describe "#eql?" do
90
-
91
- it "weeks created from the same date => true" do
92
- assert(WEEK.eql? Week.new(DATE))
93
- end
94
-
95
- it "weeks created from different dates => false" do
96
- refute(WEEK.eql? Week.new(DATE+1))
97
- end
98
-
99
- end
100
-
101
- describe "==" do
102
-
103
- it "weeks created from the same date => true" do
104
- assert(WEEK == Week.new(DATE))
105
- end
106
-
107
- it "weeks created from different dates => false" do
108
- refute(WEEK == Week.new(DATE+1))
109
- end
110
-
111
- end
112
-
113
- describe "<=>" do
114
-
115
- it "x<y => -1" do
116
- (WEEK <=> WEEK_NEXT).must_equal -1
117
- end
118
-
119
- it "x=y => 0" do
120
- (WEEK <=> WEEK).must_equal 0
121
- end
122
-
123
- it "x>y => 1" do
124
- (WEEK <=> WEEK_PREV).must_equal 1
125
- end
126
-
127
- end
128
-
129
- describe "<" do
130
-
131
- it "x<y => true" do
132
- assert(WEEK < WEEK_NEXT)
133
- end
134
-
135
- it "x==y => false" do
136
- refute(WEEK < WEEK)
137
- end
138
-
139
- it "x>y => false" do
140
- refute(WEEK < WEEK_PREV)
141
- end
142
-
143
- end
144
-
145
- describe "<=" do
146
-
147
- it "x<y => false" do
148
- assert(WEEK < WEEK_NEXT)
149
- end
150
-
151
- it "x==y => true" do
152
- assert(WEEK <= WEEK)
153
- end
154
-
155
- it "x>y => false" do
156
- refute(WEEK <= WEEK_PREV)
157
- end
158
-
159
- end
160
-
161
- describe ">" do
162
-
163
- it "x<y => false" do
164
- refute(WEEK > WEEK_NEXT)
165
- end
166
-
167
- it "x==y => false" do
168
- refute(WEEK > WEEK)
169
- end
170
-
171
- it "x>y => true" do
172
- assert(WEEK > WEEK_PREV)
173
- end
174
-
175
- end
176
-
177
- describe ">=" do
178
-
179
- it "x<y => false" do
180
- refute(WEEK >= WEEK_NEXT)
181
- end
182
-
183
- it "x==y => true" do
184
- assert(WEEK >= WEEK)
185
- end
186
-
187
- it "x>y => true" do
188
- assert(WEEK >= WEEK_PREV)
189
- end
190
-
191
- end
192
-
193
- describe "+" do
194
-
195
- describe "with Numeric type" do
196
-
197
- it "=> Week" do
198
- (WEEK + 0).must_be_kind_of Week
199
- end
200
-
201
- it "+ 0 => this week" do
202
- (WEEK + 0).must_equal WEEK
203
- end
204
-
205
- it "+ 1 => next week" do
206
- (WEEK + 1).must_equal WEEK_NEXT
207
- end
208
-
209
- it "+ (-1) => previous week" do
210
- (WEEK + (-1)).must_equal WEEK_PREV
211
- end
212
-
213
- it "+ any other number => different week" do
214
- w = WEEK + 2
215
- w.wont_equal WEEK_PREV
216
- w.wont_equal WEEK
217
- w.wont_equal WEEK_NEXT
218
- end
219
-
220
- end
221
-
222
- describe "with bad type" do
223
-
224
- it "TypeError" do
225
- proc { WEEK + "foo" }.must_raise TypeError
226
- end
227
-
228
- end
229
-
230
- end
231
-
232
- describe "-" do
233
-
234
- describe "with Numeric type" do
235
-
236
- it "=> Week" do
237
- (WEEK - 0).must_be_kind_of Week
238
- end
239
-
240
- it "- 0 => this week" do
241
- (WEEK - 0).must_equal WEEK
242
- end
243
-
244
- it "- 1 => previous week" do
245
- (WEEK - 1).must_equal WEEK_PREV
246
- end
247
-
248
- it "- (-1) => next week" do
249
- (WEEK - (-1)).must_equal WEEK_NEXT
250
- end
251
-
252
- it "- any other number => different week" do
253
- w = WEEK - 2
254
- w.wont_equal WEEK_PREV
255
- w.wont_equal WEEK
256
- w.wont_equal WEEK_NEXT
257
- end
258
-
259
- end
260
-
261
- describe "with Week type" do
262
-
263
- it "=> Integer" do
264
- (WEEK - WEEK).must_be_kind_of Integer
265
- end
266
-
267
- it "this week - previous week => 1" do
268
- (WEEK - WEEK_PREV).must_equal 1
269
- end
270
-
271
- it "this week - this week => 0" do
272
- (WEEK - WEEK).must_equal 0
273
- end
274
-
275
- it "this week - next week => -1" do
276
- (WEEK - WEEK_NEXT).must_equal -1
277
- end
278
-
279
- end
280
-
281
- describe "with bad type" do
282
-
283
- it "TypeError" do
284
- proc { WEEK - "foo" }.must_raise TypeError
285
- end
286
-
287
- end
288
-
289
- end
290
-
291
- describe "#previous" do
292
-
293
- it "=> Week" do
294
- WEEK.previous.must_be_kind_of Week
295
- end
296
-
297
- it "=> a week seven days earlier" do
298
- Week.new(DATE).previous.must_equal Week.new(DATE-7)
299
- end
300
-
301
- end
302
-
303
- describe "#next" do
304
-
305
- it "=> Week" do
306
- (WEEK.next).must_be_kind_of Week
307
- end
308
-
309
- it "=> a week seven days later" do
310
- Week.new(DATE).next.must_equal Week.new(DATE+7)
311
- end
312
-
313
- end
314
-
315
- describe "#start_date" do
316
-
317
- it "=> Date" do
318
- WEEK.start_date.must_be_kind_of Date
319
- end
320
-
321
- it "=> the initialzation date" do
322
- WEEK.start_date.must_equal DATE
323
- end
324
-
325
- end
326
-
327
- describe "#end_date" do
328
-
329
- it "=> Date" do
330
- WEEK.end_date.must_be_kind_of Date
331
- end
332
-
333
- it "=> six days after the initialization date" do
334
- WEEK.end_date.must_equal DATE + 6
335
- end
336
-
337
- end
338
-
339
- describe "#date_range" do
340
-
341
- it "=> Range" do
342
- WEEK.date_range.must_be_kind_of Range
343
- end
344
-
345
- it "=> Range first is the start date" do
346
- WEEK.date_range.first.must_equal WEEK.start_date
347
- end
348
-
349
- it "=> Range last is the end date" do
350
- WEEK.date_range.last.must_equal WEEK.end_date
351
- end
352
-
353
- end
354
-
355
- describe "#include?" do
356
-
357
- it "all days in this week => true" do
358
- WEEK.must_include DATE+0
359
- WEEK.must_include DATE+1
360
- WEEK.must_include DATE+2
361
- WEEK.must_include DATE+3
362
- WEEK.must_include DATE+4
363
- WEEK.must_include DATE+5
364
- WEEK.must_include DATE+6
365
- end
366
-
367
- it "any day before this week => false" do
368
- WEEK.wont_include DATE-1
369
- WEEK.wont_include DATE-999
370
- end
371
-
372
- it "any day after this week => false" do
373
- WEEK.wont_include DATE+7
374
- WEEK.wont_include DATE+999
375
- end
376
-
377
- end
378
-
379
- end
@@ -0,0 +1,401 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "sixarm_ruby_week_test"
3
+ require "sixarm_ruby_week/week"
4
+
5
+ describe Week do
6
+
7
+ before do
8
+ TEXT ||= '2012-01-02'
9
+ DATE ||= Date.parse(TEXT)
10
+ WEEK ||= Week.new(DATE)
11
+ WEEK_PREV ||= Week.new(DATE-7)
12
+ WEEK_NEXT ||= Week.new(DATE+7)
13
+ end
14
+
15
+ describe ".initialize" do
16
+
17
+ it "must initialize the year, week, and day" do
18
+ WEEK.date.cwyear.must_equal 2012
19
+ WEEK.date.cweek.must_equal 1
20
+ WEEK.date.cwday.must_equal 1
21
+ end
22
+
23
+ end
24
+
25
+ describe "#date" do
26
+
27
+ it "=> Date" do
28
+ WEEK.date.must_be_kind_of Date
29
+ end
30
+
31
+ it "=> the date that initialized the week" do
32
+ WEEK.date.must_equal DATE
33
+ end
34
+
35
+ end
36
+
37
+ describe "#to_s" do
38
+
39
+ it "=> String" do
40
+ WEEK.to_s.must_be_kind_of String
41
+ end
42
+
43
+ it "=> the week's date formatted as YYYY-MM-DD" do
44
+ WEEK.to_s.must_equal TEXT
45
+ end
46
+
47
+ end
48
+
49
+ describe ".now" do
50
+
51
+ it "=> Week" do
52
+ Week.now.must_be_kind_of Week
53
+ end
54
+
55
+ it "=> a week based on today's date" do
56
+ Week.now.date.must_equal Date.today
57
+ end
58
+
59
+ end
60
+
61
+ describe ".parse" do
62
+
63
+ it "=> Week" do
64
+ Week.parse(TEXT).must_be_kind_of Week
65
+ end
66
+
67
+ it "=> a week based on the date text" do
68
+ s = '2012-01-02'
69
+ Week.parse(s).date.must_equal Date.parse(s)
70
+ end
71
+
72
+ end
73
+
74
+ describe "#hash" do
75
+
76
+ it "=> Fixnum" do
77
+ WEEK.hash.must_be_kind_of Fixnum
78
+ end
79
+
80
+ it "=> the week's date's hash" do
81
+ WEEK.hash.must_equal WEEK.date.hash
82
+ end
83
+
84
+ end
85
+
86
+ describe "#eql?" do
87
+
88
+ it "weeks created from the same date => true" do
89
+ assert(WEEK.eql? Week.new(DATE))
90
+ end
91
+
92
+ it "weeks created from different dates => false" do
93
+ refute(WEEK.eql? Week.new(DATE+1))
94
+ end
95
+
96
+ end
97
+
98
+ describe "==" do
99
+
100
+ it "weeks created from the same date => true" do
101
+ assert(WEEK == Week.new(DATE))
102
+ end
103
+
104
+ it "weeks created from different dates => false" do
105
+ refute(WEEK == Week.new(DATE+1))
106
+ end
107
+
108
+ end
109
+
110
+ describe "<=>" do
111
+
112
+ it "x<y => -1" do
113
+ (WEEK <=> WEEK_NEXT).must_equal -1
114
+ end
115
+
116
+ it "x=y => 0" do
117
+ (WEEK <=> WEEK).must_equal 0
118
+ end
119
+
120
+ it "x>y => 1" do
121
+ (WEEK <=> WEEK_PREV).must_equal 1
122
+ end
123
+
124
+ end
125
+
126
+ describe "<" do
127
+
128
+ it "x<y => true" do
129
+ assert(WEEK < WEEK_NEXT)
130
+ end
131
+
132
+ it "x==y => false" do
133
+ refute(WEEK < WEEK)
134
+ end
135
+
136
+ it "x>y => false" do
137
+ refute(WEEK < WEEK_PREV)
138
+ end
139
+
140
+ end
141
+
142
+ describe "<=" do
143
+
144
+ it "x<y => false" do
145
+ assert(WEEK < WEEK_NEXT)
146
+ end
147
+
148
+ it "x==y => true" do
149
+ assert(WEEK <= WEEK)
150
+ end
151
+
152
+ it "x>y => false" do
153
+ refute(WEEK <= WEEK_PREV)
154
+ end
155
+
156
+ end
157
+
158
+ describe ">" do
159
+
160
+ it "x<y => false" do
161
+ refute(WEEK > WEEK_NEXT)
162
+ end
163
+
164
+ it "x==y => false" do
165
+ refute(WEEK > WEEK)
166
+ end
167
+
168
+ it "x>y => true" do
169
+ assert(WEEK > WEEK_PREV)
170
+ end
171
+
172
+ end
173
+
174
+ describe ">=" do
175
+
176
+ it "x<y => false" do
177
+ refute(WEEK >= WEEK_NEXT)
178
+ end
179
+
180
+ it "x==y => true" do
181
+ assert(WEEK >= WEEK)
182
+ end
183
+
184
+ it "x>y => true" do
185
+ assert(WEEK >= WEEK_PREV)
186
+ end
187
+
188
+ end
189
+
190
+ describe "+" do
191
+
192
+ describe "with Numeric type" do
193
+
194
+ it "=> Week" do
195
+ (WEEK + 0).must_be_kind_of Week
196
+ end
197
+
198
+ it "+ 0 => this week" do
199
+ (WEEK + 0).must_equal WEEK
200
+ end
201
+
202
+ it "+ 1 => next week" do
203
+ (WEEK + 1).must_equal WEEK_NEXT
204
+ end
205
+
206
+ it "+ (-1) => previous week" do
207
+ (WEEK + (-1)).must_equal WEEK_PREV
208
+ end
209
+
210
+ it "+ any other number => different week" do
211
+ w = WEEK + 2
212
+ w.wont_equal WEEK_PREV
213
+ w.wont_equal WEEK
214
+ w.wont_equal WEEK_NEXT
215
+ end
216
+
217
+ end
218
+
219
+ describe "with bad type" do
220
+
221
+ it "TypeError" do
222
+ proc { WEEK + "foo" }.must_raise TypeError
223
+ end
224
+
225
+ end
226
+
227
+ end
228
+
229
+ describe "-" do
230
+
231
+ describe "with Numeric type" do
232
+
233
+ it "=> Week" do
234
+ (WEEK - 0).must_be_kind_of Week
235
+ end
236
+
237
+ it "- 0 => this week" do
238
+ (WEEK - 0).must_equal WEEK
239
+ end
240
+
241
+ it "- 1 => previous week" do
242
+ (WEEK - 1).must_equal WEEK_PREV
243
+ end
244
+
245
+ it "- (-1) => next week" do
246
+ (WEEK - (-1)).must_equal WEEK_NEXT
247
+ end
248
+
249
+ it "- any other number => different week" do
250
+ w = WEEK - 2
251
+ w.wont_equal WEEK_PREV
252
+ w.wont_equal WEEK
253
+ w.wont_equal WEEK_NEXT
254
+ end
255
+
256
+ end
257
+
258
+ describe "with Week type" do
259
+
260
+ it "=> Integer" do
261
+ (WEEK - WEEK).must_be_kind_of Integer
262
+ end
263
+
264
+ it "this week - previous week => 1" do
265
+ (WEEK - WEEK_PREV).must_equal 1
266
+ end
267
+
268
+ it "this week - this week => 0" do
269
+ (WEEK - WEEK).must_equal 0
270
+ end
271
+
272
+ it "this week - next week => -1" do
273
+ (WEEK - WEEK_NEXT).must_equal -1
274
+ end
275
+
276
+ end
277
+
278
+ describe "with bad type" do
279
+
280
+ it "TypeError" do
281
+ proc { WEEK - "foo" }.must_raise TypeError
282
+ end
283
+
284
+ end
285
+
286
+ end
287
+
288
+ describe "#previous" do
289
+
290
+ it "=> Week" do
291
+ WEEK.previous.must_be_kind_of Week
292
+ end
293
+
294
+ it "=> a week seven days earlier" do
295
+ Week.new(DATE).previous.must_equal Week.new(DATE-7)
296
+ end
297
+
298
+ end
299
+
300
+ describe "#next" do
301
+
302
+ it "=> Week" do
303
+ (WEEK.next).must_be_kind_of Week
304
+ end
305
+
306
+ it "=> a week seven days later" do
307
+ Week.new(DATE).next.must_equal Week.new(DATE+7)
308
+ end
309
+
310
+ end
311
+
312
+ describe "#start_date" do
313
+
314
+ it "=> Date" do
315
+ WEEK.start_date.must_be_kind_of Date
316
+ end
317
+
318
+ it "=> the initialzation date" do
319
+ WEEK.start_date.must_equal DATE
320
+ end
321
+
322
+ end
323
+
324
+ describe "#begin_date" do
325
+
326
+ it "=> Date" do
327
+ WEEK.begin_date.must_be_kind_of Date
328
+ end
329
+
330
+ it "=> the initialzation date" do
331
+ WEEK.begin_date.must_equal DATE
332
+ end
333
+
334
+ end
335
+
336
+ describe "#stop_date" do
337
+
338
+ it "=> Date" do
339
+ WEEK.stop_date.must_be_kind_of Date
340
+ end
341
+
342
+ it "=> six days after the initialization date" do
343
+ WEEK.stop_date.must_equal DATE + 6
344
+ end
345
+
346
+ end
347
+
348
+ describe "#end_date" do
349
+
350
+ it "=> Date" do
351
+ WEEK.end_date.must_be_kind_of Date
352
+ end
353
+
354
+ it "=> six days after the initialization date" do
355
+ WEEK.end_date.must_equal DATE + 6
356
+ end
357
+
358
+ end
359
+
360
+ describe "#date_range" do
361
+
362
+ it "=> Range" do
363
+ WEEK.date_range.must_be_kind_of Range
364
+ end
365
+
366
+ it "=> Range first is the start date" do
367
+ WEEK.date_range.first.must_equal WEEK.start_date
368
+ end
369
+
370
+ it "=> Range last is the end date" do
371
+ WEEK.date_range.last.must_equal WEEK.end_date
372
+ end
373
+
374
+ end
375
+
376
+
377
+ describe "#include?" do
378
+
379
+ it "all days in this week => true" do
380
+ WEEK.must_include DATE+0
381
+ WEEK.must_include DATE+1
382
+ WEEK.must_include DATE+2
383
+ WEEK.must_include DATE+3
384
+ WEEK.must_include DATE+4
385
+ WEEK.must_include DATE+5
386
+ WEEK.must_include DATE+6
387
+ end
388
+
389
+ it "any day before this week => false" do
390
+ WEEK.wont_include DATE-1
391
+ WEEK.wont_include DATE-999
392
+ end
393
+
394
+ it "any day after this week => false" do
395
+ WEEK.wont_include DATE+7
396
+ WEEK.wont_include DATE+999
397
+ end
398
+
399
+ end
400
+
401
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixarm_ruby_week
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - SixArm
@@ -44,7 +44,7 @@ cert_chain:
44
44
  2AC9FOGkybW6DJEFSFFMlNk0IILsa/gNp8ufGuTVLWF9FUUdMNK+TMbghnifT8/1
45
45
  n+ES/gQPOnvmVkLDGw==
46
46
  -----END CERTIFICATE-----
47
- date: 2015-07-10 00:00:00.000000000 Z
47
+ date: 2015-07-18 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: minitest
@@ -126,7 +126,7 @@ dependencies:
126
126
  - - "<"
127
127
  - !ruby/object:Gem::Version
128
128
  version: '2'
129
- description: Week model, based on Ruby Date
129
+ description: Week model based on Ruby Date
130
130
  email: sixarm@sixarm.com
131
131
  executables: []
132
132
  extensions: []
@@ -135,6 +135,7 @@ files:
135
135
  - Rakefile
136
136
  - lib/sixarm_ruby_week.rb
137
137
  - test/sixarm_ruby_week_test.rb
138
+ - test/sixarm_ruby_week_test/week_test.rb
138
139
  homepage: http://sixarm.com/
139
140
  licenses:
140
141
  - BSD
@@ -165,4 +166,5 @@ specification_version: 4
165
166
  summary: SixArm.com » Ruby » Week
166
167
  test_files:
167
168
  - test/sixarm_ruby_week_test.rb
169
+ - test/sixarm_ruby_week_test/week_test.rb
168
170
  has_rdoc: true
metadata.gz.sig CHANGED
Binary file