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