dtg 4.0.1 → 5.0.0

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,168 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe DateTime do
4
- # Set Time Zone before tests
5
- before do
6
- Time.zone = "UTC"
7
- end
8
-
9
- let(:time) { described_class.now { include DateTimeGroup } }
10
-
11
- describe "#to_dtg" do
12
- context "when zone is a symbol" do
13
- context "when symbol is lowercase" do
14
- it "converts and formats as dtg" do
15
- (:a..:z).to_set.delete(:j).each do |zone|
16
- expect(time.to_dtg(zone)).to eq(time.in_time_zone(
17
- Zones::UTC_ZONES[zone])
18
- .strftime(
19
- "%d%H%M#{zone.upcase.to_s} %b %y"))
20
- end
21
- # :j is separate because there is no local timezone identifier,
22
- # it just gets returned and formatted
23
- expect(time.to_dtg(:j)).to eq(time.format(:j))
24
- end
25
- end
26
-
27
- context "when symbol is uppercase" do
28
- it "converts and formats as dtg" do
29
- (:A..:Z).to_set.delete(:J).each do |zone|
30
- expect(time.to_dtg(zone)).to eq(time.in_time_zone(
31
- Zones::UTC_ZONES[zone.downcase])
32
- .strftime(
33
- "%d%H%M#{zone.to_s} %b %y"))
34
- end
35
- # :J is separate because there is no local timezone identifier,
36
- # it just gets returned and formatted
37
- expect(time.to_dtg(:J)).to eq(time.format(:j))
38
- end
39
- end
40
- end
41
-
42
- context "when zone is a single character string" do
43
- context "when string is lowercase" do
44
- it "converts and formats as dtg" do
45
- ('a'..'z').to_set.delete('j').each do |zone|
46
- expect(time.to_dtg(zone)).to eq(time.in_time_zone(
47
- Zones::UTC_ZONES[zone.to_sym])
48
- .strftime(
49
- "%d%H%M#{zone.upcase} %b %y"))
50
- end
51
- # 'j' is separate because there is no local timezone identifier
52
- # it just gets returned and formatted
53
- expect(time.to_dtg('j')).to eq(time.format(:j))
54
- end
55
- end
56
-
57
- context "when string is uppercase" do
58
- it "converts and formats as dtg" do
59
- ('A'..'Z').to_set.delete('J').each do |zone|
60
- expect(time.to_dtg(zone)).to eq(time.in_time_zone(
61
- Zones::UTC_ZONES[zone.downcase.to_sym])
62
- .strftime(
63
- "%d%H%M#{zone} %b %y"))
64
- end
65
- # 'J' is separate because there is no local timezone identifier,
66
- # it just gets returned and formatted
67
- expect(time.to_dtg('J')).to eq(time.format(:j))
68
- end
69
- end
70
- end
71
- end
72
-
73
- describe "#format" do
74
- context "when zone is a symbol" do
75
- context "when symbol is lowercase" do
76
- it "formats to dtg standard" do
77
- (:a..:z).each do |zone|
78
- expect(time.format(zone)).to eq(time.strftime(
79
- "%d%H%M#{zone.upcase.to_s} %b %y"))
80
- end
81
- end
82
- end
83
-
84
- context "when symbol is uppercase" do
85
- it "formats to dtg standard" do
86
- (:A..:Z).each do |zone|
87
- expect(time.format(zone)).to eq(time.strftime(
88
- "%d%H%M#{zone.to_s} %b %y"))
89
- end
90
- end
91
- end
92
- end
93
-
94
- context "when zone is a single character string" do
95
- context "when string is lowercase" do
96
- it "formats to dtg standard" do
97
- ('a'..'z').each do |zone|
98
- expect(time.format(zone)).to eq(time.strftime(
99
- "%d%H%M#{zone.upcase} %b %y"))
100
- end
101
- end
102
- end
103
-
104
- context "when string is uppercase" do
105
- it "formats to dtg standard" do
106
- ('A'..'Z').each do |zone|
107
- expect(time.format(zone)).to eq(time.strftime(
108
- "%d%H%M#{zone} %b %y"))
109
- end
110
- end
111
- end
112
- end
113
- end
114
-
115
- describe "#convert" do
116
- context "when zone is a symbol" do
117
- context "when symbol is lowercase" do
118
- it "returns converted time to new zone" do
119
- (:a..:z).to_set.delete(:j).each do |zone|
120
- expect(time.convert(zone)).to eq(time.in_time_zone(
121
- Zones::UTC_ZONES[zone]))
122
- end
123
- # :j is separate because there is no local timezone identifier,
124
- # it just gets returned and formatted
125
- expect(time.convert(:j)).to eq(time)
126
- end
127
- end
128
-
129
- context "when symbol is uppercase" do
130
- it "returns converted time to new zone" do
131
- (:A..:Z).to_set.delete(:J).each do |zone|
132
- expect(time.convert(zone)).to eq(time.in_time_zone(
133
- Zones::UTC_ZONES[zone.downcase]))
134
- end
135
- # :J is separate because there is no local timezone identifier,
136
- # it just gets returned and formatted
137
- expect(time.convert(:J)).to eq(time)
138
- end
139
- end
140
- end
141
-
142
- context "when zone is a single character string" do
143
- context "when string is lowercase" do
144
- it "returns converted time to new zone" do
145
- ('a'..'z').to_set.delete('j').each do |zone|
146
- expect(time.convert(zone)).to eq(time.in_time_zone(
147
- Zones::UTC_ZONES[zone.to_sym]))
148
- end
149
- # 'j' is separate because there is no local timezone identifier,
150
- # it just gets returned and formatted
151
- expect(time.convert('j')).to eq(time)
152
- end
153
- end
154
-
155
- context "when string is uppercase" do
156
- it "returns converted time to new zone" do
157
- ('A'..'Z').to_set.delete('J').each do |zone|
158
- expect(time.convert(zone)).to eq(time.in_time_zone(
159
- Zones::UTC_ZONES[zone.downcase.to_sym]))
160
- end
161
- # 'J' is separate because there is no local timezone identifier,
162
- # it just gets returned and formatted
163
- expect(time.convert('J')).to eq(time)
164
- end
165
- end
166
- end
167
- end
168
- end
@@ -1,35 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe DateTimeGroup do
4
- # Set Time Zone before tests
5
- before do
6
- Time.zone = "UTC"
7
- end
8
-
9
- describe "#dtg" do
10
- context "when the object is a DateTime" do
11
- let(:dummy) { DateTime.new{ include described_class } }
12
-
13
- it "returns datetime in a string" do
14
- expect(dummy.dtg).to eq("DTG gem is natively integrated with this class: #{dummy.class}")
15
- end
16
- end
17
-
18
- context "when the object is a Time" do
19
- let(:dummy) { Time.new{ include described_class } }
20
-
21
- it "returns time in a string" do
22
- expect(dummy.dtg).to eq("DTG gem is natively integrated with this class: #{dummy.class}")
23
- end
24
- end
25
-
26
- context "when the object is an ActiveSupport::TimeWithZone" do
27
- # ActiveSupport::TimeWithZone.new is not allowed to instantiate empty class
28
- let(:dummy) { Time.zone.now { include described_class } }
29
-
30
- it "returns the ActiveSupport::TimeWithZone in a string" do
31
- expect(dummy.dtg).to eq("DTG gem is natively integrated with this class: #{dummy.class}")
32
- end
33
- end
34
- end
35
- end
@@ -1,168 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Time do
4
- # Set Time Zone before tests
5
- before do
6
- described_class.zone = "UTC"
7
- end
8
-
9
- let(:time) { described_class.now { include DateTimeGroup } }
10
-
11
- describe "#to_dtg" do
12
- context "when zone is a symbol" do
13
- context "when symbol is lowercase" do
14
- it "converts and formats as dtg" do
15
- (:a..:z).to_set.delete(:j).each do |zone|
16
- expect(time.to_dtg(zone)).to eq(time.in_time_zone(
17
- Zones::UTC_ZONES[zone])
18
- .strftime(
19
- "%d%H%M#{zone.upcase.to_s} %b %y"))
20
- end
21
- # :j is separate because there is no local timezone identifier,
22
- # it just gets returned and formatted
23
- expect(time.to_dtg(:j)).to eq(time.format(:j))
24
- end
25
- end
26
-
27
- context "when symbol is uppercase" do
28
- it "converts and formats as dtg" do
29
- (:A..:Z).to_set.delete(:J).each do |zone|
30
- expect(time.to_dtg(zone)).to eq(time.in_time_zone(
31
- Zones::UTC_ZONES[zone.downcase])
32
- .strftime(
33
- "%d%H%M#{zone.to_s} %b %y"))
34
- end
35
- # :J is separate because there is no local timezone identifier,
36
- # it just gets returned and formatted
37
- expect(time.to_dtg(:J)).to eq(time.format(:j))
38
- end
39
- end
40
- end
41
-
42
- context "when zone is a single character string" do
43
- context "when string is lowercase" do
44
- it "converts and formats as dtg" do
45
- ('a'..'z').to_set.delete('j').each do |zone|
46
- expect(time.to_dtg(zone)).to eq(time.in_time_zone(
47
- Zones::UTC_ZONES[zone.to_sym])
48
- .strftime(
49
- "%d%H%M#{zone.upcase} %b %y"))
50
- end
51
- # 'j' is separate because there is no local timezone identifier
52
- # it just gets returned and formatted
53
- expect(time.to_dtg('j')).to eq(time.format(:j))
54
- end
55
- end
56
-
57
- context "when string is uppercase" do
58
- it "converts and formats as dtg" do
59
- ('A'..'Z').to_set.delete('J').each do |zone|
60
- expect(time.to_dtg(zone)).to eq(time.in_time_zone(
61
- Zones::UTC_ZONES[zone.downcase.to_sym])
62
- .strftime(
63
- "%d%H%M#{zone} %b %y"))
64
- end
65
- # 'J' is separate because there is no local timezone identifier,
66
- # it just gets returned and formatted
67
- expect(time.to_dtg('J')).to eq(time.format(:j))
68
- end
69
- end
70
- end
71
- end
72
-
73
- describe "#format" do
74
- context "when zone is a symbol" do
75
- context "when symbol is lowercase" do
76
- it "formats to dtg standard" do
77
- (:a..:z).each do |zone|
78
- expect(time.format(zone)).to eq(time.strftime(
79
- "%d%H%M#{zone.upcase.to_s} %b %y"))
80
- end
81
- end
82
- end
83
-
84
- context "when symbol is uppercase" do
85
- it "formats to dtg standard" do
86
- (:A..:Z).each do |zone|
87
- expect(time.format(zone)).to eq(time.strftime(
88
- "%d%H%M#{zone.to_s} %b %y"))
89
- end
90
- end
91
- end
92
- end
93
-
94
- context "when zone is a single character string" do
95
- context "when string is lowercase" do
96
- it "formats to dtg standard" do
97
- ('a'..'z').each do |zone|
98
- expect(time.format(zone)).to eq(time.strftime(
99
- "%d%H%M#{zone.upcase} %b %y"))
100
- end
101
- end
102
- end
103
-
104
- context "when string is uppercase" do
105
- it "formats to dtg standard" do
106
- ('A'..'Z').each do |zone|
107
- expect(time.format(zone)).to eq(time.strftime(
108
- "%d%H%M#{zone} %b %y"))
109
- end
110
- end
111
- end
112
- end
113
- end
114
-
115
- describe "#convert" do
116
- context "when zone is a symbol" do
117
- context "when symbol is lowercase" do
118
- it "returns converted time to new zone" do
119
- (:a..:z).to_set.delete(:j).each do |zone|
120
- expect(time.convert(zone)).to eq(time.in_time_zone(
121
- Zones::UTC_ZONES[zone]))
122
- end
123
- # :j is separate because there is no local timezone identifier,
124
- # it just gets returned and formatted
125
- expect(time.convert(:j)).to eq(time)
126
- end
127
- end
128
-
129
- context "when symbol is uppercase" do
130
- it "returns converted time to new zone" do
131
- (:A..:Z).to_set.delete(:J).each do |zone|
132
- expect(time.convert(zone)).to eq(time.in_time_zone(
133
- Zones::UTC_ZONES[zone.downcase]))
134
- end
135
- # :J is separate because there is no local timezone identifier,
136
- # it just gets returned and formatted
137
- expect(time.convert(:J)).to eq(time)
138
- end
139
- end
140
- end
141
-
142
- context "when zone is a single character string" do
143
- context "when string is lowercase" do
144
- it "returns converted time to new zone" do
145
- ('a'..'z').to_set.delete('j').each do |zone|
146
- expect(time.convert(zone)).to eq(time.in_time_zone(
147
- Zones::UTC_ZONES[zone.to_sym]))
148
- end
149
- # 'j' is separate because there is no local timezone identifier,
150
- # it just gets returned and formatted
151
- expect(time.convert('j')).to eq(time)
152
- end
153
- end
154
-
155
- context "when string is uppercase" do
156
- it "returns converted time to new zone" do
157
- ('A'..'Z').to_set.delete('J').each do |zone|
158
- expect(time.convert(zone)).to eq(time.in_time_zone(
159
- Zones::UTC_ZONES[zone.downcase.to_sym]))
160
- end
161
- # 'J' is separate because there is no local timezone identifier,
162
- # it just gets returned and formatted
163
- expect(time.convert('J')).to eq(time)
164
- end
165
- end
166
- end
167
- end
168
- end
@@ -1,9 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Dtg do
4
- describe ".dtg" do
5
- it "replies as active if gem is loaded" do
6
- expect(described_class.dtg).to eq("DTG gem is active")
7
- end
8
- end
9
- end