iso8601 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,110 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ISO8601::Time do
4
- it "should raise an error for any unknown pattern" do
5
- expect { ISO8601::Time.new('') }.to raise_error(ISO8601::Errors::UnknownPattern)
6
- expect { ISO8601::Time.new('T') }.to raise_error(ISO8601::Errors::UnknownPattern)
7
- expect { ISO8601::Time.new('T10:3012+0400') }.to raise_error(ISO8601::Errors::UnknownPattern)
8
- expect { ISO8601::Time.new('T10:30:12+0400') }.to raise_error(ISO8601::Errors::UnknownPattern)
9
- expect { ISO8601::Time.new('T10:30:12+040') }.to raise_error(ISO8601::Errors::UnknownPattern)
10
- end
11
-
12
- it "should raise an error for a correct pattern but an invalid date" do
13
- expect { ISO8601::Time.new('T25:00:00') }.to raise_error(ISO8601::Errors::RangeError)
14
- expect { ISO8601::Time.new('T00:61:00') }.to raise_error(ISO8601::Errors::RangeError)
15
- expect { ISO8601::Time.new('T00:00:61') }.to raise_error(ISO8601::Errors::RangeError)
16
- end
17
-
18
- it "should parse any allowed pattern" do
19
- expect { ISO8601::Time.new('T10') }.to_not raise_error
20
- expect { ISO8601::Time.new('T10-00:00') }.to_not raise_error
21
- expect { ISO8601::Time.new('T10Z') }.to_not raise_error
22
- expect { ISO8601::Time.new('T10:30') }.to_not raise_error
23
- expect { ISO8601::Time.new('T10:30Z') }.to_not raise_error
24
- expect { ISO8601::Time.new('T10:30:12') }.to_not raise_error
25
- expect { ISO8601::Time.new('T10:30:12Z') }.to_not raise_error
26
- expect { ISO8601::Time.new('T10:30:12+04') }.to_not raise_error
27
- expect { ISO8601::Time.new('T10:30:12+04:00') }.to_not raise_error
28
- expect { ISO8601::Time.new('T10:30:12-04:00') }.to_not raise_error
29
- expect { ISO8601::Time.new('T103012+0400') }.to_not raise_error
30
- expect { ISO8601::Time.new('T103012+04') }.to_not raise_error
31
- expect { ISO8601::Time.new('T10:30:12-00:00') }.to_not raise_error
32
- expect { ISO8601::Time.new('T16:26:10,5Z') }.to_not raise_error
33
- expect { ISO8601::Time.new('T10+00:00') }.to_not raise_error
34
- end
35
-
36
- context 'reduced patterns' do
37
- it "should parse correctly reduced times" do
38
- reduced_time = ISO8601::Time.new('T101112Z')
39
- expect(reduced_time.hour).to eq(10)
40
- expect(reduced_time.minute).to eq(11)
41
- expect(reduced_time.second).to eq(12)
42
- end
43
- end
44
-
45
- it "should return each atomic value" do
46
- t = ISO8601::Time.new('T12:02:01+04:00', ::Date.parse('2010-05-09'))
47
- expect(t.hour).to eq(12)
48
- expect(t.minute).to eq(2)
49
- expect(t.second).to eq(1)
50
- expect(t.zone).to eq('+04:00')
51
- end
52
-
53
- it "should keep the correct fraction when using commma separators" do
54
- expect(ISO8601::Time.new('T16:26:10,5Z').second).to eq(10.5)
55
- end
56
-
57
- it "should respond to delegated casting methods" do
58
- expect(ISO8601::Time.new('T10:09:08Z')).to respond_to(:to_s, :to_time, :to_date, :to_datetime)
59
- end
60
-
61
- describe '#+' do
62
- it "should return the result of the addition of a number" do
63
- expect((ISO8601::Time.new('T20:20:20Z') + 10).to_s).to eq('T20:20:30+00:00')
64
- expect((ISO8601::Time.new('T20:20:20.5Z') + 10).to_s).to eq('T20:20:30.5+00:00')
65
- expect((ISO8601::Time.new('T20:20:20+02:00') + 10.09).to_s).to eq('T20:20:30.1+02:00')
66
- expect((ISO8601::Time.new('T20:20:20+02:00') + 10.1).to_s).to eq('T20:20:30.1+02:00')
67
- expect((ISO8601::Time.new('T20:20:20+02:00') + 10).second).to eq(30)
68
- expect((ISO8601::Time.new('T20:20:20.5Z') + 10).second).to eq(30.5)
69
- expect((ISO8601::Time.new('T20:20:20+02:00') + 10.09).second).to eq(30.1)
70
- end
71
- end
72
-
73
- describe '#-' do
74
- it "should return the result of the subtraction of a number" do
75
- expect((ISO8601::Time.new('T20:20:20+01:00') - 10).to_s).to eq('T20:20:10+01:00')
76
- expect((ISO8601::Time.new('T20:20:20.11+02:00') - 10).to_s).to eq('T20:20:10.1+02:00')
77
- end
78
- end
79
-
80
- describe '#to_a' do
81
- it "should return an array of atoms" do
82
- expect(ISO8601::Time.new('T19:29:39Z').to_a).to eq([19, 29, 39, '+00:00'])
83
- end
84
- end
85
-
86
- describe '#atoms' do
87
- it "should return an array of atoms" do
88
- expect(ISO8601::Time.new('T19:29:39+04:00').atoms).to eq([19, 29, 39, '+04:00'])
89
- expect(ISO8601::Time.new('T19:29:39Z').atoms).to eq([19, 29, 39, 'Z'])
90
- expect(ISO8601::Time.new('T19:29:39').atoms).to eq([19, 29, 39])
91
- expect(ISO8601::Time.new('T19:29').atoms).to eq([19, 29, 0.0])
92
- expect(ISO8601::Time.new('T19:29Z').atoms).to eq([19, 29, 0.0, 'Z'])
93
- expect(ISO8601::Time.new('T19Z').atoms).to eq([19, 0, 0.0, 'Z'])
94
- end
95
- end
96
-
97
- describe '#hash' do
98
- it "should return the time hash" do
99
- subject = ISO8601::Time.new('T20:11:10Z')
100
-
101
- expect(subject).to respond_to(:hash)
102
- end
103
- it "should return the same hash" do
104
- subject = ISO8601::Time.new('T20:11:10Z')
105
- contrast = ISO8601::Time.new('T20:11:10Z')
106
-
107
- expect(subject.hash).to eq(contrast.hash)
108
- end
109
- end
110
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ISO8601::Weeks do
4
- describe 'Atomic' do
5
- let(:subject) { ISO8601::Weeks.new(1) }
6
-
7
- it "should respond to the Atomic interface" do
8
- %i[factor
9
- to_seconds
10
- symbol
11
- to_i
12
- to_f
13
- to_s
14
- value
15
- <=>
16
- eql?
17
- hash
18
- valid_atom?].each { |m| expect(subject).to respond_to(m) }
19
- end
20
- end
21
-
22
- describe '#factor' do
23
- it "should return the Week factor" do
24
- expect(ISO8601::Weeks.new(2).factor).to eq(604800)
25
- end
26
- end
27
-
28
- describe '#to_seconds' do
29
- it "should return the amount of seconds" do
30
- expect(ISO8601::Weeks.new(2).to_seconds).to eq(1209600)
31
- expect(ISO8601::Weeks.new(-2).to_seconds).to eq(-1209600)
32
- end
33
- end
34
-
35
- describe '#symbol' do
36
- it "should return the ISO symbol" do
37
- expect(ISO8601::Weeks.new(1).symbol).to eq(:W)
38
- end
39
- end
40
-
41
- describe '#hash' do
42
- it "should build hash identity by value" do
43
- expect(ISO8601::Weeks.new(3).hash).to eq(ISO8601::Weeks.new(3).hash)
44
- end
45
- end
46
- end
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ISO8601::Years do
4
- let(:common_year) { ISO8601::DateTime.new('2010-01-01') }
5
- let(:leap_year) { ISO8601::DateTime.new('2000-01-01') }
6
-
7
- describe 'Atomic' do
8
- let(:subject) { ISO8601::Years.new(1) }
9
-
10
- it "should respond to the Atomic interface" do
11
- %i[factor
12
- to_seconds
13
- symbol
14
- to_i
15
- to_f
16
- to_s
17
- value
18
- <=>
19
- eql?
20
- hash
21
- valid_atom?].each { |m| expect(subject).to respond_to(m) }
22
- end
23
- end
24
-
25
- describe '#factor' do
26
- it "should return the Year factor" do
27
- expect { ISO8601::Years.new(1).factor }.to_not raise_error
28
- expect(ISO8601::Years.new(2).factor).to eq(31536000)
29
- expect(ISO8601::Years.new(1).factor).to eq(31536000)
30
- end
31
-
32
- it "should return the Year factor for a common year" do
33
- expect(ISO8601::Years.new(1).factor(common_year)).to eq(31536000)
34
- expect(ISO8601::Years.new(0).factor(common_year)).to eq(31536000)
35
- end
36
-
37
- it "should return the Year factor for a leap year" do
38
- expect(ISO8601::Years.new(1).factor(leap_year)).to eq(31622400)
39
- end
40
- end
41
-
42
- describe '#to_seconds' do
43
- it "should return the amount of seconds" do
44
- expect(ISO8601::Years.new(2).to_seconds).to eq(63072000)
45
- expect(ISO8601::Years.new(-2).to_seconds).to eq(-63072000)
46
- end
47
-
48
- it "should return the amount of seconds for a common year" do
49
- expect(ISO8601::Years.new(2).to_seconds(common_year)).to eq(63072000)
50
- expect(ISO8601::Years.new(12).to_seconds(common_year)).to eq(378691200)
51
- end
52
-
53
- it "should return the amount of seconds for a leap year" do
54
- expect(ISO8601::Years.new(2).to_seconds(leap_year)).to eq(63158400)
55
- expect(ISO8601::Years.new(15).to_seconds(leap_year)).to eq(473385600)
56
- end
57
- end
58
-
59
- describe '#symbol' do
60
- it "should return the ISO symbol" do
61
- expect(ISO8601::Years.new(1).symbol).to eq(:Y)
62
- end
63
- end
64
-
65
- describe '#hash' do
66
- it "should build hash identity by value" do
67
- expect(ISO8601::Years.new(3).hash).to eq(ISO8601::Years.new(3).hash)
68
- end
69
- end
70
- end
@@ -1,12 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
- require 'iso8601'
3
-
4
- RSpec.configure do |config|
5
- config.run_all_when_everything_filtered = true
6
- config.color = true
7
- config.order = 'random'
8
- config.formatter = :documentation
9
- # config.fail_fast = true
10
- config.run_all_when_everything_filtered = true
11
- config.filter_run :focus
12
- end