multiparameter_date_time 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd4b646671a89153334e24e8e5965616725df430
4
- data.tar.gz: f2e6aef9a92bd20cb6334b53e62b23156404476d
3
+ metadata.gz: 7dbe4e334a2cdfcaffabfc6e283e801b6ec7a2c4
4
+ data.tar.gz: f1dc19849afde4d9ca07c7e8c0d11bbcb82a5ebd
5
5
  SHA512:
6
- metadata.gz: a43cc2612bc431a19085a49264dd4045c10f9b6169edbbc99a4248a95d628b067822c13333b2192d17576172aab3efe44547a26da8821f1d6116009a0c2ce092
7
- data.tar.gz: a067365b7f8aad02982b715b2aac8ffa22ec9fb491c8ba66cd694549e175fb39fcf9e1efd31771a8ee40b786e3f71f39de6422624f9322190103d40d4cc8d465
6
+ metadata.gz: 4246599e275e0200c000547dcbeffa5fa0be0731aaaba88c424311d80b63e0cbe4994cb41825cf49e0845a8393171571fe119fc3220cd7de77495bc64afafb4c
7
+ data.tar.gz: e0c95dcb0ddcfb50a5ef77b57fc108e15413720194dd191552fd8630a30cdf509605b3e997678bcb18cf9eb47dd9ab898d5c946e70c2e10b8b056ea44e074c6a
@@ -1,7 +1,8 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 1.9.2
4
- - 1.9.3
5
- - 2.0.0
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
6
7
  - jruby-19mode
7
8
  - rbx-19mode
data/README.md CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
 
22
22
  $ gem install multiparameter_date_time
23
23
 
24
- Note that Ruby 1.9.2+ is required.
24
+ Note that Ruby 2.x is required.
25
25
 
26
26
  ## Usage
27
27
 
@@ -108,4 +108,4 @@ en:
108
108
 
109
109
  ## License
110
110
 
111
- Copyright © 2012–2013 Case Commons, LLC. License is available in the LICENSE file.
111
+ Copyright © 2012–2016 Case Commons, LLC. License is available in the LICENSE file.
@@ -20,6 +20,7 @@ class IsValidMultiparameterDateTimeValidator < ActiveModel::EachValidator
20
20
  else
21
21
  attribute_value = record.public_send(:"#{attribute}_time_part")
22
22
  begin
23
+ Date.parse(date_value)
23
24
  Time.zone.parse("#{date_value} #{time_value}")
24
25
  Time.zone.parse(attribute_value)
25
26
  rescue ArgumentError
@@ -117,6 +117,7 @@ module MultiparameterDateTime
117
117
  formatted_date_string = MultiparameterDateTime.date_string_formatter.format(date_string)
118
118
  end
119
119
 
120
+ Date.parse(formatted_date_string)
120
121
  write_attribute_for_multiparameter_date_time(
121
122
  name, Time.zone.parse("#{formatted_date_string} #{time_string}")
122
123
  )
@@ -1,3 +1,3 @@
1
1
  module MultiparameterDateTime
2
- VERSION = '0.3.5'
2
+ VERSION = '0.3.6'
3
3
  end
@@ -5,7 +5,7 @@ require 'is_valid_multiparameter_date_time_validator'
5
5
 
6
6
  describe IsValidMultiparameterDateTimeValidator do
7
7
  before do
8
- Time.zone = "US/Eastern"
8
+ Time.zone = 'US/Eastern'
9
9
  end
10
10
 
11
11
  with_model :ModelWithDatetime do
@@ -20,21 +20,21 @@ describe IsValidMultiparameterDateTimeValidator do
20
20
  end
21
21
  end
22
22
 
23
- shared_examples_for "a valid time" do
24
- it "should not have an error" do
23
+ shared_examples_for 'a valid time' do
24
+ it 'does not have an error' do
25
25
  record.valid?
26
- record.errors[:foo].should be_empty
26
+ expect(record.errors[:foo]).to be_empty
27
27
  end
28
28
  end
29
29
 
30
- shared_examples_for "a badly formatted date or time" do
31
- it "should show the bad format error" do
30
+ shared_examples_for 'a badly formatted date or time' do
31
+ it 'shows the bad format error' do
32
32
  record.valid?
33
- record.errors[:foo].should == [bad_format_error]
33
+ expect(record.errors[:foo]).to eq [bad_format_error]
34
34
  end
35
35
  end
36
36
 
37
- describe "#validate_each" do
37
+ describe '#validate_each' do
38
38
  subject { record }
39
39
  let(:record) do
40
40
  ModelWithDatetime.new(
@@ -49,75 +49,75 @@ describe IsValidMultiparameterDateTimeValidator do
49
49
  let(:missing_time_error) { 'Please enter a time.' }
50
50
  let(:missing_date_error) { 'Please enter a date.' }
51
51
 
52
- context "with valid date" do
52
+ context 'with valid date' do
53
53
  let(:date_string) { '01/01/2001' }
54
54
 
55
- context "with valid time in" do
56
- context "military format" do
57
- context "lots of zeros" do
55
+ context 'with valid time in' do
56
+ context 'military format' do
57
+ context 'lots of zeros' do
58
58
  let(:time_string) { '00:00' }
59
- it_should_behave_like "a valid time"
59
+ it_should_behave_like 'a valid time'
60
60
  end
61
61
 
62
- context "last valid value" do
62
+ context 'last valid value' do
63
63
  let(:time_string) { '23:59' }
64
- it_should_behave_like "a valid time"
64
+ it_should_behave_like 'a valid time'
65
65
  end
66
66
 
67
- context "1 pm" do
67
+ context '1 pm' do
68
68
  let(:time_string) { '13:00' }
69
- it_should_behave_like "a valid time"
69
+ it_should_behave_like 'a valid time'
70
70
  end
71
71
  end
72
72
 
73
- context "standard format" do
73
+ context 'standard format' do
74
74
  let(:time_string) { '12:31pm' }
75
- it_should_behave_like "a valid time"
75
+ it_should_behave_like 'a valid time'
76
76
 
77
- context "with a capital AM or PM" do
77
+ context 'with a capital AM or PM' do
78
78
  let(:time_string) { '12:31 PM' }
79
- it_should_behave_like "a valid time"
79
+ it_should_behave_like 'a valid time'
80
80
  end
81
81
 
82
- context "without a space between the time and AM or PM" do
82
+ context 'without a space between the time and AM or PM' do
83
83
  let(:time_string) { '12:31AM' }
84
- it_should_behave_like "a valid time"
84
+ it_should_behave_like 'a valid time'
85
85
  end
86
86
 
87
- context "with no space and a mixed case aM or pM" do
87
+ context 'with no space and a mixed case aM or pM' do
88
88
  let(:time_string) { '12:31aM' }
89
- it_should_behave_like "a valid time"
89
+ it_should_behave_like 'a valid time'
90
90
  end
91
91
 
92
- context "with a space and a mixed case aM or pM" do
92
+ context 'with a space and a mixed case aM or pM' do
93
93
  let(:time_string) { '12:31 aM' }
94
- it_should_behave_like "a valid time"
94
+ it_should_behave_like 'a valid time'
95
95
  end
96
96
 
97
- context "with a space and a lower case am or pm" do
97
+ context 'with a space and a lower case am or pm' do
98
98
  let(:time_string) { '12:31 am' }
99
- it_should_behave_like "a valid time"
99
+ it_should_behave_like 'a valid time'
100
100
  end
101
101
  end
102
102
  end
103
103
 
104
- context "with invalid time in" do
105
- context "military format" do
106
- context "above 23:59" do
104
+ context 'with invalid time in' do
105
+ context 'military format' do
106
+ context 'above 23:59' do
107
107
  let(:time_string) { '25:00' }
108
- it_should_behave_like "a badly formatted date or time"
108
+ it_should_behave_like 'a badly formatted date or time'
109
109
  end
110
110
 
111
- context "with am or pm" do
111
+ context 'with am or pm' do
112
112
  let(:time_string) { '23:00 am' }
113
- it_should_behave_like "a badly formatted date or time"
113
+ it_should_behave_like 'a badly formatted date or time'
114
114
  end
115
115
  end
116
116
 
117
- context "standard format" do
117
+ context 'standard format' do
118
118
  let(:time_string) { '90:00pm' }
119
119
 
120
- it_should_behave_like "a badly formatted date or time"
120
+ it_should_behave_like 'a badly formatted date or time'
121
121
  end
122
122
  end
123
123
 
@@ -158,56 +158,56 @@ describe IsValidMultiparameterDateTimeValidator do
158
158
  end
159
159
  end
160
160
 
161
- context "with invalid date" do
161
+ context 'with invalid date' do
162
162
  let(:date_string) { 'asdf' }
163
163
 
164
- context "with valid time" do
164
+ context 'with valid time' do
165
165
  let(:time_string) { '12:31pm' }
166
166
 
167
- it_should_behave_like "a badly formatted date or time"
167
+ it_should_behave_like 'a badly formatted date or time'
168
168
  end
169
169
 
170
- context "with invalid time" do
170
+ context 'with invalid time' do
171
171
  let(:time_string) { 'asdf' }
172
172
 
173
- it_should_behave_like "a badly formatted date or time"
173
+ it_should_behave_like 'a badly formatted date or time'
174
174
  end
175
175
 
176
176
  [' ', nil].each do |time_value|
177
177
  context "with time = #{time_value.inspect}" do
178
178
  let(:time_string) { time_value }
179
- it_should_behave_like "a badly formatted date or time"
179
+ it_should_behave_like 'a badly formatted date or time'
180
180
  end
181
181
  end
182
182
  end
183
183
 
184
- context "with a date that has invalid format" do
185
- context "with year has 5 digits" do
184
+ context 'with a date that has invalid format' do
185
+ context 'with year has 5 digits' do
186
186
  let(:date_string) { '1/1/12012' }
187
187
  let(:time_string) { '12:31pm' }
188
188
 
189
- it_should_behave_like "a badly formatted date or time"
189
+ it_should_behave_like 'a badly formatted date or time'
190
190
  end
191
191
 
192
- context "with year has 1 digit" do
192
+ context 'with year has 1 digit' do
193
193
  let(:date_string) { '1/1/2' }
194
194
  let(:time_string) { '12:31pm' }
195
195
 
196
- it_should_behave_like "a badly formatted date or time"
196
+ it_should_behave_like 'a badly formatted date or time'
197
197
  end
198
198
 
199
- context "with month has 3 digits" do
199
+ context 'with month has 3 digits' do
200
200
  let(:date_string) { '100/1/2012' }
201
201
  let(:time_string) { '12:31pm' }
202
202
 
203
- it_should_behave_like "a badly formatted date or time"
203
+ it_should_behave_like 'a badly formatted date or time'
204
204
  end
205
205
 
206
- context "with day has 3 digits" do
206
+ context 'with day has 3 digits' do
207
207
  let(:date_string) { '10/100/2012' }
208
208
  let(:time_string) { '12:31pm' }
209
209
 
210
- it_should_behave_like "a badly formatted date or time"
210
+ it_should_behave_like 'a badly formatted date or time'
211
211
  end
212
212
  end
213
213
 
@@ -215,19 +215,19 @@ describe IsValidMultiparameterDateTimeValidator do
215
215
  context "with date = #{date_value.inspect}" do
216
216
  let(:date_string) { date_value }
217
217
 
218
- context "with valid time" do
218
+ context 'with valid time' do
219
219
  let(:time_string) { '12:31pm' }
220
220
 
221
- it "should show the missing date error" do
221
+ it 'should show the missing date error' do
222
222
  record.valid?
223
- record.errors[:foo].should == [missing_date_error]
223
+ expect(record.errors[:foo]).to eq [missing_date_error]
224
224
  end
225
225
  end
226
226
 
227
- context "with invalid time" do
227
+ context 'with invalid time' do
228
228
  let(:time_string) { 'asdf' }
229
229
 
230
- it_should_behave_like "a badly formatted date or time"
230
+ it_should_behave_like 'a badly formatted date or time'
231
231
  end
232
232
 
233
233
  [' ', nil].each do |time_value|
@@ -235,7 +235,7 @@ describe IsValidMultiparameterDateTimeValidator do
235
235
  let(:time_string) { time_value }
236
236
  it 'should not have an error' do
237
237
  record.valid?
238
- record.errors[:foo].should be_empty
238
+ expect(record.errors[:foo]).to be_empty
239
239
  end
240
240
  end
241
241
  end
@@ -243,7 +243,7 @@ describe IsValidMultiparameterDateTimeValidator do
243
243
  end
244
244
 
245
245
  [' ', nil].each do |date_value|
246
- context "with valid time" do
246
+ context 'with valid time' do
247
247
  let(:date_string) { date_value }
248
248
  let(:time_string) { '12:31pm' }
249
249
 
@@ -260,86 +260,104 @@ describe IsValidMultiparameterDateTimeValidator do
260
260
  end
261
261
 
262
262
  context 'and I18n error messages' do
263
- it "should show the missing date error" do
263
+ it 'should show the missing date error' do
264
264
  record.valid?
265
- record.errors[:foo].should == ['custom error']
265
+ expect(record.errors[:foo]).to eq ['custom error']
266
266
  end
267
267
  end
268
268
  end
269
269
  end
270
270
 
271
- context "when the datetime is set directly" do
271
+ context 'when the datetime is set directly' do
272
272
  let(:record) { ModelWithDatetime.new(foo: Time.current) }
273
- it "should not have an error" do
273
+ it 'should not have an error' do
274
274
  record.valid?
275
- record.errors[:foo].should be_empty
275
+ expect(record.errors[:foo]).to be_empty
276
276
  end
277
277
  end
278
278
 
279
- context "when the datetime is set directly to nil" do
279
+ context 'when the datetime is set directly to nil' do
280
280
  let(:record) { ModelWithDatetime.new(foo: nil) }
281
- it "should not have an error" do
281
+ it 'should not have an error' do
282
282
  record.valid?
283
- record.errors[:foo].should be_empty
283
+ expect(record.errors[:foo]).to be_empty
284
284
  end
285
285
  end
286
286
 
287
- context "when nothing is set at all" do
287
+ context 'when nothing is set at all' do
288
288
  let(:record) { ModelWithDatetime.new }
289
- it "should not have an error" do
289
+ it 'should not have an error' do
290
290
  record.valid?
291
- record.errors[:foo].should be_empty
291
+ expect(record.errors[:foo]).to be_empty
292
292
  end
293
293
  end
294
294
 
295
- context "with an impossible date" do
296
- context "set in parts" do
295
+ context 'with an impossible date' do
296
+ context 'set in parts' do
297
297
  let(:record) do
298
298
  ModelWithDatetime.new(foo_date_part: '19/19/1919', foo_time_part: '04:50pm')
299
299
  end
300
300
 
301
- it_should_behave_like "a badly formatted date or time"
301
+ it_should_behave_like 'a badly formatted date or time'
302
302
  end
303
303
 
304
- context "set directly" do
304
+ context 'set directly' do
305
305
  let(:record) do
306
306
  ModelWithDatetime.new(foo: '19/19/1919 04:50pm')
307
307
  end
308
308
 
309
- it_should_behave_like "a badly formatted date or time"
309
+ it_should_behave_like 'a badly formatted date or time'
310
+ end
311
+
312
+ context 'having a valid month but invalid day for that month' do
313
+ context 'set in parts' do
314
+ let(:record) do
315
+ ModelWithDatetime.new(foo_date_part: '2/31/2015', foo_time_part: '04:50pm')
316
+ end
317
+
318
+ it_should_behave_like 'a badly formatted date or time'
319
+ end
320
+
321
+ context 'set directly' do
322
+ let(:record) do
323
+ ModelWithDatetime.new(foo: '2/31/2015 04:50pm')
324
+ end
325
+
326
+ it_should_behave_like 'a badly formatted date or time'
327
+ end
310
328
  end
311
329
  end
312
330
 
313
- context "with an impossible time" do
314
- context "set in parts" do
331
+ context 'with an impossible time' do
332
+ context 'set in parts' do
315
333
  let(:record) do
316
334
  ModelWithDatetime.new(foo_date_part: '01/01/2001', foo_time_part: '09:99pm')
317
335
  end
318
336
 
319
- it_should_behave_like "a badly formatted date or time"
337
+ it_should_behave_like 'a badly formatted date or time'
320
338
  end
321
339
 
322
- context "set directly" do
340
+ context 'set directly' do
323
341
  let(:record) do
324
342
  ModelWithDatetime.new(foo: '01/01/2001 09:99pm')
325
343
  end
326
344
 
327
- it_should_behave_like "a badly formatted date or time"
345
+ it_should_behave_like 'a badly formatted date or time'
328
346
  end
329
347
  end
330
348
 
331
- context "when the display format has been configured" do
349
+ context 'when the display format has been configured' do
332
350
  let(:date_string) { 'asdf' }
333
351
  let(:time_string) { 'foo' }
334
352
 
335
- context "when the date format is set" do
353
+ context 'when the date format is set' do
336
354
  before do
337
355
  MultiparameterDateTime.date_format = '%-m-%-e-%0y'
338
356
  end
339
357
 
340
- it "should show the bad format error" do
358
+ it 'shows the bad format error' do
341
359
  record.valid?
342
- record.errors[:foo].should == [
360
+ expect(record.errors[:foo]).to eq [
343
361
  'Please enter a valid date and time using the following formats: 1-29-00, 5:15 pm'
344
362
  ]
345
363
  end
@@ -349,16 +367,16 @@ describe IsValidMultiparameterDateTimeValidator do
349
367
  end
350
368
  end
351
369
 
352
- context "when the time format is set" do
370
+ context 'when the time format is set' do
353
371
  let(:time_string) { 'asdf' }
354
372
 
355
373
  before do
356
374
  MultiparameterDateTime.time_format = '%H%M hours'
357
375
  end
358
376
 
359
- it "should show the bad format error" do
377
+ it 'shows the bad format error' do
360
378
  record.valid?
361
- record.errors[:foo].should == [
379
+ expect(record.errors[:foo]).to eq [
362
380
  'Please enter a valid date and time using the following formats: 1/29/2000, 1715 hours'
363
381
  ]
364
382
  end
@@ -370,7 +388,7 @@ describe IsValidMultiparameterDateTimeValidator do
370
388
  end
371
389
  end
372
390
 
373
- describe "accepts dates in a variety of formats" do
391
+ describe 'accepts dates in a variety of formats' do
374
392
  ['2010-1-1', '02-01-1971', '4/4/92', '01/02/2001', '01/02/2001', '01.02.2011'].each do |format|
375
393
  context format do
376
394
  let(:date_string) { format }
@@ -379,14 +397,14 @@ describe IsValidMultiparameterDateTimeValidator do
379
397
  ModelWithDatetime.new(foo_date_part: date_string, foo_time_part: time_string)
380
398
  end
381
399
 
382
- it "should be accepted" do
383
- record.should be_valid
400
+ it 'is accepted' do
401
+ expect(record).to be_valid
384
402
  end
385
403
  end
386
404
  end
387
405
  end
388
406
 
389
- describe ".invalid_format_error_message" do
407
+ describe '.invalid_format_error_message' do
390
408
  it do
391
409
  expected_error = 'Please enter a valid date and time using the following formats: 1/29/2000, 5:15 pm'
392
410
  expect(described_class.invalid_format_error_message).to eq expected_error
@@ -40,7 +40,7 @@ describe MultiparameterDateTime do
40
40
 
41
41
  subject { record }
42
42
 
43
- describe "when a value is present" do
43
+ describe 'when a value is present' do
44
44
  let(:record) { model.new(foo: Time.zone.parse('1/2/2003 04:05pm')) }
45
45
  it 'assigns date_part' do
46
46
  expect(subject.foo_date_part).to eq '1/2/2003'
@@ -51,304 +51,325 @@ describe MultiparameterDateTime do
51
51
  end
52
52
  end
53
53
 
54
- describe "setting a valid date and time" do
54
+ describe 'setting a valid date and time' do
55
55
  let(:foo_date_part) { '01/02/2000' }
56
56
  let(:foo_time_part) { '9:30 pm EST' }
57
57
 
58
- it "doesn't raise an exception" do
58
+ it 'does not raise an exception' do
59
59
  expect { subject }.not_to raise_exception
60
60
  end
61
61
 
62
- it "sets the attribute to a DateTime object" do
63
- subject.foo.should == Time.zone.parse('1/2/2000 9:30 pm')
62
+ it 'sets the attribute to a DateTime object' do
63
+ expect(subject.foo).to eq Time.zone.parse('1/2/2000 9:30 pm')
64
64
  end
65
65
 
66
- it "has the original date input" do
67
- subject.foo_date_part.should == '01/02/2000'
66
+ it 'has the original date input' do
67
+ expect(subject.foo_date_part).to eq '01/02/2000'
68
68
  end
69
69
 
70
- it "has the original time input" do
71
- subject.foo_time_part.should == '9:30 pm EST'
70
+ it 'has the original time input' do
71
+ expect(subject.foo_time_part).to eq '9:30 pm EST'
72
72
  end
73
73
  end
74
74
 
75
- describe "setting an invalid date" do
75
+ describe 'setting an invalid date' do
76
76
  let(:foo_date_part) { 'bad input' }
77
77
  let(:foo_time_part) { '9:30 pm' }
78
78
 
79
- it "doesn't raise an exception" do
79
+ it 'does not raise an exception' do
80
80
  expect { subject }.not_to raise_exception
81
81
  end
82
82
 
83
- it "sets the attribute to :incomplete" do
84
- subject.foo.should == :incomplete
83
+ it 'sets the attribute to :incomplete' do
84
+ expect(subject.foo).to eq :incomplete
85
85
  end
86
86
 
87
- it "has the original date" do
88
- subject.foo_date_part.should == 'bad input'
87
+ it 'has the original date' do
88
+ expect(subject.foo_date_part).to eq 'bad input'
89
89
  end
90
90
 
91
- it "has the original time input" do
92
- subject.foo_time_part.should == '9:30 pm'
91
+ it 'has the original time input' do
92
+ expect(subject.foo_time_part).to eq '9:30 pm'
93
+ end
94
+
95
+ context 'valid month but invalid day for the month' do
96
+ let(:foo_date_part) { '2/31/2015' }
97
+ let(:foo_time_part) { '9:30 pm' }
98
+
99
+ it 'does not raise an exception' do
100
+ expect { subject }.not_to raise_exception
101
+ end
102
+
103
+ it 'sets the attribute to :incomplete' do
104
+ expect(subject.foo).to eq :incomplete
105
+ end
106
+
107
+ it 'has the original date' do
108
+ expect(subject.foo_date_part).to eq '2/31/2015'
109
+ end
110
+
111
+ it 'has the original time input' do
112
+ expect(subject.foo_time_part).to eq '9:30 pm'
113
+ end
93
114
  end
94
115
  end
95
116
 
96
- describe "setting a impossible date" do
117
+ describe 'setting an impossible date' do
97
118
  let(:foo_date_part) { '99/99/9999' }
98
119
  let(:foo_time_part) { '12:30 pm' }
99
120
 
100
- it "doesn't raise an exception" do
121
+ it 'does not raise an exception' do
101
122
  expect { subject }.not_to raise_exception
102
123
  end
103
124
 
104
- it "sets the attribute to :incomplete" do
105
- subject.foo.should == :incomplete
125
+ it 'sets the attribute to :incomplete' do
126
+ expect(subject.foo).to eq :incomplete
106
127
  end
107
128
 
108
- it "has the original date" do
109
- subject.foo_date_part.should == '99/99/9999'
129
+ it 'has the original date' do
130
+ expect(subject.foo_date_part).to eq '99/99/9999'
110
131
  end
111
132
 
112
- it "has the original time" do
113
- subject.foo_time_part.should == '12:30 pm'
133
+ it 'has the original time' do
134
+ expect(subject.foo_time_part).to eq '12:30 pm'
114
135
  end
115
136
  end
116
137
 
117
- describe "setting an invalid time" do
138
+ describe 'setting an invalid time' do
118
139
  let(:foo_date_part) { '01/02/2000' }
119
140
  let(:foo_time_part) { 'bad input' }
120
141
 
121
- it "doesn't raise an exception" do
142
+ it 'does not raise an exception' do
122
143
  expect { subject }.not_to raise_exception
123
144
  end
124
145
 
125
- it "sets the attribute to :incomplete" do
126
- subject.foo.should == :incomplete
146
+ it 'sets the attribute to :incomplete' do
147
+ expect(subject.foo).to eq :incomplete
127
148
  end
128
149
 
129
- it "has the original date input" do
130
- subject.foo_date_part.should == '01/02/2000'
150
+ it 'has the original date input' do
151
+ expect(subject.foo_date_part).to eq '01/02/2000'
131
152
  end
132
153
 
133
- it "has the original time input" do
134
- subject.foo_time_part.should == "bad input"
154
+ it 'has the original time input' do
155
+ expect(subject.foo_time_part).to eq 'bad input'
135
156
  end
136
157
  end
137
158
 
138
- describe "setting a impossible time" do
159
+ describe 'setting a impossible time' do
139
160
  let(:foo_date_part) { '01/02/2000' }
140
161
  let(:foo_time_part) { '99:99pm' }
141
162
 
142
- it "doesn't raise an exception" do
163
+ it 'does not raise an exception' do
143
164
  expect { subject }.not_to raise_exception
144
165
  end
145
166
 
146
- it "sets the attribute to :incomplete" do
147
- subject.foo.should == :incomplete
167
+ it 'sets the attribute to :incomplete' do
168
+ expect(subject.foo).to eq :incomplete
148
169
  end
149
170
 
150
- it "has the original date input" do
151
- subject.foo_date_part.should == '01/02/2000'
171
+ it 'has the original date input' do
172
+ expect(subject.foo_date_part).to eq '01/02/2000'
152
173
  end
153
174
 
154
- it "has the original time input" do
155
- subject.foo_time_part.should == '99:99pm'
175
+ it 'has the original time input' do
176
+ expect(subject.foo_time_part).to eq '99:99pm'
156
177
  end
157
178
  end
158
179
 
159
- describe "setting a date but not a time" do
180
+ describe 'setting a date but not a time' do
160
181
  let(:record) { model.new(foo_date_part: '01/01/2000') }
161
182
 
162
- it "doesn't raise an exception" do
183
+ it 'does not raise an exception' do
163
184
  expect { subject }.not_to raise_exception
164
185
  end
165
186
 
166
- it "sets the attribute to :incomplete" do
167
- subject.foo.should == :incomplete
187
+ it 'sets the attribute to :incomplete' do
188
+ expect(subject.foo).to eq :incomplete
168
189
  end
169
190
 
170
- it "has the original date" do
171
- subject.foo_date_part.should == '01/01/2000'
191
+ it 'has the original date' do
192
+ expect(subject.foo_date_part).to eq '01/01/2000'
172
193
  end
173
194
 
174
- it "has the nil for the time input" do
175
- subject.foo_time_part.should == nil
195
+ it 'has the nil for the time input' do
196
+ expect(subject.foo_time_part).to eq nil
176
197
  end
177
198
  end
178
199
 
179
- describe "setting a time but not a date" do
200
+ describe 'setting a time but not a date' do
180
201
  let(:record) { model.new(foo_time_part: '12:30 pm') }
181
202
 
182
- it "doesn't raise an exception" do
203
+ it 'does not raise an exception' do
183
204
  expect { subject }.not_to raise_exception
184
205
  end
185
206
 
186
- it "sets the attribute to :incomplete" do
187
- subject.foo.should == :incomplete
207
+ it 'sets the attribute to :incomplete' do
208
+ expect(subject.foo).to eq :incomplete
188
209
  end
189
210
 
190
- it "has the nil for the date input" do
191
- subject.foo_date_part.should == nil
211
+ it 'has the nil for the date input' do
212
+ expect(subject.foo_date_part).to eq nil
192
213
  end
193
214
 
194
- it "has the original time" do
195
- subject.foo_time_part.should == '12:30 pm'
215
+ it 'has the original time' do
216
+ expect(subject.foo_time_part).to eq '12:30 pm'
196
217
  end
197
218
  end
198
219
 
199
- describe "setting incorrect time and date" do
220
+ describe 'setting incorrect time and date' do
200
221
  let(:record) { model.new(foo_time_part: 'qwer',
201
222
  foo_date_part: 'asdf') }
202
223
 
203
- it "doesn't raise an exception" do
224
+ it 'does not raise an exception' do
204
225
  expect { subject }.not_to raise_exception
205
226
  end
206
227
 
207
- it "sets the attribute to :incomplete" do
208
- subject.foo.should == :incomplete
228
+ it 'sets the attribute to :incomplete' do
229
+ expect(subject.foo).to eq :incomplete
209
230
  end
210
231
 
211
- it "has the original date" do
212
- subject.foo_date_part.should == 'asdf'
232
+ it 'has the original date' do
233
+ expect(subject.foo_date_part).to eq 'asdf'
213
234
  end
214
235
 
215
- it "has the original time input" do
216
- subject.foo_time_part.should == 'qwer'
236
+ it 'has the original time input' do
237
+ expect(subject.foo_time_part).to eq 'qwer'
217
238
  end
218
239
  end
219
240
 
220
- describe "setting neither time nor a date" do
241
+ describe 'setting neither time nor a date' do
221
242
  let(:record) { model.new(foo_time_part: '',
222
243
  foo_date_part: '') }
223
244
 
224
- it "doesn't raise an exception" do
245
+ it 'does not raise an exception' do
225
246
  expect { subject }.not_to raise_exception
226
247
  end
227
248
 
228
- it "has nil for the attribute" do
229
- subject.foo.should == nil
249
+ it 'has nil for the attribute' do
250
+ expect(subject.foo).to eq nil
230
251
  end
231
252
 
232
- it "has the original date" do
233
- subject.foo_date_part.should == ''
253
+ it 'has the original date' do
254
+ expect(subject.foo_date_part).to eq ''
234
255
  end
235
256
 
236
- it "has the original time input" do
237
- subject.foo_time_part.should == ''
257
+ it 'has the original time input' do
258
+ expect(subject.foo_time_part).to eq ''
238
259
  end
239
260
  end
240
261
 
241
- describe "setting a DateTime directly" do
262
+ describe 'setting a DateTime directly' do
242
263
  let(:record) { model.new(foo: Time.zone.parse("#{foo_date_part} #{foo_time_part}")) }
243
264
  let(:foo_date_part) { '01/02/2000' }
244
265
  let(:foo_time_part) { '12:30 pm' }
245
266
 
246
- it "doesn't raise an exception" do
267
+ it 'does not raise an exception' do
247
268
  expect { subject }.not_to raise_exception
248
269
  end
249
270
 
250
- it "sets the attribute to a DateTime object" do
251
- subject.foo.should == Time.zone.parse('01/02/2000 12:30 pm')
271
+ it 'sets the attribute to a DateTime object' do
272
+ expect(subject.foo).to eq Time.zone.parse('01/02/2000 12:30 pm')
252
273
  end
253
274
 
254
- it "has the original date" do
255
- subject.foo_date_part.should == '1/2/2000'
275
+ it 'has the original date' do
276
+ expect(subject.foo_date_part).to eq '1/2/2000'
256
277
  end
257
278
 
258
- it "has the original time input" do
259
- subject.foo_time_part.should == '12:30 pm'
279
+ it 'has the original time input' do
280
+ expect(subject.foo_time_part).to eq '12:30 pm'
260
281
  end
261
282
  end
262
283
 
263
- describe "setting a String directly" do
264
- context "When the string contains a date and time" do
284
+ describe 'setting a String directly' do
285
+ context 'When the string contains a date and time' do
265
286
  let(:record) { model.new(foo: "#{foo_date_part} #{foo_time_part}") }
266
287
  let(:foo_date_part) { '01/01/2000' }
267
288
  let(:foo_time_part) { '12:30 pm' }
268
289
 
269
- it "doesn't raise an exception" do
290
+ it 'does not raise an exception' do
270
291
  expect { subject }.not_to raise_exception
271
292
  end
272
293
 
273
- it "sets the attribute to a DateTime object" do
274
- subject.foo.should == Time.zone.parse('01/01/2000 12:30pm')
294
+ it 'sets the attribute to a DateTime object' do
295
+ expect(subject.foo).to eq Time.zone.parse('01/01/2000 12:30pm')
275
296
  end
276
297
 
277
- it "has the original date" do
278
- subject.foo_date_part.should == '01/01/2000'
298
+ it 'has the original date' do
299
+ expect(subject.foo_date_part).to eq '01/01/2000'
279
300
  end
280
301
 
281
- it "has the original time" do
282
- subject.foo_time_part.should == '12:30 pm'
302
+ it 'has the original time' do
303
+ expect(subject.foo_time_part).to eq '12:30 pm'
283
304
  end
284
305
  end
285
306
 
286
- context "When the string contains an iso8601 datetime" do
307
+ context 'When the string contains an iso8601 datetime' do
287
308
  let(:record) { model.new(foo: '2011-12-03T01:00:00Z') }
288
309
 
289
- it "doesn't raise an exception" do
310
+ it 'does not raise an exception' do
290
311
  expect { subject }.not_to raise_exception
291
312
  end
292
313
 
293
- it "sets the attribute to a DateTime object with the correct EST time" do
294
- subject.foo.should == Time.zone.parse('12/2/2011 8:00 pm')
314
+ it 'sets the attribute to a DateTime object with the correct EST time' do
315
+ expect(subject.foo).to eq Time.zone.parse('12/2/2011 8:00 pm')
295
316
  end
296
317
 
297
- it "has a date" do
298
- subject.foo_date_part.should == '12/2/2011'
318
+ it 'has a date' do
319
+ expect(subject.foo_date_part).to eq '12/2/2011'
299
320
  end
300
321
 
301
- it "has a time" do
302
- subject.foo_time_part.should == '8:00 pm'
322
+ it 'has a time' do
323
+ expect(subject.foo_time_part).to eq '8:00 pm'
303
324
  end
304
325
  end
305
326
 
306
- context "When the string contains only a date" do
327
+ context 'When the string contains only a date' do
307
328
  let(:record) { model.new(foo: "#{foo_date_part}") }
308
329
  let(:foo_date_part) { '01/01/2000' }
309
330
 
310
- it "doesn't raise an exception" do
331
+ it 'does not raise an exception' do
311
332
  expect { subject }.not_to raise_exception
312
333
  end
313
334
 
314
- it "sets the attribute to a DateTime object" do
315
- subject.foo.should == Time.zone.parse('01/01/2000 12:00am')
335
+ it 'sets the attribute to a DateTime object' do
336
+ expect(subject.foo).to eq Time.zone.parse('01/01/2000 12:00am')
316
337
  end
317
338
 
318
- it "has the original date" do
319
- subject.foo_date_part.should == '1/1/2000'
339
+ it 'has the original date' do
340
+ expect(subject.foo_date_part).to eq '1/1/2000'
320
341
  end
321
342
 
322
- it "has midnight for the time input" do
323
- subject.foo_time_part.should == '12:00 am'
343
+ it 'has midnight for the time input' do
344
+ expect(subject.foo_time_part).to eq '12:00 am'
324
345
  end
325
346
  end
326
347
  end
327
348
 
328
- describe "setting a Date directly" do
349
+ describe 'setting a Date directly' do
329
350
  let(:record) { model.new(foo: Date.parse(foo_date_part)) }
330
351
 
331
352
  let(:foo_date_part) { '01/01/2000' }
332
353
 
333
- it "doesn't raise an exception" do
354
+ it 'does not raise an exception' do
334
355
  expect { subject }.not_to raise_exception
335
356
  end
336
357
 
337
- it "sets the attribute to a DateTime object in the current time zone" do
338
- subject.foo.should == Time.zone.parse('01/01/2000 12:00 am')
358
+ it 'sets the attribute to a DateTime object in the current time zone' do
359
+ expect(subject.foo).to eq Time.zone.parse('01/01/2000 12:00 am')
339
360
  end
340
361
 
341
- it "has the original date" do
342
- subject.foo_date_part.should == '1/1/2000'
362
+ it 'has the original date' do
363
+ expect(subject.foo_date_part).to eq '1/1/2000'
343
364
  end
344
365
 
345
- it "has midnight for the time input" do
346
- subject.foo_time_part.should == '12:00 am'
366
+ it 'has midnight for the time input' do
367
+ expect(subject.foo_time_part).to eq '12:00 am'
347
368
  end
348
369
  end
349
370
 
350
- describe "setting to nil" do
351
- it "is nil" do
371
+ describe 'setting to nil' do
372
+ it 'is nil' do
352
373
  record = ModelWithDateTime.new
353
374
  record.foo = Time.current
354
375
  record.foo = nil
@@ -356,20 +377,20 @@ describe MultiparameterDateTime do
356
377
  end
357
378
  end
358
379
 
359
- describe "configuring the datetime format" do
380
+ describe 'configuring the datetime format' do
360
381
  let(:record) { model.new(foo: Time.zone.parse('01/09/2000 1:30 pm')) }
361
382
 
362
- context "when the date format is set" do
383
+ context 'when the date format is set' do
363
384
  before do
364
385
  MultiparameterDateTime.date_format = '%-m-%-e-%0y'
365
386
  end
366
387
 
367
- it "should format the date properly" do
368
- subject.foo_date_part.should == '1-9-00'
388
+ it 'formats the date properly' do
389
+ expect(subject.foo_date_part).to eq '1-9-00'
369
390
  end
370
391
 
371
- it "should use the default format for the time" do
372
- subject.foo_time_part.should == '1:30 pm'
392
+ it 'uses the default format for the time' do
393
+ expect(subject.foo_time_part).to eq '1:30 pm'
373
394
  end
374
395
 
375
396
  after do
@@ -377,17 +398,17 @@ describe MultiparameterDateTime do
377
398
  end
378
399
  end
379
400
 
380
- context "when the time format is set" do
401
+ context 'when the time format is set' do
381
402
  before do
382
403
  MultiparameterDateTime.time_format = '%H%M hours'
383
404
  end
384
405
 
385
- it "should format the time properly" do
386
- subject.foo_time_part.should == '1330 hours'
406
+ it 'formats the time properly' do
407
+ expect(subject.foo_time_part).to eq '1330 hours'
387
408
  end
388
409
 
389
- it "should use the default format for the date" do
390
- subject.foo_date_part.should == '1/9/2000'
410
+ it 'uses the default format for the date' do
411
+ expect(subject.foo_date_part).to eq '1/9/2000'
391
412
  end
392
413
 
393
414
  after do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiparameter_date_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Case Commons, LLC
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-06-23 00:00:00.000000000 Z
14
+ date: 2016-01-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: american_date
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.4.5
129
+ rubygems_version: 2.2.2
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Set a DateTime via two accessors, one for the date, one for the time
@@ -134,3 +134,4 @@ test_files:
134
134
  - spec/is_valid_multiparameter_date_time_validator_spec.rb
135
135
  - spec/multiparameter_date_time_spec.rb
136
136
  - spec/spec_helper.rb
137
+ has_rdoc: