datetime_helper 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTVhN2M1ZWU0MGQ3OGM1ZDlmNzBlZGFjOTNkOWI1NzU0MmUwMzE1Ng==
4
+ MmU2ZDI0YzgzNGJjMDQ0MjYzMDAwNzU4ZTU5ZDhiZWM4YzkzMTk5Nw==
5
5
  data.tar.gz: !binary |-
6
- NmVjMjkyNTJhNzFlYzNiNDcwYWFjZWQxN2VjZWI5ZjRkMjUzMmEzMA==
6
+ MTg1ZTNiZGQxYjdhM2RmMDg2YWI4MmNlZmE0NTU3ZjZhZGJjYmE2MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWY5ZmJhODIwZDg3ZTAyMzQwYWE0MTI1MmY2Zjg0YTY3MGM5NzA0NGViMWQ0
10
- MGUyMmI4ODg1NzVlNDcwNjBiZGNmMjYyNDVkODAwMzk2NTgwY2I5ODcyNDQ0
11
- NGFjNjIxOTEzN2RkYTExMDljZTIxY2E1NmZlNGIzNzY5MWQ4OTY=
9
+ YzRhN2RmY2I2MTgwYTY3YzJjMTc5NWIyNzgxMDhjOTA0MDk5NjBlYThmYjBh
10
+ NGY2ODg1ZWJiZTAwNzY5MTllN2FmOGY1ZGYzYTA3ZDAyOTE2ZTc2YWQ1ZTc2
11
+ OTBhMGY0ODFmOTZkZDc1YWEyNWRlMTBjZDhmOTUxZjRkMDgyYjM=
12
12
  data.tar.gz: !binary |-
13
- ODE5MmVkMWJjNzA5ZmE0MzU2MDRkOWIxZjRiNWVjOGE4NzY1MjY0N2YwMDVh
14
- MDVhY2I1NjViYzY5NDhkM2ExMGIyYzVmZTM5ODg4ZjA5M2RlNDRiZDkwYzJl
15
- MzM0M2UwNWY1MTk0ODU3NWE2YWE1ODcyNzkxOTFlYzkwMjM2ODY=
13
+ NGQ3Mzg4NGNlNDgyZWJjYzljMGE4M2Q0MmY1YTBlZGZmNDhiYmZlMGRlNTk3
14
+ NDUxYTAxMTUyNWRmYzMxNmNmODA0YTJjMzY0NmI5MDFjZTc4NDY2NzIzODE4
15
+ ZmE2YjAzYWFjZjVjZTE2MDAyYjI2YWZkZWI5NmRiNDFiZWRiYjg=
@@ -1,15 +1,15 @@
1
1
  module DatetimeHelper
2
2
  module Matchers
3
-
3
+
4
4
  RSpec::Matchers.define :be_an_iso_formatted_time do |expected|
5
5
  match do |time|
6
- !(time =~ /\d{2}:\d{2}/).nil?
6
+ !(time =~ /\A\d{2}:\d{2}\z/).nil?
7
7
  end
8
8
  end
9
9
 
10
10
  RSpec::Matchers.define :be_an_iso_formatted_date do |expected|
11
11
  match do |date|
12
- !(date =~ /\d{4}\-\d{2}\-\d{2}/).nil?
12
+ !(date =~ /\A\d{4}\-\d{2}\-\d{2}\z/).nil?
13
13
  end
14
14
  end
15
15
 
@@ -1,3 +1,3 @@
1
1
  module DatetimeHelper
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -11,17 +11,27 @@ describe 'iso_formatted' do
11
11
  let(:invalid_time_string) { "This is not a time string" }
12
12
  it { expect(invalid_time_string).to_not be_an_iso_formatted_time }
13
13
  end
14
+
15
+ context 'given a valid time embedded in a string' do
16
+ let(:embedded_time_string) { Time.now.iso8601 }
17
+ it { expect(embedded_time_string).to_not be_an_iso_formatted_time }
18
+ end
14
19
  end
15
20
 
16
21
  describe 'be_an_iso_formatted_date' do
17
22
  context 'given a valid date string' do
18
- let(:valid_time_string) { "2015-11-30" }
19
- it { expect(valid_time_string).to be_an_iso_formatted_date }
23
+ let(:valid_date_string) { "2015-11-30" }
24
+ it { expect(valid_date_string).to be_an_iso_formatted_date }
20
25
  end
21
26
 
22
27
  context 'given an invalid date string' do
23
- let(:invalid_time_string) { "This is not a date string" }
24
- it { expect(invalid_time_string).to_not be_an_iso_formatted_date }
28
+ let(:invalid_date_string) { "This is not a date string" }
29
+ it { expect(invalid_date_string).to_not be_an_iso_formatted_date }
30
+ end
31
+
32
+ context 'given an valid date embedded in a string' do
33
+ let(:embedded_date_string) { Time.now.iso8601 }
34
+ it { expect(embedded_date_string).to_not be_an_iso_formatted_date }
25
35
  end
26
36
  end
27
37
  end
@@ -3,20 +3,20 @@ require "datetime_helper/active_model_serialiser"
3
3
 
4
4
  class TestSerialiser < ActiveModel::Serializer
5
5
  extend DatetimeHelper::Serialisers
6
- attributes :updated_at, :enabled_date, :enabled_date_time
6
+ attributes :updated_at, :enabled_date, :enabled_time
7
7
 
8
8
  enforce_zulu_time :updated_at
9
9
  enforce_iso8601_date :enabled_date
10
- enforce_iso8601_date :enabled_date_time
10
+ enforce_iso8601_date :enabled_time
11
11
  end
12
12
 
13
13
  class TestItemNoTime
14
14
  include ActiveModel::SerializerSupport
15
- attr_reader :updated_at, :enabled_date, :enabled_date_time
15
+ attr_reader :updated_at, :enabled_date, :enabled_time
16
16
  def initialize(options = {})
17
17
  @updated_at = nil
18
18
  @enabled_date = nil
19
- @enabled_date_time = nil
19
+ @enabled_time = nil
20
20
  end
21
21
  end
22
22
 
@@ -24,7 +24,7 @@ class TestItem < TestItemNoTime
24
24
  def initialize(options = {})
25
25
  @updated_at = options[:updated_at] || Time.now.utc
26
26
  @enabled_date = options[:enabled_date] || Time.now.to_date
27
- @enabled_date_time = options[:enabled_date_time] || Time.now
27
+ @enabled_time = options[:enabled_time] || Time.now
28
28
  end
29
29
  end
30
30
 
@@ -60,12 +60,12 @@ describe DatetimeHelper::Serialisers do
60
60
 
61
61
  context 'with a date-time' do
62
62
  let(:item) { TestItem.new }
63
- it { expect(subject[:enabled_date_time]).to be_an_iso_formatted_date }
63
+ it { expect(subject[:enabled_time]).to be_an_iso_formatted_date }
64
64
  end
65
65
 
66
66
  context 'with a nil date-time' do
67
67
  let(:item) { TestItemNoTime.new }
68
- it { expect(subject[:enabled_date_time]).to be_nil}
68
+ it { expect(subject[:enabled_time]).to be_nil}
69
69
  end
70
70
 
71
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datetime_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - davesag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec