nickel 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Rakefile +5 -1
- data/lib/nickel/construct.rb +31 -36
- data/lib/nickel/construct_finder.rb +442 -360
- data/lib/nickel/construct_interpreter.rb +50 -52
- data/lib/nickel/nlp.rb +18 -21
- data/lib/nickel/nlp_query.rb +471 -471
- data/lib/nickel/nlp_query_constants.rb +1 -1
- data/lib/nickel/occurrence.rb +7 -8
- data/lib/nickel/version.rb +1 -1
- data/lib/nickel/zdate.rb +86 -77
- data/lib/nickel/ztime.rb +58 -54
- data/spec/lib/nickel/construct_spec.rb +66 -0
- data/spec/lib/nickel/nlp_spec.rb +7 -7
- data/spec/lib/nickel/occurrence_spec.rb +20 -21
- data/spec/lib/nickel/zdate_spec.rb +49 -29
- data/spec/lib/nickel/ztime_spec.rb +174 -158
- data/spec/lib/nickel_spec.rb +687 -609
- data/spec/spec_helper.rb +2 -2
- metadata +4 -2
data/spec/lib/nickel_spec.rb
CHANGED
@@ -1,561 +1,561 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'time'
|
3
|
+
require_relative '../../lib/nickel'
|
4
|
+
require_relative '../../lib/nickel/occurrence'
|
5
|
+
require_relative '../../lib/nickel/zdate'
|
6
|
+
require_relative '../../lib/nickel/ztime'
|
7
7
|
|
8
8
|
describe Nickel do
|
9
|
-
describe
|
9
|
+
describe '#parse' do
|
10
10
|
let(:n) { Nickel.parse(query, run_date) }
|
11
11
|
let(:run_date) { Time.now }
|
12
12
|
|
13
13
|
context "when the query is 'oct 15 09'" do
|
14
|
-
let(:query) {
|
14
|
+
let(:query) { 'oct 15 09' }
|
15
15
|
|
16
|
-
describe
|
17
|
-
it
|
16
|
+
describe '#message' do
|
17
|
+
it 'is empty' do
|
18
18
|
expect(n.message).to be_empty
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe
|
23
|
-
it
|
22
|
+
describe '#occurrences' do
|
23
|
+
it 'is October 15 2009' do
|
24
24
|
expect(n.occurrences).to match_array [
|
25
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
25
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20091015'))
|
26
26
|
]
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
context "when the query is 'wake up everyday at 11am'" do
|
32
|
-
let(:query) {
|
32
|
+
let(:query) { 'wake up everyday at 11am' }
|
33
33
|
let(:run_date) { Time.local(2014, 2, 26) }
|
34
34
|
|
35
|
-
describe
|
35
|
+
describe '#message' do
|
36
36
|
it "is 'wake up'" do
|
37
|
-
expect(n.message).to eq
|
37
|
+
expect(n.message).to eq 'wake up'
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
42
|
-
it
|
41
|
+
describe '#occurrences' do
|
42
|
+
it 'is daily at 11:00am' do
|
43
43
|
expect(n.occurrences).to match_array [
|
44
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
44
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20140226'), start_time: Nickel::ZTime.new('11'))
|
45
45
|
]
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
context "when the query is 'guitar lessons every tuesday at 5pm'" do
|
51
|
-
let(:query) {
|
51
|
+
let(:query) { 'guitar lessons every tuesday at 5pm' }
|
52
52
|
let(:run_date) { Time.local(2014, 2, 26) }
|
53
53
|
|
54
|
-
describe
|
54
|
+
describe '#message' do
|
55
55
|
it "is 'guitar lessons'" do
|
56
|
-
expect(n.message).to eq
|
56
|
+
expect(n.message).to eq 'guitar lessons'
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe
|
61
|
-
it
|
60
|
+
describe '#occurrences' do
|
61
|
+
it 'is weekly at 5:00pm on Tuesday' do
|
62
62
|
expect(n.occurrences).to match_array [
|
63
|
-
Nickel::Occurrence.new(type: :weekly, interval: 1, day_of_week: 1, start_time: Nickel::ZTime.new(
|
63
|
+
Nickel::Occurrence.new(type: :weekly, interval: 1, day_of_week: 1, start_time: Nickel::ZTime.new('17'), start_date: Nickel::ZDate.new('20140304'))
|
64
64
|
]
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
context "when the query is 'drink specials on the second thursday of every month'" do
|
70
|
-
let(:query) {
|
70
|
+
let(:query) { 'drink specials on the second thursday of every month' }
|
71
71
|
let(:run_date) { Time.local(2014, 2, 26) }
|
72
72
|
|
73
|
-
describe
|
73
|
+
describe '#message' do
|
74
74
|
it "is 'drink specials'" do
|
75
|
-
expect(n.message).to eq
|
75
|
+
expect(n.message).to eq 'drink specials'
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
80
|
-
it
|
79
|
+
describe '#occurrences' do
|
80
|
+
it 'is monthly on the second Thursday of the month' do
|
81
81
|
expect(n.occurrences).to match_array [
|
82
|
-
Nickel::Occurrence.new(type: :daymonthly, interval: 1, week_of_month: 2, day_of_week: 3, start_date: Nickel::ZDate.new(
|
82
|
+
Nickel::Occurrence.new(type: :daymonthly, interval: 1, week_of_month: 2, day_of_week: 3, start_date: Nickel::ZDate.new('20140313'))
|
83
83
|
]
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
context "when the query is 'pay credit card every month on the 22nd'" do
|
89
|
-
let(:query) {
|
89
|
+
let(:query) { 'pay credit card every month on the 22nd' }
|
90
90
|
let(:run_date) { Time.local(2014, 2, 26) }
|
91
91
|
|
92
|
-
describe
|
93
|
-
it
|
94
|
-
expect(n.message).to eq
|
92
|
+
describe '#message' do
|
93
|
+
it 'is pay credit card' do
|
94
|
+
expect(n.message).to eq 'pay credit card'
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
describe
|
99
|
-
it
|
98
|
+
describe '#occurrences' do
|
99
|
+
it 'is monthly on the 22nd' do
|
100
100
|
expect(n.occurrences).to match_array [
|
101
|
-
Nickel::Occurrence.new(type: :datemonthly, interval: 1, date_of_month: 22, start_date: Nickel::ZDate.new(
|
101
|
+
Nickel::Occurrence.new(type: :datemonthly, interval: 1, date_of_month: 22, start_date: Nickel::ZDate.new('20140322'))
|
102
102
|
]
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
context "when the query is 'band meeting every monday and wednesday at 2pm'" do
|
108
|
-
let(:query) {
|
108
|
+
let(:query) { 'band meeting every monday and wednesday at 2pm' }
|
109
109
|
let(:run_date) { Time.local(2014, 2, 26) }
|
110
110
|
|
111
|
-
describe
|
111
|
+
describe '#message' do
|
112
112
|
it "is 'band meeting'" do
|
113
|
-
expect(n.message).to eq
|
113
|
+
expect(n.message).to eq 'band meeting'
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
describe
|
118
|
-
it
|
117
|
+
describe '#occurrences' do
|
118
|
+
it 'is Mondays at 2:00pm and Wednesdays at 2:00pm' do
|
119
119
|
expect(n.occurrences).to match_array [
|
120
|
-
Nickel::Occurrence.new(type: :weekly, interval: 1, day_of_week: 0, start_time: Nickel::ZTime.new(
|
121
|
-
Nickel::Occurrence.new(type: :weekly, interval: 1, day_of_week: 2, start_time: Nickel::ZTime.new(
|
120
|
+
Nickel::Occurrence.new(type: :weekly, interval: 1, day_of_week: 0, start_time: Nickel::ZTime.new('14'), start_date: Nickel::ZDate.new('20140303')),
|
121
|
+
Nickel::Occurrence.new(type: :weekly, interval: 1, day_of_week: 2, start_time: Nickel::ZTime.new('14'), start_date: Nickel::ZDate.new('20140226'))
|
122
122
|
]
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
context "when the query is 'lunch 3 days from now'" do
|
128
|
-
let(:query) {
|
129
|
-
let(:run_date) { Time.local(2009,05,28) }
|
128
|
+
let(:query) { 'lunch 3 days from now' }
|
129
|
+
let(:run_date) { Time.local(2009, 05, 28) }
|
130
130
|
|
131
|
-
describe
|
131
|
+
describe '#message' do
|
132
132
|
it "is 'lunch'" do
|
133
|
-
expect(n.message).to eq
|
133
|
+
expect(n.message).to eq 'lunch'
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
describe
|
138
|
-
it
|
137
|
+
describe '#occurrences' do
|
138
|
+
it 'is 3 days from now' do
|
139
139
|
expect(n.occurrences).to match_array [
|
140
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
140
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090531'))
|
141
141
|
]
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
context "when the query is 'do something today'" do
|
147
|
-
let(:query) {
|
147
|
+
let(:query) { 'do something today' }
|
148
148
|
let(:run_date) { Time.local(2008, 8, 25) }
|
149
149
|
|
150
|
-
describe
|
150
|
+
describe '#message' do
|
151
151
|
it "is 'do something'" do
|
152
|
-
expect(n.message).to eq
|
152
|
+
expect(n.message).to eq 'do something'
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
describe
|
157
|
-
it
|
156
|
+
describe '#occurrences' do
|
157
|
+
it 'is today' do
|
158
158
|
expect(n.occurrences).to match_array [
|
159
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
159
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080825'))
|
160
160
|
]
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
165
|
context "when the query is 'there is a movie today at noon'" do
|
166
|
-
let(:query) {
|
166
|
+
let(:query) { 'there is a movie today at noon' }
|
167
167
|
let(:run_date) { Time.local(2008, 8, 25) }
|
168
168
|
|
169
|
-
describe
|
169
|
+
describe '#message' do
|
170
170
|
it "is 'there is a movie'" do
|
171
|
-
expect(n.message).to eq
|
171
|
+
expect(n.message).to eq 'there is a movie'
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
describe
|
176
|
-
it
|
175
|
+
describe '#occurrences' do
|
176
|
+
it 'is today at noon' do
|
177
177
|
expect(n.occurrences).to match_array [
|
178
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
178
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080825'), start_time: Nickel::ZTime.new('12'))
|
179
179
|
]
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
184
184
|
context "when the query is 'go to work today and tomorrow'" do
|
185
|
-
let(:query) {
|
185
|
+
let(:query) { 'go to work today and tomorrow' }
|
186
186
|
let(:run_date) { Time.local(2008, 8, 25) }
|
187
187
|
|
188
|
-
describe
|
188
|
+
describe '#message' do
|
189
189
|
it "is 'go to work'" do
|
190
|
-
expect(n.message).to eq
|
190
|
+
expect(n.message).to eq 'go to work'
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
-
describe
|
195
|
-
it
|
194
|
+
describe '#occurrences' do
|
195
|
+
it 'is today and tomorrow' do
|
196
196
|
expect(n.occurrences).to match_array [
|
197
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
198
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
197
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080825')),
|
198
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080826'))
|
199
199
|
]
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
204
|
context "when the query is 'appointments with the dentist are on oct 5 and oct 23rd'" do
|
205
|
-
let(:query) {
|
205
|
+
let(:query) { 'appointments with the dentist are on oct 5 and oct 23rd' }
|
206
206
|
let(:run_date) { Time.local(2008, 8, 25) }
|
207
207
|
|
208
|
-
describe
|
208
|
+
describe '#message' do
|
209
209
|
it "is 'appointments with the dentist'" do
|
210
|
-
expect(n.message).to eq
|
210
|
+
expect(n.message).to eq 'appointments with the dentist'
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
-
describe
|
215
|
-
it
|
214
|
+
describe '#occurrences' do
|
215
|
+
it 'is October 5 and October 23' do
|
216
216
|
expect(n.occurrences).to match_array [
|
217
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
218
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
217
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081005')),
|
218
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081023'))
|
219
219
|
]
|
220
220
|
end
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
224
|
context "when the query is 'today at noon and tomorrow at 5:45 am there will be an office meeting'" do
|
225
|
-
let(:query) {
|
225
|
+
let(:query) { 'today at noon and tomorrow at 5:45 am there will be an office meeting' }
|
226
226
|
let(:run_date) { Time.local(2008, 8, 25) }
|
227
227
|
|
228
|
-
describe
|
228
|
+
describe '#message' do
|
229
229
|
it "is 'there will be an office meeting'" do
|
230
|
-
expect(n.message).to eq
|
230
|
+
expect(n.message).to eq 'there will be an office meeting'
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
|
-
describe
|
235
|
-
it
|
234
|
+
describe '#occurrences' do
|
235
|
+
it 'is noon today and 5:45am tomorrow' do
|
236
236
|
expect(n.occurrences).to match_array [
|
237
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
238
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
237
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080825'), start_time: Nickel::ZTime.new('12')),
|
238
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080826'), start_time: Nickel::ZTime.new('0545'))
|
239
239
|
]
|
240
240
|
end
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
244
|
context "when the query is 'some stuff to do at noon today and 545am tomorrow'" do
|
245
|
-
let(:query) {
|
245
|
+
let(:query) { 'some stuff to do at noon today and 545am tomorrow' }
|
246
246
|
let(:run_date) { Time.local(2008, 8, 25) }
|
247
247
|
|
248
|
-
describe
|
248
|
+
describe '#message' do
|
249
249
|
it "is 'some stuff to do'" do
|
250
|
-
expect(n.message).to eq
|
250
|
+
expect(n.message).to eq 'some stuff to do'
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
254
|
-
describe
|
255
|
-
it
|
254
|
+
describe '#occurrences' do
|
255
|
+
it 'is noon today and 5:45am tomorrow' do
|
256
256
|
expect(n.occurrences).to match_array [
|
257
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
258
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
257
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080825'), start_time: Nickel::ZTime.new('12')),
|
258
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080826'), start_time: Nickel::ZTime.new('0545'))
|
259
259
|
]
|
260
260
|
end
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
264
264
|
context "when the query is 'go to the park tomorrow and thursday with the dog'" do
|
265
|
-
let(:query) {
|
265
|
+
let(:query) { 'go to the park tomorrow and thursday with the dog' }
|
266
266
|
let(:run_date) { Time.local(2008, 2, 29) }
|
267
267
|
|
268
|
-
describe
|
268
|
+
describe '#message' do
|
269
269
|
it "is 'go to the park with the dog'" do
|
270
|
-
expect(n.message).to eq
|
270
|
+
expect(n.message).to eq 'go to the park with the dog'
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
describe
|
275
|
-
it
|
274
|
+
describe '#occurrences' do
|
275
|
+
it 'is tomorrow and thursday' do
|
276
276
|
expect(n.occurrences).to match_array [
|
277
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
278
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
277
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080301')),
|
278
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080306'))
|
279
279
|
]
|
280
280
|
end
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
284
284
|
context "when the query is 'go to the park tomorrow and also on thursday with the dog'" do
|
285
|
-
let(:query) {
|
285
|
+
let(:query) { 'go to the park tomorrow and also on thursday with the dog' }
|
286
286
|
let(:run_date) { Time.local(2008, 2, 29) }
|
287
287
|
|
288
|
-
describe
|
288
|
+
describe '#message' do
|
289
289
|
it "is 'go to the park with the dog'" do
|
290
|
-
expect(n.message).to eq
|
290
|
+
expect(n.message).to eq 'go to the park with the dog'
|
291
291
|
end
|
292
292
|
end
|
293
293
|
|
294
|
-
describe
|
295
|
-
it
|
294
|
+
describe '#occurrences' do
|
295
|
+
it 'is tomorrow and thursday' do
|
296
296
|
expect(n.occurrences).to match_array [
|
297
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
298
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
297
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080301')),
|
298
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080306'))
|
299
299
|
]
|
300
300
|
end
|
301
301
|
end
|
302
302
|
end
|
303
303
|
|
304
304
|
context "when the query is 'how awesome tomorrow at 1am and from 2am to 5pm and thursday at 1pm is this?'" do
|
305
|
-
let(:query) {
|
305
|
+
let(:query) { 'how awesome tomorrow at 1am and from 2am to 5pm and thursday at 1pm is this?' }
|
306
306
|
let(:run_date) { Time.local(2008, 2, 29) }
|
307
307
|
|
308
|
-
describe
|
308
|
+
describe '#message' do
|
309
309
|
it "is 'how awesome is this?'" do
|
310
|
-
expect(n.message).to eq
|
310
|
+
expect(n.message).to eq 'how awesome is this?'
|
311
311
|
end
|
312
312
|
end
|
313
313
|
|
314
|
-
describe
|
315
|
-
it
|
314
|
+
describe '#occurrences' do
|
315
|
+
it 'is 1:00am and 2:00am-5:00pm tomorrow and 1:00pm Thursday' do
|
316
316
|
expect(n.occurrences).to match_array [
|
317
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
318
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
319
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
317
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080301'), start_time: Nickel::ZTime.new('01')),
|
318
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080301'), start_time: Nickel::ZTime.new('02'), end_time: Nickel::ZTime.new('17')),
|
319
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080306'), start_time: Nickel::ZTime.new('13'))
|
320
320
|
]
|
321
321
|
end
|
322
322
|
end
|
323
323
|
end
|
324
324
|
|
325
325
|
context "when the query is 'soccer practice monday tuesday and wednesday with susan'" do
|
326
|
-
let(:query) {
|
326
|
+
let(:query) { 'soccer practice monday tuesday and wednesday with susan' }
|
327
327
|
let(:run_date) { Time.local(2008, 9, 10) }
|
328
328
|
|
329
|
-
describe
|
329
|
+
describe '#message' do
|
330
330
|
it "is 'soccer practice with susan'" do
|
331
|
-
expect(n.message).to eq
|
331
|
+
expect(n.message).to eq 'soccer practice with susan'
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
335
|
-
describe
|
336
|
-
it
|
335
|
+
describe '#occurrences' do
|
336
|
+
it 'is Monday, Tuesday and Wednesday' do
|
337
337
|
expect(n.occurrences).to match_array [
|
338
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
339
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
340
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
338
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080915')),
|
339
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080916')),
|
340
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080917'))
|
341
341
|
]
|
342
342
|
end
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
346
346
|
context "when the query is 'monday and wednesday at 4pm I have guitar lessons'" do
|
347
|
-
let(:query) {
|
347
|
+
let(:query) { 'monday and wednesday at 4pm I have guitar lessons' }
|
348
348
|
let(:run_date) { Time.local(2008, 9, 10) }
|
349
349
|
|
350
|
-
describe
|
350
|
+
describe '#message' do
|
351
351
|
it "is 'I have guitar lessons'" do
|
352
|
-
expect(n.message).to eq
|
352
|
+
expect(n.message).to eq 'I have guitar lessons'
|
353
353
|
end
|
354
354
|
end
|
355
355
|
|
356
|
-
describe
|
357
|
-
it
|
356
|
+
describe '#occurrences' do
|
357
|
+
it 'is 4:00pm Monday and 4:00pm Wednesday' do
|
358
358
|
expect(n.occurrences).to match_array [
|
359
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
360
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
359
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080915'), start_time: Nickel::ZTime.new('16')),
|
360
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080917'), start_time: Nickel::ZTime.new('16'))
|
361
361
|
]
|
362
362
|
end
|
363
363
|
end
|
364
364
|
end
|
365
365
|
|
366
366
|
context "when the query is 'meet with so and so 4pm on monday and wednesday'" do
|
367
|
-
let(:query) {
|
367
|
+
let(:query) { 'meet with so and so 4pm on monday and wednesday' }
|
368
368
|
let(:run_date) { Time.local(2008, 9, 10) }
|
369
369
|
|
370
|
-
describe
|
370
|
+
describe '#message' do
|
371
371
|
it "is 'meet with so and so'" do
|
372
|
-
expect(n.message).to eq
|
372
|
+
expect(n.message).to eq 'meet with so and so'
|
373
373
|
end
|
374
374
|
end
|
375
375
|
|
376
|
-
describe
|
377
|
-
it
|
376
|
+
describe '#occurrences' do
|
377
|
+
it 'is 4:00pm Monday and 4:00pm Wednesday' do
|
378
378
|
expect(n.occurrences).to match_array [
|
379
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
380
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
379
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080915'), start_time: Nickel::ZTime.new('16')),
|
380
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080917'), start_time: Nickel::ZTime.new('16'))
|
381
381
|
]
|
382
382
|
end
|
383
383
|
end
|
384
384
|
end
|
385
385
|
|
386
386
|
context "when the query is 'flight this sunday on American'" do
|
387
|
-
let(:query) {
|
387
|
+
let(:query) { 'flight this sunday on American' }
|
388
388
|
let(:run_date) { Time.local(2008, 8, 25) }
|
389
389
|
|
390
|
-
describe
|
390
|
+
describe '#message' do
|
391
391
|
it "is 'flight on American'" do
|
392
|
-
expect(n.message).to eq
|
392
|
+
expect(n.message).to eq 'flight on American'
|
393
393
|
end
|
394
394
|
end
|
395
395
|
|
396
|
-
describe
|
397
|
-
it
|
396
|
+
describe '#occurrences' do
|
397
|
+
it 'is this Sunday' do
|
398
398
|
expect(n.occurrences).to match_array [
|
399
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
399
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080831'))
|
400
400
|
]
|
401
401
|
end
|
402
402
|
end
|
403
403
|
end
|
404
404
|
|
405
405
|
context "when the query is 'Flight to Miami this sunday 9-5am on Jet Blue'" do
|
406
|
-
let(:query) {
|
406
|
+
let(:query) { 'Flight to Miami this sunday 9-5am on Jet Blue' }
|
407
407
|
let(:run_date) { Time.local(2007, 11, 25) }
|
408
408
|
|
409
|
-
describe
|
409
|
+
describe '#message' do
|
410
410
|
it "is 'Flight to Miami on Jet Blue'" do
|
411
|
-
expect(n.message).to eq
|
411
|
+
expect(n.message).to eq 'Flight to Miami on Jet Blue'
|
412
412
|
end
|
413
413
|
end
|
414
414
|
|
415
|
-
describe
|
416
|
-
it
|
415
|
+
describe '#occurrences' do
|
416
|
+
it 'is 9:00pm to 5:00am this Sunday' do
|
417
417
|
# FIXME: this occurrence should have an end date
|
418
418
|
expect(n.occurrences).to match_array [
|
419
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
419
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20071125'), start_time: Nickel::ZTime.new('21'), end_time: Nickel::ZTime.new('05'))
|
420
420
|
]
|
421
421
|
end
|
422
422
|
end
|
423
423
|
end
|
424
424
|
|
425
425
|
context "when the query is 'Go to the park this sunday 9-5'" do
|
426
|
-
let(:query) {
|
426
|
+
let(:query) { 'Go to the park this sunday 9-5' }
|
427
427
|
let(:run_date) { Time.local(2007, 11, 25) }
|
428
428
|
|
429
|
-
describe
|
429
|
+
describe '#message' do
|
430
430
|
it "is 'Go to the park'" do
|
431
|
-
expect(n.message).to eq
|
431
|
+
expect(n.message).to eq 'Go to the park'
|
432
432
|
end
|
433
433
|
end
|
434
434
|
|
435
|
-
describe
|
436
|
-
it
|
435
|
+
describe '#occurrences' do
|
436
|
+
it 'is 9:00am to 5:00pm this Sunday' do
|
437
437
|
expect(n.occurrences).to match_array [
|
438
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
438
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20071125'), start_time: Nickel::ZTime.new('09'), end_time: Nickel::ZTime.new('17'))
|
439
439
|
]
|
440
440
|
end
|
441
441
|
end
|
442
442
|
end
|
443
443
|
|
444
444
|
context "when the query is 'movie showings are today at 10, 11, 12, and 1 to 5'" do
|
445
|
-
let(:query) {
|
445
|
+
let(:query) { 'movie showings are today at 10, 11, 12, and 1 to 5' }
|
446
446
|
let(:run_date) { Time.local(2008, 9, 10) }
|
447
447
|
|
448
|
-
describe
|
448
|
+
describe '#message' do
|
449
449
|
it "is 'movie showings'" do
|
450
|
-
expect(n.message).to eq
|
450
|
+
expect(n.message).to eq 'movie showings'
|
451
451
|
end
|
452
452
|
end
|
453
453
|
|
454
|
-
describe
|
455
|
-
it
|
454
|
+
describe '#occurrences' do
|
455
|
+
it 'is 10:00am, 11:00am, 12:00pm and 1:00pm to 5:00pm' do
|
456
456
|
expect(n.occurrences).to match_array [
|
457
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
458
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
459
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
460
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
457
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('10')),
|
458
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('11')),
|
459
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('12')),
|
460
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('13'), end_time: Nickel::ZTime.new('17'))
|
461
461
|
]
|
462
462
|
end
|
463
463
|
end
|
464
464
|
end
|
465
465
|
|
466
466
|
context "when the query is 'Games today at 10, 11, 12, 1'" do
|
467
|
-
let(:query) {
|
467
|
+
let(:query) { 'Games today at 10, 11, 12, 1' }
|
468
468
|
let(:run_date) { Time.local(2008, 9, 10) }
|
469
469
|
|
470
|
-
describe
|
470
|
+
describe '#message' do
|
471
471
|
it "is 'Games'" do
|
472
|
-
expect(n.message).to eq
|
472
|
+
expect(n.message).to eq 'Games'
|
473
473
|
end
|
474
474
|
end
|
475
475
|
|
476
|
-
describe
|
477
|
-
it
|
476
|
+
describe '#occurrences' do
|
477
|
+
it 'is 10:00am, 11:00am, 12:00pm and 1:00pm' do
|
478
478
|
expect(n.occurrences).to match_array [
|
479
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
480
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
481
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
482
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
479
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('10')),
|
480
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('11')),
|
481
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('12')),
|
482
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('13'))
|
483
483
|
]
|
484
484
|
end
|
485
485
|
end
|
486
486
|
end
|
487
487
|
|
488
488
|
context "when the query is 'Flight is a week from today'" do
|
489
|
-
let(:query) {
|
489
|
+
let(:query) { 'Flight is a week from today' }
|
490
490
|
let(:run_date) { Time.local(2009, 1, 1) }
|
491
491
|
|
492
|
-
describe
|
492
|
+
describe '#message' do
|
493
493
|
it "is 'Flight'" do
|
494
|
-
expect(n.message).to eq
|
494
|
+
expect(n.message).to eq 'Flight'
|
495
495
|
end
|
496
496
|
end
|
497
497
|
|
498
|
-
describe
|
499
|
-
it
|
498
|
+
describe '#occurrences' do
|
499
|
+
it 'is a week from today' do
|
500
500
|
expect(n.occurrences).to match_array [
|
501
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
501
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090108'))
|
502
502
|
]
|
503
503
|
end
|
504
504
|
end
|
505
505
|
end
|
506
506
|
|
507
507
|
context "when the query is 'Bill is due two weeks from tomorrow'" do
|
508
|
-
let(:query) {
|
508
|
+
let(:query) { 'Bill is due two weeks from tomorrow' }
|
509
509
|
let(:run_date) { Time.local(2008, 12, 24) }
|
510
510
|
|
511
|
-
describe
|
511
|
+
describe '#message' do
|
512
512
|
it "is 'Bill is due'" do
|
513
|
-
expect(n.message).to eq
|
513
|
+
expect(n.message).to eq 'Bill is due'
|
514
514
|
end
|
515
515
|
end
|
516
516
|
|
517
|
-
describe
|
518
|
-
it
|
517
|
+
describe '#occurrences' do
|
518
|
+
it 'is two weeks from tomorrow' do
|
519
519
|
expect(n.occurrences).to match_array [
|
520
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
520
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090108'))
|
521
521
|
]
|
522
522
|
end
|
523
523
|
end
|
524
524
|
end
|
525
525
|
|
526
526
|
context "when the query is 'Tryouts are two months from now'" do
|
527
|
-
let(:query) {
|
527
|
+
let(:query) { 'Tryouts are two months from now' }
|
528
528
|
let(:run_date) { Time.local(2008, 12, 24) }
|
529
529
|
|
530
|
-
describe
|
530
|
+
describe '#message' do
|
531
531
|
it "is 'Tryouts'" do
|
532
|
-
expect(n.message).to eq
|
532
|
+
expect(n.message).to eq 'Tryouts'
|
533
533
|
end
|
534
534
|
end
|
535
535
|
|
536
|
-
describe
|
537
|
-
it
|
536
|
+
describe '#occurrences' do
|
537
|
+
it 'is two months from now' do
|
538
538
|
expect(n.occurrences).to match_array [
|
539
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
539
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090224'))
|
540
540
|
]
|
541
541
|
end
|
542
542
|
end
|
543
543
|
end
|
544
544
|
|
545
545
|
context "when the query is 'baseball game is on october second'" do
|
546
|
-
let(:query) {
|
546
|
+
let(:query) { 'baseball game is on october second' }
|
547
547
|
let(:run_date) { Time.local(2008, 1, 30) }
|
548
548
|
|
549
|
-
describe
|
549
|
+
describe '#message' do
|
550
550
|
it "is 'baseball game'" do
|
551
|
-
expect(n.message).to eq
|
551
|
+
expect(n.message).to eq 'baseball game'
|
552
552
|
end
|
553
553
|
end
|
554
554
|
|
555
|
-
describe
|
556
|
-
it
|
555
|
+
describe '#occurrences' do
|
556
|
+
it 'is October 2nd' do
|
557
557
|
expect(n.occurrences).to match_array [
|
558
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
558
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081002'))
|
559
559
|
]
|
560
560
|
end
|
561
561
|
end
|
@@ -563,785 +563,798 @@ describe Nickel do
|
|
563
563
|
|
564
564
|
context "when the query is 'baseball game is on 10/2'" do
|
565
565
|
# FIXME: n should support US and international date formats
|
566
|
-
let(:query) {
|
566
|
+
let(:query) { 'baseball game is on 10/2' }
|
567
567
|
let(:run_date) { Time.local(2008, 1, 30) }
|
568
568
|
|
569
|
-
describe
|
570
|
-
it
|
569
|
+
describe '#occurrences' do
|
570
|
+
it 'is October 2nd' do
|
571
571
|
expect(n.occurrences).to match_array [
|
572
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
572
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081002'))
|
573
573
|
]
|
574
574
|
end
|
575
575
|
end
|
576
576
|
end
|
577
577
|
|
578
578
|
context "when the query is 'baseball game is on 10/2/08'" do
|
579
|
-
let(:query) {
|
579
|
+
let(:query) { 'baseball game is on 10/2/08' }
|
580
580
|
let(:run_date) { Time.local(2008, 1, 30) }
|
581
581
|
|
582
|
-
describe
|
583
|
-
it
|
582
|
+
describe '#occurrences' do
|
583
|
+
it 'is October 2nd' do
|
584
584
|
expect(n.occurrences).to match_array [
|
585
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
585
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081002'))
|
586
586
|
]
|
587
587
|
end
|
588
588
|
end
|
589
589
|
end
|
590
590
|
|
591
591
|
context "when the query is 'baseball game is on 10/2/2008'" do
|
592
|
-
let(:query) {
|
592
|
+
let(:query) { 'baseball game is on 10/2/2008' }
|
593
593
|
let(:run_date) { Time.local(2008, 1, 30) }
|
594
594
|
|
595
|
-
describe
|
596
|
-
it
|
595
|
+
describe '#occurrences' do
|
596
|
+
it 'is October 2nd' do
|
597
597
|
expect(n.occurrences).to match_array [
|
598
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
598
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081002'))
|
599
599
|
]
|
600
600
|
end
|
601
601
|
end
|
602
602
|
end
|
603
603
|
|
604
604
|
context "when the query is 'baseball game is on october 2nd 08'" do
|
605
|
-
let(:query) {
|
605
|
+
let(:query) { 'baseball game is on october 2nd 08' }
|
606
606
|
let(:run_date) { Time.local(2008, 1, 30) }
|
607
607
|
|
608
|
-
describe
|
609
|
-
it
|
608
|
+
describe '#occurrences' do
|
609
|
+
it 'is October 2nd' do
|
610
610
|
expect(n.occurrences).to match_array [
|
611
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
611
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081002'))
|
612
612
|
]
|
613
613
|
end
|
614
614
|
end
|
615
615
|
end
|
616
616
|
|
617
617
|
context "when the query is 'baseball game is on october 2nd 2008'" do
|
618
|
-
let(:query) {
|
618
|
+
let(:query) { 'baseball game is on october 2nd 2008' }
|
619
619
|
let(:run_date) { Time.local(2008, 1, 30) }
|
620
620
|
|
621
|
-
describe
|
622
|
-
it
|
621
|
+
describe '#occurrences' do
|
622
|
+
it 'is October 2nd' do
|
623
623
|
expect(n.occurrences).to match_array [
|
624
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
624
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081002'))
|
625
625
|
]
|
626
626
|
end
|
627
627
|
end
|
628
628
|
end
|
629
629
|
|
630
630
|
context "when the query is 'something for the next 1 day'" do
|
631
|
-
let(:query) {
|
631
|
+
let(:query) { 'something for the next 1 day' }
|
632
632
|
let(:run_date) { Time.local(2007, 12, 29) }
|
633
633
|
|
634
|
-
describe
|
634
|
+
describe '#message' do
|
635
635
|
it "is 'something'" do
|
636
|
-
expect(n.message).to eq
|
636
|
+
expect(n.message).to eq 'something'
|
637
637
|
end
|
638
638
|
end
|
639
639
|
|
640
|
-
describe
|
641
|
-
it
|
640
|
+
describe '#occurrences' do
|
641
|
+
it 'is today and tomorrow' do
|
642
642
|
expect(n.occurrences).to match_array [
|
643
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
643
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20071229'), end_date: Nickel::ZDate.new('20071230'))
|
644
644
|
]
|
645
645
|
end
|
646
646
|
end
|
647
647
|
end
|
648
648
|
|
649
649
|
context "when the query is 'pick up groceries tomorrow and also the kids'" do
|
650
|
-
let(:query) {
|
650
|
+
let(:query) { 'pick up groceries tomorrow and also the kids' }
|
651
651
|
let(:run_date) { Time.local(2008, 10, 28) }
|
652
652
|
|
653
|
-
describe
|
653
|
+
describe '#message' do
|
654
654
|
it "is 'pick up groceries and also the kids'" do
|
655
|
-
expect(n.message).to eq
|
655
|
+
expect(n.message).to eq 'pick up groceries and also the kids'
|
656
656
|
end
|
657
657
|
end
|
658
658
|
|
659
|
-
describe
|
660
|
-
it
|
659
|
+
describe '#occurrences' do
|
660
|
+
it 'is tomorrow' do
|
661
661
|
expect(n.occurrences).to match_array [
|
662
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
662
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081029'))
|
663
663
|
]
|
664
664
|
end
|
665
665
|
end
|
666
666
|
end
|
667
667
|
|
668
668
|
context "when the query is 'do something on january first'" do
|
669
|
-
let(:query) {
|
669
|
+
let(:query) { 'do something on january first' }
|
670
670
|
let(:run_date) { Time.local(2008, 11, 30) }
|
671
671
|
|
672
|
-
describe
|
672
|
+
describe '#message' do
|
673
673
|
it "is 'do something'" do
|
674
|
-
expect(n.message).to eq
|
674
|
+
expect(n.message).to eq 'do something'
|
675
675
|
end
|
676
676
|
end
|
677
677
|
|
678
|
-
describe
|
679
|
-
it
|
678
|
+
describe '#occurrences' do
|
679
|
+
it 'is January 1st' do
|
680
680
|
expect(n.occurrences).to match_array [
|
681
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
681
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090101'))
|
682
682
|
]
|
683
683
|
end
|
684
684
|
end
|
685
685
|
end
|
686
686
|
|
687
687
|
context "when the query is 'on the first of the month, go to the museum'" do
|
688
|
-
let(:query) {
|
688
|
+
let(:query) { 'on the first of the month, go to the museum' }
|
689
689
|
let(:run_date) { Time.local(2008, 11, 30) }
|
690
690
|
|
691
|
-
describe
|
691
|
+
describe '#message' do
|
692
692
|
it "is 'go to the museum'" do
|
693
|
-
expect(n.message).to eq
|
693
|
+
expect(n.message).to eq 'go to the museum'
|
694
694
|
end
|
695
695
|
end
|
696
696
|
|
697
|
-
describe
|
698
|
-
it
|
697
|
+
describe '#occurrences' do
|
698
|
+
it 'is the 1st of this month' do
|
699
699
|
expect(n.occurrences).to match_array [
|
700
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
700
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081201'))
|
701
701
|
]
|
702
702
|
end
|
703
703
|
end
|
704
704
|
end
|
705
705
|
|
706
706
|
context "when the query is 'today from 8 to 4 and 9 to 5'" do
|
707
|
-
let(:query) {
|
707
|
+
let(:query) { 'today from 8 to 4 and 9 to 5' }
|
708
708
|
let(:run_date) { Time.local(2008, 9, 10) }
|
709
709
|
|
710
|
-
describe
|
711
|
-
it
|
710
|
+
describe '#occurrences' do
|
711
|
+
it 'is 8:00am to 4:00pm and 9:00am to 5:00pm' do
|
712
712
|
expect(n.occurrences).to match_array [
|
713
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
714
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
713
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('08'), end_time: Nickel::ZTime.new('16')),
|
714
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('09'), end_time: Nickel::ZTime.new('17'))
|
715
715
|
]
|
716
716
|
end
|
717
717
|
end
|
718
718
|
end
|
719
719
|
|
720
720
|
context "when the query is 'today from 9 to 5pm and 8am to 4'" do
|
721
|
-
let(:query) {
|
721
|
+
let(:query) { 'today from 9 to 5pm and 8am to 4' }
|
722
722
|
let(:run_date) { Time.local(2008, 9, 10) }
|
723
723
|
|
724
|
-
describe
|
725
|
-
it
|
724
|
+
describe '#occurrences' do
|
725
|
+
it 'is 9:00am to 5:00pm and 8:00am to 4:00pm' do
|
726
726
|
expect(n.occurrences).to match_array [
|
727
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
728
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
727
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('08'), end_time: Nickel::ZTime.new('16')),
|
728
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('09'), end_time: Nickel::ZTime.new('17'))
|
729
729
|
]
|
730
730
|
end
|
731
731
|
end
|
732
732
|
end
|
733
733
|
|
734
734
|
context "when the query is 'today at 11am, 2 and 3, and tomorrow from 2 to 6pm'" do
|
735
|
-
let(:query) {
|
735
|
+
let(:query) { 'today at 11am, 2 and 3, and tomorrow from 2 to 6pm' }
|
736
736
|
let(:run_date) { Time.local(2008, 9, 10) }
|
737
737
|
|
738
|
-
describe
|
739
|
-
it
|
738
|
+
describe '#occurrences' do
|
739
|
+
it 'is 11:00am, 2:00pm, 3:00pm, 2:00pm to 6:00pm' do
|
740
740
|
expect(n.occurrences).to match_array [
|
741
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
742
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
743
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
744
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
741
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('11')),
|
742
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('14')),
|
743
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080910'), start_time: Nickel::ZTime.new('15')),
|
744
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080911'), start_time: Nickel::ZTime.new('14'), end_time: Nickel::ZTime.new('18'))
|
745
745
|
]
|
746
746
|
end
|
747
747
|
end
|
748
748
|
end
|
749
749
|
|
750
750
|
context "when the query is 'next monday'" do
|
751
|
-
let(:query) {
|
751
|
+
let(:query) { 'next monday' }
|
752
752
|
let(:run_date) { Time.local(2008, 10, 27) }
|
753
753
|
|
754
|
-
describe
|
755
|
-
it
|
754
|
+
describe '#occurrences' do
|
755
|
+
it 'is next monday' do
|
756
756
|
expect(n.occurrences).to match_array [
|
757
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
757
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081103'))
|
758
758
|
]
|
759
759
|
end
|
760
760
|
end
|
761
761
|
end
|
762
762
|
|
763
763
|
context "when the query is 'last monday this month'" do
|
764
|
-
let(:query) {
|
764
|
+
let(:query) { 'last monday this month' }
|
765
765
|
let(:run_date) { Time.local(2008, 8, 25) }
|
766
766
|
|
767
|
-
describe
|
768
|
-
it
|
767
|
+
describe '#occurrences' do
|
768
|
+
it 'is last monday this month' do
|
769
769
|
expect(n.occurrences).to match_array [
|
770
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
770
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080825'))
|
771
771
|
]
|
772
772
|
end
|
773
773
|
end
|
774
774
|
end
|
775
775
|
|
776
776
|
context "when the query is 'the last monday of this month'" do
|
777
|
-
let(:query) {
|
777
|
+
let(:query) { 'the last monday of this month' }
|
778
778
|
let(:run_date) { Time.local(2008, 8, 25) }
|
779
779
|
|
780
|
-
describe
|
781
|
-
it
|
780
|
+
describe '#occurrences' do
|
781
|
+
it 'is last monday this month' do
|
782
782
|
expect(n.occurrences).to match_array [
|
783
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
783
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080825'))
|
784
784
|
]
|
785
785
|
end
|
786
786
|
end
|
787
787
|
end
|
788
788
|
|
789
789
|
context "when the query is 'the last thursday of the month'" do
|
790
|
-
let(:query) {
|
790
|
+
let(:query) { 'the last thursday of the month' }
|
791
791
|
let(:run_date) { Time.local(2008, 8, 25) }
|
792
792
|
|
793
|
-
describe
|
794
|
-
it
|
793
|
+
describe '#occurrences' do
|
794
|
+
it 'is last thursday this month' do
|
795
795
|
expect(n.occurrences).to match_array [
|
796
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
796
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080828'))
|
797
797
|
]
|
798
798
|
end
|
799
799
|
end
|
800
800
|
end
|
801
801
|
|
802
802
|
context "when the query is 'third monday next month'" do
|
803
|
-
let(:query) {
|
803
|
+
let(:query) { 'third monday next month' }
|
804
804
|
let(:run_date) { Time.local(2008, 8, 25) }
|
805
805
|
|
806
|
-
describe
|
807
|
-
it
|
806
|
+
describe '#occurrences' do
|
807
|
+
it 'is third monday last month' do
|
808
808
|
expect(n.occurrences).to match_array [
|
809
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
809
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080915'))
|
810
810
|
]
|
811
811
|
end
|
812
812
|
end
|
813
813
|
end
|
814
814
|
|
815
815
|
context "when the query is 'the third monday next month'" do
|
816
|
-
let(:query) {
|
816
|
+
let(:query) { 'the third monday next month' }
|
817
817
|
let(:run_date) { Time.local(2008, 8, 25) }
|
818
818
|
|
819
|
-
describe
|
820
|
-
it
|
819
|
+
describe '#occurrences' do
|
820
|
+
it 'is third monday last month' do
|
821
821
|
expect(n.occurrences).to match_array [
|
822
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
822
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080915'))
|
823
823
|
]
|
824
824
|
end
|
825
825
|
end
|
826
826
|
end
|
827
827
|
|
828
828
|
context "when the query is 'the twentyeigth'" do
|
829
|
-
let(:query) {
|
829
|
+
let(:query) { 'the twentyeigth' }
|
830
830
|
let(:run_date) { Time.local(2010, 3, 20) }
|
831
831
|
|
832
|
-
describe
|
833
|
-
it
|
832
|
+
describe '#occurrences' do
|
833
|
+
it 'is the 28th of this month' do
|
834
834
|
expect(n.occurrences).to match_array [
|
835
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
835
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20100328'))
|
836
836
|
]
|
837
837
|
end
|
838
838
|
end
|
839
839
|
end
|
840
840
|
|
841
841
|
context "when the query is '28th'" do
|
842
|
-
let(:query) {
|
842
|
+
let(:query) { '28th' }
|
843
843
|
let(:run_date) { Time.local(2010, 3, 20) }
|
844
844
|
|
845
|
-
describe
|
846
|
-
it
|
845
|
+
describe '#occurrences' do
|
846
|
+
it 'is the 28th of this month' do
|
847
847
|
expect(n.occurrences).to match_array [
|
848
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
848
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20100328'))
|
849
849
|
]
|
850
850
|
end
|
851
851
|
end
|
852
852
|
end
|
853
853
|
|
854
854
|
context "when the query is '28'" do
|
855
|
-
let(:query) {
|
855
|
+
let(:query) { '28' }
|
856
856
|
let(:run_date) { Time.local(2010, 3, 20) }
|
857
857
|
|
858
|
-
describe
|
859
|
-
it
|
858
|
+
describe '#occurrences' do
|
859
|
+
it 'is the 28th of this month' do
|
860
860
|
expect(n.occurrences).to match_array [
|
861
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
861
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20100328'))
|
862
862
|
]
|
863
863
|
end
|
864
864
|
end
|
865
865
|
end
|
866
866
|
|
867
867
|
context "when the query is 'the 28th of this month'" do
|
868
|
-
let(:query) {
|
868
|
+
let(:query) { 'the 28th of this month' }
|
869
869
|
let(:run_date) { Time.local(2010, 3, 20) }
|
870
870
|
|
871
|
-
describe
|
872
|
-
it
|
871
|
+
describe '#occurrences' do
|
872
|
+
it 'is the 28th of this month' do
|
873
873
|
expect(n.occurrences).to match_array [
|
874
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
874
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20100328'))
|
875
875
|
]
|
876
876
|
end
|
877
877
|
end
|
878
878
|
end
|
879
879
|
|
880
880
|
context "when the query is '28th of this month'" do
|
881
|
-
let(:query) {
|
881
|
+
let(:query) { '28th of this month' }
|
882
882
|
let(:run_date) { Time.local(2010, 3, 20) }
|
883
883
|
|
884
|
-
describe
|
885
|
-
it
|
884
|
+
describe '#occurrences' do
|
885
|
+
it 'is the 28th of this month' do
|
886
886
|
expect(n.occurrences).to match_array [
|
887
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
887
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20100328'))
|
888
888
|
]
|
889
889
|
end
|
890
890
|
end
|
891
891
|
end
|
892
892
|
|
893
893
|
context "when the query is 'the 28th this month'" do
|
894
|
-
let(:query) {
|
894
|
+
let(:query) { 'the 28th this month' }
|
895
895
|
let(:run_date) { Time.local(2010, 3, 20) }
|
896
896
|
|
897
|
-
describe
|
898
|
-
it
|
897
|
+
describe '#occurrences' do
|
898
|
+
it 'is the 28th of this month' do
|
899
899
|
expect(n.occurrences).to match_array [
|
900
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
900
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20100328'))
|
901
901
|
]
|
902
902
|
end
|
903
903
|
end
|
904
904
|
end
|
905
905
|
|
906
906
|
context "when the query is 'next month 28th'" do
|
907
|
-
let(:query) {
|
907
|
+
let(:query) { 'next month 28th' }
|
908
908
|
let(:run_date) { Time.local(2008, 12, 31) }
|
909
909
|
|
910
|
-
describe
|
911
|
-
it
|
910
|
+
describe '#occurrences' do
|
911
|
+
it 'is the 28th of next month' do
|
912
912
|
expect(n.occurrences).to match_array [
|
913
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
913
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090128'))
|
914
914
|
]
|
915
915
|
end
|
916
916
|
end
|
917
917
|
end
|
918
918
|
|
919
919
|
context "when the query is '28th next month'" do
|
920
|
-
let(:query) {
|
920
|
+
let(:query) { '28th next month' }
|
921
921
|
let(:run_date) { Time.local(2008, 12, 31) }
|
922
922
|
|
923
|
-
describe
|
924
|
-
it
|
923
|
+
describe '#occurrences' do
|
924
|
+
it 'is the 28th of next month' do
|
925
925
|
expect(n.occurrences).to match_array [
|
926
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
926
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090128'))
|
927
927
|
]
|
928
928
|
end
|
929
929
|
end
|
930
930
|
end
|
931
931
|
|
932
932
|
context "when the query is 'the 28th next month'" do
|
933
|
-
let(:query) {
|
933
|
+
let(:query) { 'the 28th next month' }
|
934
934
|
let(:run_date) { Time.local(2008, 12, 31) }
|
935
935
|
|
936
|
-
describe
|
937
|
-
it
|
936
|
+
describe '#occurrences' do
|
937
|
+
it 'is the 28th of next month' do
|
938
938
|
expect(n.occurrences).to match_array [
|
939
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
939
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090128'))
|
940
940
|
]
|
941
941
|
end
|
942
942
|
end
|
943
943
|
end
|
944
944
|
|
945
945
|
context "when the query is '28th of next month'" do
|
946
|
-
let(:query) {
|
946
|
+
let(:query) { '28th of next month' }
|
947
947
|
let(:run_date) { Time.local(2008, 12, 31) }
|
948
948
|
|
949
|
-
describe
|
950
|
-
it
|
949
|
+
describe '#occurrences' do
|
950
|
+
it 'is the 28th of next month' do
|
951
951
|
expect(n.occurrences).to match_array [
|
952
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
952
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090128'))
|
953
953
|
]
|
954
954
|
end
|
955
955
|
end
|
956
956
|
end
|
957
957
|
|
958
958
|
context "when the query is 'the 28th of next month'" do
|
959
|
-
let(:query) {
|
959
|
+
let(:query) { 'the 28th of next month' }
|
960
960
|
let(:run_date) { Time.local(2008, 12, 31) }
|
961
961
|
|
962
|
-
describe
|
963
|
-
it
|
962
|
+
describe '#occurrences' do
|
963
|
+
it 'is the 28th of next month' do
|
964
964
|
expect(n.occurrences).to match_array [
|
965
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
965
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090128'))
|
966
|
+
]
|
967
|
+
end
|
968
|
+
end
|
969
|
+
end
|
970
|
+
|
971
|
+
context "when the query is '6 days from tomorrow'", broken: true do
|
972
|
+
let(:query) { '6 days from tomorrow' }
|
973
|
+
let(:run_date) { Time.local(2014, 2, 12) }
|
974
|
+
|
975
|
+
describe '#occurrences' do
|
976
|
+
it 'is 7 days from now' do
|
977
|
+
expect(n.occurrences).to match_array [
|
978
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140218'))
|
966
979
|
]
|
967
980
|
end
|
968
981
|
end
|
969
982
|
end
|
970
983
|
|
971
984
|
context "when the query is '5 days from now'" do
|
972
|
-
let(:query) {
|
985
|
+
let(:query) { '5 days from now' }
|
973
986
|
let(:run_date) { Time.local(2008, 9, 11) }
|
974
987
|
|
975
|
-
describe
|
976
|
-
it
|
988
|
+
describe '#occurrences' do
|
989
|
+
it 'is 5 days from now' do
|
977
990
|
expect(n.occurrences).to match_array [
|
978
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
991
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080916'))
|
979
992
|
]
|
980
993
|
end
|
981
994
|
end
|
982
995
|
end
|
983
996
|
|
984
997
|
context "when the query is 'in 5 days'" do
|
985
|
-
let(:query) {
|
998
|
+
let(:query) { 'in 5 days' }
|
986
999
|
let(:run_date) { Time.local(2008, 9, 11) }
|
987
1000
|
|
988
|
-
describe
|
989
|
-
it
|
1001
|
+
describe '#occurrences' do
|
1002
|
+
it 'is 5 days from now' do
|
990
1003
|
expect(n.occurrences).to match_array [
|
991
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1004
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080916'))
|
992
1005
|
]
|
993
1006
|
end
|
994
1007
|
end
|
995
1008
|
end
|
996
1009
|
|
997
1010
|
context "when the query is '5 weeks from now'" do
|
998
|
-
let(:query) {
|
1011
|
+
let(:query) { '5 weeks from now' }
|
999
1012
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1000
1013
|
|
1001
|
-
describe
|
1002
|
-
it
|
1014
|
+
describe '#occurrences' do
|
1015
|
+
it 'is 5 weeks from now' do
|
1003
1016
|
expect(n.occurrences).to match_array [
|
1004
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1017
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081016'))
|
1005
1018
|
]
|
1006
1019
|
end
|
1007
1020
|
end
|
1008
1021
|
end
|
1009
1022
|
|
1010
1023
|
context "when the query is 'in 5 weeks'" do
|
1011
|
-
let(:query) {
|
1024
|
+
let(:query) { 'in 5 weeks' }
|
1012
1025
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1013
1026
|
|
1014
|
-
describe
|
1015
|
-
it
|
1027
|
+
describe '#occurrences' do
|
1028
|
+
it 'is 5 weeks from now' do
|
1016
1029
|
expect(n.occurrences).to match_array [
|
1017
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1030
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20081016'))
|
1018
1031
|
]
|
1019
1032
|
end
|
1020
1033
|
end
|
1021
1034
|
end
|
1022
1035
|
|
1023
1036
|
context "when the query is '5 months from now'" do
|
1024
|
-
let(:query) {
|
1037
|
+
let(:query) { '5 months from now' }
|
1025
1038
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1026
1039
|
|
1027
|
-
describe
|
1028
|
-
it
|
1040
|
+
describe '#occurrences' do
|
1041
|
+
it 'is 5 months from now' do
|
1029
1042
|
expect(n.occurrences).to match_array [
|
1030
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1043
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090211'))
|
1031
1044
|
]
|
1032
1045
|
end
|
1033
1046
|
end
|
1034
1047
|
end
|
1035
1048
|
|
1036
1049
|
context "when the query is 'in 5 months'" do
|
1037
|
-
let(:query) {
|
1050
|
+
let(:query) { 'in 5 months' }
|
1038
1051
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1039
1052
|
|
1040
|
-
describe
|
1041
|
-
it
|
1053
|
+
describe '#occurrences' do
|
1054
|
+
it 'is 5 months from now' do
|
1042
1055
|
expect(n.occurrences).to match_array [
|
1043
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1056
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090211'))
|
1044
1057
|
]
|
1045
1058
|
end
|
1046
1059
|
end
|
1047
1060
|
end
|
1048
1061
|
|
1049
1062
|
context "when the query is '5 minutes from now'" do
|
1050
|
-
let(:query) {
|
1063
|
+
let(:query) { '5 minutes from now' }
|
1051
1064
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1052
1065
|
|
1053
|
-
describe
|
1054
|
-
it
|
1066
|
+
describe '#occurrences' do
|
1067
|
+
it 'is 5 minutes from now' do
|
1055
1068
|
expect(n.occurrences).to match_array [
|
1056
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1069
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080911'), start_time: Nickel::ZTime.new('0005'))
|
1057
1070
|
]
|
1058
1071
|
end
|
1059
1072
|
end
|
1060
1073
|
end
|
1061
1074
|
|
1062
1075
|
context "when the query is 'in 5 minutes'" do
|
1063
|
-
let(:query) {
|
1076
|
+
let(:query) { 'in 5 minutes' }
|
1064
1077
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1065
1078
|
|
1066
|
-
describe
|
1067
|
-
it
|
1079
|
+
describe '#occurrences' do
|
1080
|
+
it 'is 5 minutes from now' do
|
1068
1081
|
expect(n.occurrences).to match_array [
|
1069
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1082
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080911'), start_time: Nickel::ZTime.new('0005'))
|
1070
1083
|
]
|
1071
1084
|
end
|
1072
1085
|
end
|
1073
1086
|
end
|
1074
1087
|
|
1075
1088
|
context "when the query is '5 hours from now'" do
|
1076
|
-
let(:query) {
|
1089
|
+
let(:query) { '5 hours from now' }
|
1077
1090
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1078
1091
|
|
1079
|
-
describe
|
1080
|
-
it
|
1092
|
+
describe '#occurrences' do
|
1093
|
+
it 'is 5 hours from now' do
|
1081
1094
|
expect(n.occurrences).to match_array [
|
1082
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1095
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080911'), start_time: Nickel::ZTime.new('05'))
|
1083
1096
|
]
|
1084
1097
|
end
|
1085
1098
|
end
|
1086
1099
|
end
|
1087
1100
|
|
1088
1101
|
context "when the query is 'in 5 hours'" do
|
1089
|
-
let(:query) {
|
1102
|
+
let(:query) { 'in 5 hours' }
|
1090
1103
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1091
1104
|
|
1092
|
-
describe
|
1093
|
-
it
|
1105
|
+
describe '#occurrences' do
|
1106
|
+
it 'is 5 hours from now' do
|
1094
1107
|
expect(n.occurrences).to match_array [
|
1095
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1108
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080911'), start_time: Nickel::ZTime.new('05'))
|
1096
1109
|
]
|
1097
1110
|
end
|
1098
1111
|
end
|
1099
1112
|
end
|
1100
1113
|
|
1101
1114
|
context "when the query is '24 hours from now'" do
|
1102
|
-
let(:query) {
|
1115
|
+
let(:query) { '24 hours from now' }
|
1103
1116
|
let(:run_date) { Time.local(2008, 9, 11) }
|
1104
1117
|
|
1105
|
-
describe
|
1106
|
-
it
|
1118
|
+
describe '#occurrences' do
|
1119
|
+
it 'is 24 hours from now' do
|
1107
1120
|
expect(n.occurrences).to match_array [
|
1108
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1121
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080912'), start_time: Nickel::ZTime.new('000000'))
|
1109
1122
|
]
|
1110
1123
|
end
|
1111
1124
|
end
|
1112
1125
|
end
|
1113
1126
|
|
1114
1127
|
context "when the query is 'tomorrow through sunday'" do
|
1115
|
-
let(:query) {
|
1128
|
+
let(:query) { 'tomorrow through sunday' }
|
1116
1129
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1117
1130
|
|
1118
|
-
describe
|
1119
|
-
it
|
1131
|
+
describe '#occurrences' do
|
1132
|
+
it 'is tomorrow to sunday' do
|
1120
1133
|
expect(n.occurrences).to match_array [
|
1121
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1134
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20080919'), end_date: Nickel::ZDate.new('20080921'), interval: 1)
|
1122
1135
|
]
|
1123
1136
|
end
|
1124
1137
|
end
|
1125
1138
|
end
|
1126
1139
|
|
1127
1140
|
context "when the query is 'tomorrow through sunday from 9 to 5'" do
|
1128
|
-
let(:query) {
|
1141
|
+
let(:query) { 'tomorrow through sunday from 9 to 5' }
|
1129
1142
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1130
1143
|
|
1131
|
-
describe
|
1132
|
-
it
|
1144
|
+
describe '#occurrences' do
|
1145
|
+
it 'is 9:00am to 5:00pm every day from tomorrow to sunday' do
|
1133
1146
|
expect(n.occurrences).to match_array [
|
1134
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1147
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20080919'), end_date: Nickel::ZDate.new('20080921'), start_time: Nickel::ZTime.new('09'), end_time: Nickel::ZTime.new('17'), interval: 1)
|
1135
1148
|
]
|
1136
1149
|
end
|
1137
1150
|
end
|
1138
1151
|
end
|
1139
1152
|
|
1140
1153
|
context "when the query is '9 to 5 tomorrow through sunday'" do
|
1141
|
-
let(:query) {
|
1154
|
+
let(:query) { '9 to 5 tomorrow through sunday' }
|
1142
1155
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1143
1156
|
|
1144
|
-
describe
|
1145
|
-
it
|
1157
|
+
describe '#occurrences' do
|
1158
|
+
it 'is 9:00am to 5:00pm every day from tomorrow to sunday' do
|
1146
1159
|
expect(n.occurrences).to match_array [
|
1147
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1160
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20080919'), end_date: Nickel::ZDate.new('20080921'), start_time: Nickel::ZTime.new('09'), end_time: Nickel::ZTime.new('17'), interval: 1)
|
1148
1161
|
]
|
1149
1162
|
end
|
1150
1163
|
end
|
1151
1164
|
end
|
1152
1165
|
|
1153
1166
|
context "when the query is 'october 2nd through 5th'" do
|
1154
|
-
let(:query) {
|
1167
|
+
let(:query) { 'october 2nd through 5th' }
|
1155
1168
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1156
1169
|
|
1157
|
-
describe
|
1158
|
-
it
|
1170
|
+
describe '#occurrences' do
|
1171
|
+
it 'is every day from October 2nd to October 5th' do
|
1159
1172
|
expect(n.occurrences).to match_array [
|
1160
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1173
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1)
|
1161
1174
|
]
|
1162
1175
|
end
|
1163
1176
|
end
|
1164
1177
|
end
|
1165
1178
|
|
1166
1179
|
context "when the query is 'october 2nd through october 5th'" do
|
1167
|
-
let(:query) {
|
1180
|
+
let(:query) { 'october 2nd through october 5th' }
|
1168
1181
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1169
1182
|
|
1170
|
-
describe
|
1171
|
-
it
|
1183
|
+
describe '#occurrences' do
|
1184
|
+
it 'is every day from October 2nd to October 5th' do
|
1172
1185
|
expect(n.occurrences).to match_array [
|
1173
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1186
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1)
|
1174
1187
|
]
|
1175
1188
|
end
|
1176
1189
|
end
|
1177
1190
|
end
|
1178
1191
|
|
1179
1192
|
context "when the query is '10/2 to 10/5'" do
|
1180
|
-
let(:query) {
|
1193
|
+
let(:query) { '10/2 to 10/5' }
|
1181
1194
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1182
1195
|
|
1183
|
-
describe
|
1184
|
-
it
|
1196
|
+
describe '#occurrences' do
|
1197
|
+
it 'is every day from October 2nd to October 5th' do
|
1185
1198
|
expect(n.occurrences).to match_array [
|
1186
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1199
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1)
|
1187
1200
|
]
|
1188
1201
|
end
|
1189
1202
|
end
|
1190
1203
|
end
|
1191
1204
|
|
1192
1205
|
context "when the query is 'oct 2 until 5'" do
|
1193
|
-
let(:query) {
|
1206
|
+
let(:query) { 'oct 2 until 5' }
|
1194
1207
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1195
1208
|
|
1196
|
-
describe
|
1197
|
-
it
|
1209
|
+
describe '#occurrences' do
|
1210
|
+
it 'is every day from October 2nd to October 5th' do
|
1198
1211
|
expect(n.occurrences).to match_array [
|
1199
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1212
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1)
|
1200
1213
|
]
|
1201
1214
|
end
|
1202
1215
|
end
|
1203
1216
|
end
|
1204
1217
|
|
1205
1218
|
context "when the query is 'oct 2 until oct 5'" do
|
1206
|
-
let(:query) {
|
1219
|
+
let(:query) { 'oct 2 until oct 5' }
|
1207
1220
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1208
1221
|
|
1209
|
-
describe
|
1210
|
-
it
|
1222
|
+
describe '#occurrences' do
|
1223
|
+
it 'is every day from October 2nd to October 5th' do
|
1211
1224
|
expect(n.occurrences).to match_array [
|
1212
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1225
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1)
|
1213
1226
|
]
|
1214
1227
|
end
|
1215
1228
|
end
|
1216
1229
|
end
|
1217
1230
|
|
1218
1231
|
context "when the query is 'oct 2-oct 5'" do
|
1219
|
-
let(:query) {
|
1232
|
+
let(:query) { 'oct 2-oct 5' }
|
1220
1233
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1221
1234
|
|
1222
|
-
describe
|
1223
|
-
it
|
1235
|
+
describe '#occurrences' do
|
1236
|
+
it 'is every day from October 2nd to October 5th' do
|
1224
1237
|
expect(n.occurrences).to match_array [
|
1225
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1238
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1)
|
1226
1239
|
]
|
1227
1240
|
end
|
1228
1241
|
end
|
1229
1242
|
end
|
1230
1243
|
|
1231
1244
|
context "when the query is 'october 2nd-5th'" do
|
1232
|
-
let(:query) {
|
1245
|
+
let(:query) { 'october 2nd-5th' }
|
1233
1246
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1234
1247
|
|
1235
|
-
describe
|
1236
|
-
it
|
1248
|
+
describe '#occurrences' do
|
1249
|
+
it 'is every day from October 2nd to October 5th' do
|
1237
1250
|
expect(n.occurrences).to match_array [
|
1238
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1251
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1)
|
1239
1252
|
]
|
1240
1253
|
end
|
1241
1254
|
end
|
1242
1255
|
end
|
1243
1256
|
|
1244
1257
|
context "when the query is 'october 2nd-5th from 9 to 5am'" do
|
1245
|
-
let(:query) {
|
1258
|
+
let(:query) { 'october 2nd-5th from 9 to 5am' }
|
1246
1259
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1247
1260
|
|
1248
|
-
describe
|
1249
|
-
it
|
1261
|
+
describe '#occurrences' do
|
1262
|
+
it 'is 9:00am to 5:00pm every day from October 2nd to October 5th' do
|
1250
1263
|
expect(n.occurrences).to match_array [
|
1251
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1264
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1, start_time: Nickel::ZTime.new('21'), end_time: Nickel::ZTime.new('05'))
|
1252
1265
|
]
|
1253
1266
|
end
|
1254
1267
|
end
|
1255
1268
|
end
|
1256
1269
|
|
1257
1270
|
context "when the query is 'october 2nd-5th every day from 9 to 5am'" do
|
1258
|
-
let(:query) {
|
1271
|
+
let(:query) { 'october 2nd-5th every day from 9 to 5am' }
|
1259
1272
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1260
1273
|
|
1261
|
-
describe
|
1262
|
-
it
|
1274
|
+
describe '#occurrences' do
|
1275
|
+
it 'is 9:00am to 5:00pm every day from October 2nd to October 5th' do
|
1263
1276
|
expect(n.occurrences).to match_array [
|
1264
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1277
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081005'), interval: 1, start_time: Nickel::ZTime.new('21'), end_time: Nickel::ZTime.new('05'))
|
1265
1278
|
]
|
1266
1279
|
end
|
1267
1280
|
end
|
1268
1281
|
end
|
1269
1282
|
|
1270
1283
|
context "when the query is 'january 1 from 1PM to 5AM'" do
|
1271
|
-
let(:query) {
|
1284
|
+
let(:query) { 'january 1 from 1PM to 5AM' }
|
1272
1285
|
let(:run_date) { Time.local(2013, 1, 25) }
|
1273
1286
|
|
1274
|
-
describe
|
1275
|
-
it
|
1287
|
+
describe '#occurrences' do
|
1288
|
+
it 'is 1:00pm to 5:00am January 1st' do
|
1276
1289
|
expect(n.occurrences).to match_array [
|
1277
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1290
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20130101'), start_time: Nickel::ZTime.new('13'), end_time: Nickel::ZTime.new('05'))
|
1278
1291
|
]
|
1279
1292
|
end
|
1280
1293
|
end
|
1281
1294
|
end
|
1282
1295
|
|
1283
1296
|
context "when the query is 'tuesday, january 1st - friday, february 15, 2013'" do
|
1284
|
-
let(:query) {
|
1297
|
+
let(:query) { 'tuesday, january 1st - friday, february 15, 2013' }
|
1285
1298
|
let(:run_date) { Time.local(2008, 1, 25) }
|
1286
1299
|
|
1287
|
-
describe
|
1288
|
-
it
|
1300
|
+
describe '#occurrences' do
|
1301
|
+
it 'is every day from January 1st to February 15th' do
|
1289
1302
|
expect(n.occurrences).to match_array [
|
1290
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1303
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20130101'), end_date: Nickel::ZDate.new('20130215'), interval: 1)
|
1291
1304
|
]
|
1292
1305
|
end
|
1293
1306
|
end
|
1294
1307
|
end
|
1295
1308
|
|
1296
1309
|
context "when the query is 'tuesday, january 1, 2013 - friday, february 15, 2013'" do
|
1297
|
-
let(:query) {
|
1310
|
+
let(:query) { 'tuesday, january 1, 2013 - friday, february 15, 2013' }
|
1298
1311
|
let(:run_date) { Time.local(2008, 1, 25) }
|
1299
1312
|
|
1300
|
-
describe
|
1301
|
-
it
|
1313
|
+
describe '#occurrences' do
|
1314
|
+
it 'is every day from January 1st to February 15th' do
|
1302
1315
|
expect(n.occurrences).to match_array [
|
1303
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1316
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20130101'), end_date: Nickel::ZDate.new('20130215'), interval: 1)
|
1304
1317
|
]
|
1305
1318
|
end
|
1306
1319
|
end
|
1307
1320
|
end
|
1308
1321
|
|
1309
1322
|
context "when the query is 'every monday and wednesday'" do
|
1310
|
-
let(:query) {
|
1323
|
+
let(:query) { 'every monday and wednesday' }
|
1311
1324
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1312
1325
|
|
1313
|
-
describe
|
1314
|
-
it
|
1326
|
+
describe '#occurrences' do
|
1327
|
+
it 'is every Monday and Wednesday' do
|
1315
1328
|
expect(n.occurrences).to match_array [
|
1316
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new(
|
1317
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 1, start_date: Nickel::ZDate.new(
|
1329
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new('20080922')),
|
1330
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 1, start_date: Nickel::ZDate.new('20080924'))
|
1318
1331
|
]
|
1319
1332
|
end
|
1320
1333
|
end
|
1321
1334
|
end
|
1322
1335
|
|
1323
1336
|
context "when the query is 'every other monday and wednesday'" do
|
1324
|
-
let(:query) {
|
1337
|
+
let(:query) { 'every other monday and wednesday' }
|
1325
1338
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1326
1339
|
|
1327
|
-
describe
|
1328
|
-
it
|
1340
|
+
describe '#occurrences' do
|
1341
|
+
it 'is every other Monday and Wednesday' do
|
1329
1342
|
expect(n.occurrences).to match_array [
|
1330
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 2, start_date: Nickel::ZDate.new(
|
1331
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 2, start_date: Nickel::ZDate.new(
|
1343
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 2, start_date: Nickel::ZDate.new('20080922')),
|
1344
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 2, start_date: Nickel::ZDate.new('20080924'))
|
1332
1345
|
]
|
1333
1346
|
end
|
1334
1347
|
end
|
1335
1348
|
end
|
1336
1349
|
|
1337
1350
|
context "when the query is 'every monday'" do
|
1338
|
-
let(:query) {
|
1351
|
+
let(:query) { 'every monday' }
|
1339
1352
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1340
1353
|
|
1341
|
-
describe
|
1342
|
-
it
|
1354
|
+
describe '#occurrences' do
|
1355
|
+
it 'is every Monday' do
|
1343
1356
|
expect(n.occurrences).to match_array [
|
1344
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new(
|
1357
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new('20080922'))
|
1345
1358
|
]
|
1346
1359
|
end
|
1347
1360
|
end
|
@@ -1349,511 +1362,576 @@ describe Nickel do
|
|
1349
1362
|
|
1350
1363
|
context "when the query is 'every monday at 2pm and wednesday at 4pm'", broken: true do
|
1351
1364
|
# FIXME: this spec should have two occurrences
|
1352
|
-
let(:query) {
|
1365
|
+
let(:query) { 'every monday at 2pm and wednesday at 4pm' }
|
1353
1366
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1354
1367
|
|
1355
|
-
describe
|
1356
|
-
it
|
1368
|
+
describe '#occurrences' do
|
1369
|
+
it 'is every Monday at 2:00pm and every Wednesday at 4:00pm' do
|
1357
1370
|
expect(n.occurrences).to match_array [
|
1358
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new(
|
1359
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 1, start_date: Nickel::ZDate.new(
|
1371
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new('20080922'), start_time: Nickel::ZTime.new('14')),
|
1372
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 1, start_date: Nickel::ZDate.new('20080924'), start_time: Nickel::ZTime.new('16'))
|
1360
1373
|
]
|
1361
1374
|
end
|
1362
1375
|
end
|
1363
1376
|
end
|
1364
1377
|
|
1365
1378
|
context "when the query is 'every monday at 2pm and every wednesday at 4pm'" do
|
1366
|
-
let(:query) {
|
1379
|
+
let(:query) { 'every monday at 2pm and every wednesday at 4pm' }
|
1367
1380
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1368
1381
|
|
1369
|
-
describe
|
1370
|
-
it
|
1382
|
+
describe '#occurrences' do
|
1383
|
+
it 'is every Monday at 2:00pm and every Wednesday at 4:00pm' do
|
1371
1384
|
expect(n.occurrences).to match_array [
|
1372
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new(
|
1373
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 1, start_date: Nickel::ZDate.new(
|
1385
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new('20080922'), start_time: Nickel::ZTime.new('14')),
|
1386
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 1, start_date: Nickel::ZDate.new('20080924'), start_time: Nickel::ZTime.new('16'))
|
1374
1387
|
]
|
1375
1388
|
end
|
1376
1389
|
end
|
1377
1390
|
end
|
1378
1391
|
|
1379
1392
|
context "when the query is 'every monday every wednesday'" do
|
1380
|
-
let(:query) {
|
1393
|
+
let(:query) { 'every monday every wednesday' }
|
1381
1394
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1382
1395
|
|
1383
|
-
describe
|
1384
|
-
it
|
1396
|
+
describe '#occurrences' do
|
1397
|
+
it 'is every Monday at 2:00pm and every Wednesday at 4:00pm' do
|
1385
1398
|
expect(n.occurrences).to match_array [
|
1386
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new(
|
1387
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 1, start_date: Nickel::ZDate.new(
|
1399
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new('20080922')),
|
1400
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 2, interval: 1, start_date: Nickel::ZDate.new('20080924'))
|
1388
1401
|
]
|
1389
1402
|
end
|
1390
1403
|
end
|
1391
1404
|
end
|
1392
1405
|
|
1393
1406
|
context "when the query is 'the 22nd of every month'" do
|
1394
|
-
let(:query) {
|
1407
|
+
let(:query) { 'the 22nd of every month' }
|
1395
1408
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1396
1409
|
|
1397
|
-
describe
|
1398
|
-
it
|
1410
|
+
describe '#occurrences' do
|
1411
|
+
it 'is the 22nd of every month' do
|
1399
1412
|
expect(n.occurrences).to match_array [
|
1400
|
-
Nickel::Occurrence.new(type: :datemonthly, date_of_month: 22, interval: 1, start_date: Nickel::ZDate.new(
|
1413
|
+
Nickel::Occurrence.new(type: :datemonthly, date_of_month: 22, interval: 1, start_date: Nickel::ZDate.new('20080922'))
|
1401
1414
|
]
|
1402
1415
|
end
|
1403
1416
|
end
|
1404
1417
|
end
|
1405
1418
|
|
1406
1419
|
context "when the query is 'the first friday of every month'" do
|
1407
|
-
let(:query) {
|
1420
|
+
let(:query) { 'the first friday of every month' }
|
1408
1421
|
let(:run_date) { Time.local(2008, 9, 18) }
|
1409
1422
|
|
1410
|
-
describe
|
1411
|
-
it
|
1423
|
+
describe '#occurrences' do
|
1424
|
+
it 'is the first friday of every month' do
|
1412
1425
|
expect(n.occurrences).to match_array [
|
1413
|
-
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 1, day_of_week: 4, interval: 1, start_date: Nickel::ZDate.new(
|
1426
|
+
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 1, day_of_week: 4, interval: 1, start_date: Nickel::ZDate.new('20081003'))
|
1414
1427
|
]
|
1415
1428
|
end
|
1416
1429
|
end
|
1417
1430
|
end
|
1418
1431
|
|
1419
1432
|
context "when the query is 'the second tuesday of every month at 5pm'" do
|
1420
|
-
let(:query) {
|
1433
|
+
let(:query) { 'the second tuesday of every month at 5pm' }
|
1421
1434
|
let(:run_date) { Time.local(2008, 9, 24) }
|
1422
1435
|
|
1423
|
-
describe
|
1424
|
-
it
|
1436
|
+
describe '#occurrences' do
|
1437
|
+
it 'is 5:00pm on the second Tuesday of every month' do
|
1425
1438
|
expect(n.occurrences).to match_array [
|
1426
|
-
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 2, day_of_week: 1, interval: 1, start_date: Nickel::ZDate.new(
|
1439
|
+
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 2, day_of_week: 1, interval: 1, start_date: Nickel::ZDate.new('20081014'), start_time: Nickel::ZTime.new('17'))
|
1427
1440
|
]
|
1428
1441
|
end
|
1429
1442
|
end
|
1430
1443
|
end
|
1431
1444
|
|
1432
1445
|
context "when the query is 'the first tuesday of every month at 4pm and 5pm, the second tuesday of every month at 5pm'" do
|
1433
|
-
let(:query) {
|
1446
|
+
let(:query) { 'the first tuesday of every month at 4pm and 5pm, the second tuesday of every month at 5pm' }
|
1434
1447
|
let(:run_date) { Time.local(2008, 9, 24) }
|
1435
1448
|
|
1436
|
-
describe
|
1437
|
-
it
|
1449
|
+
describe '#occurrences' do
|
1450
|
+
it 'is 4:00pm to 5:00pm on the first Tuesday of every month and 5:00pm on the second Tuesday of every month' do
|
1438
1451
|
expect(n.occurrences).to match_array [
|
1439
|
-
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 1, day_of_week: 1, interval: 1, start_date: Nickel::ZDate.new(
|
1440
|
-
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 1, day_of_week: 1, interval: 1, start_date: Nickel::ZDate.new(
|
1441
|
-
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 2, day_of_week: 1, interval: 1, start_date: Nickel::ZDate.new(
|
1452
|
+
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 1, day_of_week: 1, interval: 1, start_date: Nickel::ZDate.new('20081007'), start_time: Nickel::ZTime.new('16')),
|
1453
|
+
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 1, day_of_week: 1, interval: 1, start_date: Nickel::ZDate.new('20081007'), start_time: Nickel::ZTime.new('17')),
|
1454
|
+
Nickel::Occurrence.new(type: :daymonthly, week_of_month: 2, day_of_week: 1, interval: 1, start_date: Nickel::ZDate.new('20081014'), start_time: Nickel::ZTime.new('17'))
|
1442
1455
|
]
|
1443
1456
|
end
|
1444
1457
|
end
|
1445
1458
|
end
|
1446
1459
|
|
1447
1460
|
context "when the query is 'every sunday in december'" do
|
1448
|
-
let(:query) {
|
1461
|
+
let(:query) { 'every sunday in december' }
|
1449
1462
|
let(:run_date) { Time.local(2008, 9, 24) }
|
1450
1463
|
|
1451
|
-
describe
|
1452
|
-
it
|
1464
|
+
describe '#occurrences' do
|
1465
|
+
it 'is every Sunday in December' do
|
1453
1466
|
expect(n.occurrences).to match_array [
|
1454
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 6, interval: 1, start_date: Nickel::ZDate.new(
|
1467
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 6, interval: 1, start_date: Nickel::ZDate.new('20081207'), end_date: Nickel::ZDate.new('20081228'))
|
1455
1468
|
]
|
1456
1469
|
end
|
1457
1470
|
end
|
1458
1471
|
end
|
1459
1472
|
|
1460
1473
|
context "when the query is 'every monday until december'" do
|
1461
|
-
let(:query) {
|
1474
|
+
let(:query) { 'every monday until december' }
|
1462
1475
|
let(:run_date) { Time.local(2008, 9, 24) }
|
1463
1476
|
|
1464
|
-
describe
|
1465
|
-
it
|
1477
|
+
describe '#occurrences' do
|
1478
|
+
it 'is every Monday from now until December' do
|
1466
1479
|
expect(n.occurrences).to match_array [
|
1467
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new(
|
1480
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new('20080929'), end_date: Nickel::ZDate.new('20081124'))
|
1468
1481
|
]
|
1469
1482
|
end
|
1470
1483
|
end
|
1471
1484
|
end
|
1472
1485
|
|
1473
1486
|
context "when the query is 'every monday next month'" do
|
1474
|
-
let(:query) {
|
1487
|
+
let(:query) { 'every monday next month' }
|
1475
1488
|
let(:run_date) { Time.local(2008, 9, 24) }
|
1476
1489
|
|
1477
|
-
describe
|
1478
|
-
it
|
1490
|
+
describe '#occurrences' do
|
1491
|
+
it 'is every Monday next month' do
|
1479
1492
|
expect(n.occurrences).to match_array [
|
1480
|
-
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new(
|
1493
|
+
Nickel::Occurrence.new(type: :weekly, day_of_week: 0, interval: 1, start_date: Nickel::ZDate.new('20081006'), end_date: Nickel::ZDate.new('20081027'))
|
1481
1494
|
]
|
1482
1495
|
end
|
1483
1496
|
end
|
1484
1497
|
end
|
1485
1498
|
|
1486
1499
|
context "when the query is 'everyday next month'" do
|
1487
|
-
let(:query) {
|
1500
|
+
let(:query) { 'everyday next month' }
|
1488
1501
|
let(:run_date) { Time.local(2008, 12, 24) }
|
1489
1502
|
|
1490
|
-
describe
|
1491
|
-
it
|
1503
|
+
describe '#occurrences' do
|
1504
|
+
it 'is every day next month' do
|
1492
1505
|
expect(n.occurrences).to match_array [
|
1493
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
1506
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20090101'), end_date: Nickel::ZDate.new('20090131'))
|
1494
1507
|
]
|
1495
1508
|
end
|
1496
1509
|
end
|
1497
1510
|
end
|
1498
1511
|
|
1499
1512
|
context "when the query is 'in the next two days'" do
|
1500
|
-
let(:query) {
|
1513
|
+
let(:query) { 'in the next two days' }
|
1501
1514
|
let(:run_date) { Time.local(2007, 12, 29) }
|
1502
1515
|
|
1503
|
-
describe
|
1504
|
-
it
|
1516
|
+
describe '#occurrences' do
|
1517
|
+
it 'is today, tomorrow and the day after' do
|
1505
1518
|
expect(n.occurrences).to match_array [
|
1506
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
1519
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20071229'), end_date: Nickel::ZDate.new('20071231'))
|
1507
1520
|
]
|
1508
1521
|
end
|
1509
1522
|
end
|
1510
1523
|
end
|
1511
1524
|
|
1512
1525
|
context "when the query is 'for three days'" do
|
1513
|
-
let(:query) {
|
1526
|
+
let(:query) { 'for three days' }
|
1514
1527
|
let(:run_date) { Time.local(2007, 12, 29) }
|
1515
1528
|
|
1516
|
-
describe
|
1517
|
-
it
|
1529
|
+
describe '#occurrences' do
|
1530
|
+
it 'is today, tomorrow, the day after and the day after that' do
|
1518
1531
|
expect(n.occurrences).to match_array [
|
1519
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
1532
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20071229'), end_date: Nickel::ZDate.new('20080101'))
|
1520
1533
|
]
|
1521
1534
|
end
|
1522
1535
|
end
|
1523
1536
|
end
|
1524
1537
|
|
1525
1538
|
context "when the query is 'for the next three days'" do
|
1526
|
-
let(:query) {
|
1539
|
+
let(:query) { 'for the next three days' }
|
1527
1540
|
let(:run_date) { Time.local(2007, 12, 29) }
|
1528
1541
|
|
1529
|
-
describe
|
1530
|
-
it
|
1542
|
+
describe '#occurrences' do
|
1543
|
+
it 'is today, tomorrow, the day after and the day after that' do
|
1531
1544
|
expect(n.occurrences).to match_array [
|
1532
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
1545
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20071229'), end_date: Nickel::ZDate.new('20080101'))
|
1533
1546
|
]
|
1534
1547
|
end
|
1535
1548
|
end
|
1536
1549
|
end
|
1537
1550
|
|
1538
1551
|
context "when the query is 'this week'" do
|
1539
|
-
let(:query) {
|
1552
|
+
let(:query) { 'this week' }
|
1540
1553
|
let(:run_date) { Time.local(2008, 9, 25) }
|
1541
1554
|
|
1542
|
-
describe
|
1543
|
-
it
|
1555
|
+
describe '#occurrences' do
|
1556
|
+
it 'is every day from now until 7 days from now' do
|
1544
1557
|
expect(n.occurrences).to match_array [
|
1545
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
1558
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20080925'), end_date: Nickel::ZDate.new('20081002'))
|
1546
1559
|
]
|
1547
1560
|
end
|
1548
1561
|
end
|
1549
1562
|
end
|
1550
1563
|
|
1551
1564
|
context "when the query is 'every day this week'" do
|
1552
|
-
let(:query) {
|
1565
|
+
let(:query) { 'every day this week' }
|
1553
1566
|
let(:run_date) { Time.local(2008, 9, 25) }
|
1554
1567
|
|
1555
|
-
describe
|
1556
|
-
it
|
1568
|
+
describe '#occurrences' do
|
1569
|
+
it 'is every day from now until 7 days from now' do
|
1557
1570
|
expect(n.occurrences).to match_array [
|
1558
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
1571
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20080925'), end_date: Nickel::ZDate.new('20081002'))
|
1559
1572
|
]
|
1560
1573
|
end
|
1561
1574
|
end
|
1562
1575
|
end
|
1563
1576
|
|
1564
1577
|
context "when the query is 'next week'" do
|
1565
|
-
let(:query) {
|
1578
|
+
let(:query) { 'next week' }
|
1566
1579
|
let(:run_date) { Time.local(2008, 9, 25) }
|
1567
1580
|
|
1568
|
-
describe
|
1569
|
-
it
|
1581
|
+
describe '#occurrences' do
|
1582
|
+
it 'is every day from 7 days from now until 14 days from now' do
|
1570
1583
|
expect(n.occurrences).to match_array [
|
1571
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
1584
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081009'))
|
1572
1585
|
]
|
1573
1586
|
end
|
1574
1587
|
end
|
1575
1588
|
end
|
1576
1589
|
|
1577
1590
|
context "when the query is 'every day next week'" do
|
1578
|
-
let(:query) {
|
1591
|
+
let(:query) { 'every day next week' }
|
1579
1592
|
let(:run_date) { Time.local(2008, 9, 25) }
|
1580
1593
|
|
1581
|
-
describe
|
1582
|
-
it
|
1594
|
+
describe '#occurrences' do
|
1595
|
+
it 'is every day from 7 days from now until 14 days from now' do
|
1583
1596
|
expect(n.occurrences).to match_array [
|
1584
|
-
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new(
|
1597
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20081002'), end_date: Nickel::ZDate.new('20081009'))
|
1598
|
+
]
|
1599
|
+
end
|
1600
|
+
end
|
1601
|
+
end
|
1602
|
+
|
1603
|
+
context "when the query is 'for five weeks'" do
|
1604
|
+
let(:query) { 'for five weeks' }
|
1605
|
+
let(:run_date) { Time.local(2014, 2, 12) }
|
1606
|
+
|
1607
|
+
describe '#occurrences' do
|
1608
|
+
it 'is every day for the next 35 days' do
|
1609
|
+
expect(n.occurrences).to match_array [
|
1610
|
+
Nickel::Occurrence.new(type: :daily, interval: 1, start_date: Nickel::ZDate.new('20140212'), end_date: Nickel::ZDate.new('20140319'))
|
1585
1611
|
]
|
1586
1612
|
end
|
1587
1613
|
end
|
1588
1614
|
end
|
1589
1615
|
|
1590
1616
|
context "when the query is 'all month'" do
|
1591
|
-
let(:query) {
|
1617
|
+
let(:query) { 'all month' }
|
1592
1618
|
let(:run_date) { Time.local(2008, 10, 5) }
|
1593
1619
|
|
1594
|
-
describe
|
1595
|
-
it
|
1620
|
+
describe '#occurrences' do
|
1621
|
+
it 'is every day from now until the last day of the month' do
|
1596
1622
|
expect(n.occurrences).to match_array [
|
1597
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1623
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081005'), end_date: Nickel::ZDate.new('20081031'), interval: 1)
|
1598
1624
|
]
|
1599
1625
|
end
|
1600
1626
|
end
|
1601
1627
|
end
|
1602
1628
|
|
1603
1629
|
context "when the query is 'the week of jan 2nd'" do
|
1604
|
-
let(:query) {
|
1630
|
+
let(:query) { 'the week of jan 2nd' }
|
1605
1631
|
let(:run_date) { Time.local(2008, 12, 21) }
|
1606
1632
|
|
1607
|
-
describe
|
1608
|
-
it
|
1633
|
+
describe '#occurrences' do
|
1634
|
+
it 'is every day in the 7 days starting on January 2nd' do
|
1609
1635
|
expect(n.occurrences).to match_array [
|
1610
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1636
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20090102'), end_date: Nickel::ZDate.new('20090109'), interval: 1)
|
1611
1637
|
]
|
1612
1638
|
end
|
1613
1639
|
end
|
1614
1640
|
end
|
1615
1641
|
|
1616
1642
|
context "when the query is 'the week ending jan 2nd'" do
|
1617
|
-
let(:query) {
|
1643
|
+
let(:query) { 'the week ending jan 2nd' }
|
1618
1644
|
let(:run_date) { Time.local(2008, 12, 21) }
|
1619
1645
|
|
1620
|
-
describe
|
1621
|
-
it
|
1646
|
+
describe '#occurrences' do
|
1647
|
+
it 'is every day in the 7 days preceeding January 2nd' do
|
1622
1648
|
expect(n.occurrences).to match_array [
|
1623
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1649
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081226'), end_date: Nickel::ZDate.new('20090102'), interval: 1)
|
1624
1650
|
]
|
1625
1651
|
end
|
1626
1652
|
end
|
1627
1653
|
end
|
1628
1654
|
|
1629
1655
|
context "when the query is 'the week of the 22nd'" do
|
1630
|
-
let(:query) {
|
1656
|
+
let(:query) { 'the week of the 22nd' }
|
1631
1657
|
let(:run_date) { Time.local(2008, 12, 21) }
|
1632
1658
|
|
1633
|
-
describe
|
1634
|
-
it
|
1659
|
+
describe '#occurrences' do
|
1660
|
+
it 'is every day in the 7 days starting on the 22nd of this month' do
|
1635
1661
|
expect(n.occurrences).to match_array [
|
1636
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1662
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081222'), end_date: Nickel::ZDate.new('20081229'), interval: 1)
|
1637
1663
|
]
|
1638
1664
|
end
|
1639
1665
|
end
|
1640
1666
|
end
|
1641
1667
|
|
1642
1668
|
context "when the query is 'this monday, wednesday, friday and saturday'" do
|
1643
|
-
let(:query) {
|
1669
|
+
let(:query) { 'this monday, wednesday, friday and saturday' }
|
1644
1670
|
let(:run_date) { Time.local(2014, 2, 9) }
|
1645
1671
|
|
1646
|
-
describe
|
1647
|
-
it
|
1672
|
+
describe '#occurrences' do
|
1673
|
+
it 'is the following Monday, Wednesday, Friday and Saturday' do
|
1648
1674
|
expect(n.occurrences).to match_array [
|
1649
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1650
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1651
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1652
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1675
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140210')),
|
1676
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140212')),
|
1677
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140214')),
|
1678
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140215'))
|
1653
1679
|
]
|
1654
1680
|
end
|
1655
1681
|
end
|
1656
1682
|
end
|
1657
1683
|
|
1658
1684
|
context "when the query is 'monday, wednesday, friday and saturday'" do
|
1659
|
-
let(:query) {
|
1685
|
+
let(:query) { 'monday, wednesday, friday and saturday' }
|
1660
1686
|
let(:run_date) { Time.local(2014, 2, 9) }
|
1661
1687
|
|
1662
|
-
describe
|
1663
|
-
it
|
1688
|
+
describe '#occurrences' do
|
1689
|
+
it 'is the following Monday, Wednesday, Friday and Saturday' do
|
1664
1690
|
expect(n.occurrences).to match_array [
|
1665
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1666
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1667
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1668
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1691
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140210')),
|
1692
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140212')),
|
1693
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140214')),
|
1694
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140215'))
|
1669
1695
|
]
|
1670
1696
|
end
|
1671
1697
|
end
|
1672
1698
|
end
|
1673
1699
|
|
1674
1700
|
context "when the query is 'next monday, wednesday, friday and saturday'" do
|
1675
|
-
let(:query) {
|
1701
|
+
let(:query) { 'next monday, wednesday, friday and saturday' }
|
1676
1702
|
let(:run_date) { Time.local(2014, 2, 9) }
|
1677
1703
|
|
1678
|
-
describe
|
1679
|
-
it
|
1704
|
+
describe '#occurrences' do
|
1705
|
+
it 'is the next Monday, Wednesday, Friday and Saturday' do
|
1680
1706
|
expect(n.occurrences).to match_array [
|
1681
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1682
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1683
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1684
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1707
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140217')),
|
1708
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140219')),
|
1709
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140221')),
|
1710
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140222'))
|
1685
1711
|
]
|
1686
1712
|
end
|
1687
1713
|
end
|
1688
1714
|
end
|
1689
1715
|
|
1690
1716
|
context "when the query is 'october 2nd, 2009'" do
|
1691
|
-
let(:query) {
|
1717
|
+
let(:query) { 'october 2nd, 2009' }
|
1692
1718
|
let(:run_date) { Time.local(2008, 1, 1) }
|
1693
1719
|
|
1694
|
-
describe
|
1695
|
-
it
|
1720
|
+
describe '#occurrences' do
|
1721
|
+
it 'is October 2nd 2009' do
|
1696
1722
|
expect(n.occurrences).to match_array [
|
1697
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1723
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20091002'))
|
1698
1724
|
]
|
1699
1725
|
end
|
1700
1726
|
end
|
1701
1727
|
end
|
1702
1728
|
|
1703
1729
|
context "when the query is 'April 29, 5-8pm'" do
|
1704
|
-
let(:query) {
|
1730
|
+
let(:query) { 'April 29, 5-8pm' }
|
1705
1731
|
let(:run_date) { Time.local(2008, 3, 30) }
|
1706
1732
|
|
1707
|
-
describe
|
1708
|
-
it
|
1733
|
+
describe '#occurrences' do
|
1734
|
+
it 'is 5:00pm to 8:00pm on April 29th' do
|
1709
1735
|
expect(n.occurrences).to match_array [
|
1710
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1736
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20080429'), start_time: Nickel::ZTime.new('17'), end_time: Nickel::ZTime.new('20'))
|
1711
1737
|
]
|
1712
1738
|
end
|
1713
1739
|
end
|
1714
1740
|
end
|
1715
1741
|
|
1716
1742
|
context "when the query is 'the first of each month'" do
|
1717
|
-
let(:query) {
|
1743
|
+
let(:query) { 'the first of each month' }
|
1718
1744
|
let(:run_date) { Time.local(2008, 1, 1) }
|
1719
1745
|
|
1720
|
-
describe
|
1721
|
-
it
|
1746
|
+
describe '#occurrences' do
|
1747
|
+
it 'is every 1st of the month starting next month' do
|
1722
1748
|
expect(n.occurrences).to match_array [
|
1723
|
-
Nickel::Occurrence.new(type: :datemonthly, start_date: Nickel::ZDate.new(
|
1749
|
+
Nickel::Occurrence.new(type: :datemonthly, start_date: Nickel::ZDate.new('20080101'), interval: 1, date_of_month: 1)
|
1724
1750
|
]
|
1725
1751
|
end
|
1726
1752
|
end
|
1727
1753
|
end
|
1728
1754
|
|
1729
1755
|
context "when the query is 'the first of each month'" do
|
1730
|
-
let(:query) {
|
1756
|
+
let(:query) { 'the first of each month' }
|
1731
1757
|
let(:run_date) { Time.local(2009, 2, 15) }
|
1732
1758
|
|
1733
|
-
describe
|
1734
|
-
it
|
1759
|
+
describe '#occurrences' do
|
1760
|
+
it 'is every 1st of the month starting next month' do
|
1735
1761
|
expect(n.occurrences).to match_array [
|
1736
|
-
Nickel::Occurrence.new(type: :datemonthly, start_date: Nickel::ZDate.new(
|
1762
|
+
Nickel::Occurrence.new(type: :datemonthly, start_date: Nickel::ZDate.new('20090301'), interval: 1, date_of_month: 1)
|
1737
1763
|
]
|
1738
1764
|
end
|
1739
1765
|
end
|
1740
1766
|
end
|
1741
1767
|
|
1742
1768
|
context "when the query is 'every sunday'" do
|
1743
|
-
let(:query) {
|
1769
|
+
let(:query) { 'every sunday' }
|
1744
1770
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1745
1771
|
|
1746
|
-
describe
|
1747
|
-
it
|
1772
|
+
describe '#occurrences' do
|
1773
|
+
it 'is every sunday' do
|
1748
1774
|
expect(n.occurrences).to match_array [
|
1749
|
-
Nickel::Occurrence.new(type: :weekly, start_date: Nickel::ZDate.new(
|
1775
|
+
Nickel::Occurrence.new(type: :weekly, start_date: Nickel::ZDate.new('20090104'), interval: 1, day_of_week: 6)
|
1750
1776
|
]
|
1751
1777
|
end
|
1752
1778
|
end
|
1753
1779
|
end
|
1754
1780
|
|
1755
1781
|
context "when the query is 'every month on the 22nd at 2pm'" do
|
1756
|
-
let(:query) {
|
1782
|
+
let(:query) { 'every month on the 22nd at 2pm' }
|
1757
1783
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1758
1784
|
|
1759
|
-
describe
|
1760
|
-
it
|
1785
|
+
describe '#occurrences' do
|
1786
|
+
it 'is every month on the 22nd at 2:00pm' do
|
1761
1787
|
expect(n.occurrences).to match_array [
|
1762
|
-
Nickel::Occurrence.new(type: :datemonthly, start_date: Nickel::ZDate.new(
|
1788
|
+
Nickel::Occurrence.new(type: :datemonthly, start_date: Nickel::ZDate.new('20090122'), interval: 1, date_of_month: 22, start_time: Nickel::ZTime.new('14'))
|
1763
1789
|
]
|
1764
1790
|
end
|
1765
1791
|
end
|
1766
1792
|
end
|
1767
1793
|
|
1768
1794
|
context "when the query is 'every other saturday at noon'" do
|
1769
|
-
let(:query) {
|
1795
|
+
let(:query) { 'every other saturday at noon' }
|
1770
1796
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1771
1797
|
|
1772
|
-
describe
|
1773
|
-
it
|
1798
|
+
describe '#occurrences' do
|
1799
|
+
it 'is every 2nd Saturday at 12:00pm' do
|
1774
1800
|
expect(n.occurrences).to match_array [
|
1775
|
-
Nickel::Occurrence.new(type: :weekly, start_date: Nickel::ZDate.new(
|
1801
|
+
Nickel::Occurrence.new(type: :weekly, start_date: Nickel::ZDate.new('20090103'), interval: 2, day_of_week: 5, start_time: Nickel::ZTime.new('12'))
|
1776
1802
|
]
|
1777
1803
|
end
|
1778
1804
|
end
|
1779
1805
|
end
|
1780
1806
|
|
1781
1807
|
context "when the query is 'every day at midnight'" do
|
1782
|
-
let(:query) {
|
1808
|
+
let(:query) { 'every day at midnight' }
|
1783
1809
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1784
1810
|
|
1785
|
-
describe
|
1786
|
-
it
|
1811
|
+
describe '#occurrences' do
|
1812
|
+
it 'is every day at 12:00am' do
|
1787
1813
|
expect(n.occurrences).to match_array [
|
1788
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1814
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081230'), interval: 1, start_time: Nickel::ZTime.new('00'))
|
1789
1815
|
]
|
1790
1816
|
end
|
1791
1817
|
end
|
1792
1818
|
end
|
1793
1819
|
|
1794
1820
|
context "when the query is 'daily from noon to midnight'" do
|
1795
|
-
let(:query) {
|
1821
|
+
let(:query) { 'daily from noon to midnight' }
|
1796
1822
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1797
1823
|
|
1798
|
-
describe
|
1799
|
-
it
|
1824
|
+
describe '#occurrences' do
|
1825
|
+
it 'is every day from 12:00pm to 12:00am' do
|
1800
1826
|
expect(n.occurrences).to match_array [
|
1801
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1827
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081230'), interval: 1, start_time: Nickel::ZTime.new('12'), end_time: Nickel::ZTime.new('00'))
|
1802
1828
|
]
|
1803
1829
|
end
|
1804
1830
|
end
|
1805
1831
|
end
|
1806
1832
|
|
1807
1833
|
context "when the query is 'the last tuesday of every month, starts at 9am'" do
|
1808
|
-
let(:query) {
|
1834
|
+
let(:query) { 'the last tuesday of every month, starts at 9am' }
|
1809
1835
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1810
1836
|
|
1811
|
-
describe
|
1812
|
-
it
|
1837
|
+
describe '#occurrences' do
|
1838
|
+
it 'is the last Tuesday of every month at 9:00am' do
|
1813
1839
|
expect(n.occurrences).to match_array [
|
1814
|
-
Nickel::Occurrence.new(type: :daymonthly, start_date: Nickel::ZDate.new(
|
1840
|
+
Nickel::Occurrence.new(type: :daymonthly, start_date: Nickel::ZDate.new('20081230'), start_time: Nickel::ZTime.new('09'), interval: 1, week_of_month: -1, day_of_week: 1)
|
1815
1841
|
]
|
1816
1842
|
end
|
1817
1843
|
end
|
1818
1844
|
end
|
1819
1845
|
|
1820
1846
|
context "when the query is 'one week from today'" do
|
1821
|
-
let(:query) {
|
1847
|
+
let(:query) { 'one week from today' }
|
1822
1848
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1823
1849
|
|
1824
|
-
describe
|
1825
|
-
it
|
1850
|
+
describe '#occurrences' do
|
1851
|
+
it 'is one week from today' do
|
1826
1852
|
expect(n.occurrences).to match_array [
|
1827
|
-
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new(
|
1853
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20090106'))
|
1828
1854
|
]
|
1829
1855
|
end
|
1830
1856
|
end
|
1831
1857
|
end
|
1832
1858
|
|
1833
1859
|
context "when the query is 'every other day at 2:45am'" do
|
1834
|
-
let(:query) {
|
1860
|
+
let(:query) { 'every other day at 2:45am' }
|
1835
1861
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1836
1862
|
|
1837
|
-
describe
|
1838
|
-
it
|
1863
|
+
describe '#occurrences' do
|
1864
|
+
it 'is every other day at 2:45am' do
|
1839
1865
|
expect(n.occurrences).to match_array [
|
1840
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1866
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081230'), start_time: Nickel::ZTime.new('0245'), interval: 2)
|
1841
1867
|
]
|
1842
1868
|
end
|
1843
1869
|
end
|
1844
1870
|
end
|
1845
1871
|
|
1846
1872
|
context "when the query is 'every other day at 2:45am starting tomorrow'" do
|
1847
|
-
let(:query) {
|
1873
|
+
let(:query) { 'every other day at 2:45am starting tomorrow' }
|
1848
1874
|
let(:run_date) { Time.local(2008, 12, 30) }
|
1849
1875
|
|
1850
|
-
describe
|
1851
|
-
it
|
1876
|
+
describe '#occurrences' do
|
1877
|
+
it 'is every other day at 2:45am starting from tomorrow' do
|
1852
1878
|
expect(n.occurrences).to match_array [
|
1853
|
-
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new(
|
1879
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20081231'), start_time: Nickel::ZTime.new('0245'), interval: 2)
|
1854
1880
|
]
|
1855
1881
|
end
|
1856
1882
|
end
|
1883
|
+
|
1884
|
+
context "when the query is 'every third monday starting on this monday'" do
|
1885
|
+
let(:query) { 'every third monday starting on this monday' }
|
1886
|
+
let(:run_date) { Time.local(2014, 2, 14) }
|
1887
|
+
|
1888
|
+
describe '#occurrences' do
|
1889
|
+
it 'is every third monday starting from the following monday' do
|
1890
|
+
expect(n.occurrences).to match_array [
|
1891
|
+
Nickel::Occurrence.new(type: :weekly, start_date: Nickel::ZDate.new('20140217'), interval: 3, day_of_week: 0)
|
1892
|
+
]
|
1893
|
+
end
|
1894
|
+
end
|
1895
|
+
end
|
1896
|
+
|
1897
|
+
context "when the query is 'every third day starting today'" do
|
1898
|
+
let(:query) { 'every third day starting today' }
|
1899
|
+
let(:run_date) { Time.local(2014, 2, 14) }
|
1900
|
+
|
1901
|
+
describe '#occurrences' do
|
1902
|
+
it 'is every third day starting from today' do
|
1903
|
+
expect(n.occurrences).to match_array [
|
1904
|
+
Nickel::Occurrence.new(type: :daily, start_date: Nickel::ZDate.new('20140214'), interval: 3)
|
1905
|
+
]
|
1906
|
+
end
|
1907
|
+
end
|
1908
|
+
end
|
1909
|
+
|
1910
|
+
context "when the query is 'the last monday of each month for six months'" do
|
1911
|
+
let(:query) { 'the last monday of each month for six months' }
|
1912
|
+
let(:run_date) { Time.local(2014, 2, 12) }
|
1913
|
+
|
1914
|
+
describe '#occurrences' do
|
1915
|
+
it 'is the last monday of every month for the next six months' do
|
1916
|
+
expect(n.occurrences).to match_array [
|
1917
|
+
Nickel::Occurrence.new(type: :daymonthly, interval: 1, day_of_week: 0, week_of_month: -1, start_date: Nickel::ZDate.new('20140224'), end_date: Nickel::ZDate.new('20140812'))
|
1918
|
+
]
|
1919
|
+
end
|
1920
|
+
end
|
1921
|
+
end
|
1922
|
+
|
1923
|
+
context "when the query is '2 weeks from yesterday'" do
|
1924
|
+
let(:query) { '2 weeks from yesterday' }
|
1925
|
+
let(:run_date) { Time.local(2014, 2, 12) }
|
1926
|
+
|
1927
|
+
describe '#occurrences' do
|
1928
|
+
it 'is 13 days from today' do
|
1929
|
+
expect(n.occurrences).to match_array [
|
1930
|
+
Nickel::Occurrence.new(type: :single, start_date: Nickel::ZDate.new('20140225'))
|
1931
|
+
]
|
1932
|
+
end
|
1933
|
+
end
|
1934
|
+
end
|
1857
1935
|
end
|
1858
1936
|
end
|
1859
1937
|
end
|