flash_extensions 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Array do
4
+
5
+ describe "#remove_blanks" do
6
+ it "to be this is a test" do
7
+ expect("this is a test".split(" ").remove_blanks).to eq(["this", "is", "a", "test"])
8
+ end
9
+
10
+ it "to be this is a test" do
11
+ expect(["this", "", "that", nil].remove_blanks).to eq(["this", "that"])
12
+ end
13
+ end
14
+
15
+ describe "#remove_first_element" do
16
+ it "to be this is a test" do
17
+ expect(["1", "2", "3"].remove_first_element).to eq(["2", "3"])
18
+ end
19
+ end
20
+
21
+ describe "#remove_last_element" do
22
+ it "to be this is a test" do
23
+ expect(["1", "2", "3"].remove_last_element).to eq(["1", "2"])
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hash do
4
+ describe "#rename_keys" do
5
+ it "to be [:baz, :bar]" do
6
+ expect({ foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar).keys).to eq([:baz, :bar])
7
+ end
8
+
9
+ it "to be [:foo, 'tick']" do
10
+ expect({ foo: 'foo', 'baz' => 'baz' }.rename_keys('baz' => 'tick').keys).to eq([:foo, 'tick'])
11
+ end
12
+
13
+ it "to be [:bar, :tick]" do
14
+ expect({ foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar, baz: :tick).keys).to eq([:bar, :tick])
15
+ end
16
+
17
+ it "to be [:bar, 'tick']" do
18
+ expect({ foo: 'foo', 'baz' => 'baz' }.rename_keys(foo: :bar, 'baz' => 'tick').keys).to eq([:bar, 'tick'])
19
+ end
20
+ end
21
+
22
+ describe "#stringify_keys(!)" do
23
+ it "to be ['foo', 'bar']" do
24
+ expect({ foo: 'foo', 'bar' => 'bar' }.stringify_keys.keys).to eq(['foo', 'bar'])
25
+ expect({ foo: 'foo', 'bar' => 'bar' }.stringify_keys!.keys).to eq(['foo', 'bar'])
26
+ end
27
+ end
28
+
29
+ describe "#symbolize_keys(!)" do
30
+ it "to be [:foo, :bar]" do
31
+ expect({ foo: 'foo', 'bar' => 'bar' }.symbolize_keys.keys).to eq([:foo, :bar])
32
+ expect({ foo: 'foo', 'bar' => 'bar' }.symbolize_keys!.keys).to eq([:foo, :bar])
33
+ end
34
+ end
35
+
36
+ describe "#symbolize_and_underscore_keys(!)" do
37
+ it "to be [:foo_bar, :baz_bar]" do
38
+ expect({ 'foo_Bar' => 'example', bazBar: 'string' }.symbolize_and_underscore_keys.keys).to eq([:foo_bar, :baz_bar])
39
+ expect({ 'foo_Bar' => 'example', bazBar: 'string' }.symbolize_and_underscore_keys.keys).to eq([:foo_bar, :baz_bar])
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe Object do
4
+ describe "#blank?" do
5
+ it "to be true" do
6
+ expect("".blank?).to eq(true)
7
+ expect([].blank?).to eq(true)
8
+ expect({}.blank?).to eq(true)
9
+ expect(false.blank?).to eq(true)
10
+ end
11
+
12
+ it "to be false" do
13
+ expect("x".blank?).to eq(false)
14
+ expect("foo bar".blank?).to eq(false)
15
+ expect("19".blank?).to eq(false)
16
+ expect(true.blank?).to eq(false)
17
+ end
18
+ end
19
+
20
+ describe "#present?" do
21
+ it "to be true" do
22
+ expect("x".present?).to eq(true)
23
+ expect("foo bar".present?).to eq(true)
24
+ expect("19".present?).to eq(true)
25
+ expect(true.present?).to eq(true)
26
+ end
27
+
28
+ it "to be false" do
29
+ expect("".present?).to eq(false)
30
+ expect([].present?).to eq(false)
31
+ expect({}.present?).to eq(false)
32
+ expect(false.present?).to eq(false)
33
+ end
34
+ end
35
+
36
+ describe "#try" do
37
+ it "to be upcase" do
38
+ expect("example".try(:upcase)).to eq("EXAMPLE")
39
+ end
40
+
41
+ it "to be nil" do
42
+ expect("example".try(:fake_method)).to eq(nil)
43
+ end
44
+ end
45
+
46
+ describe "#numeric?" do
47
+ it "to be true" do
48
+ expect(5.numeric?).to eq(true)
49
+ expect(0.numeric?).to eq(true)
50
+ expect(-37.3.numeric?).to eq(true)
51
+ expect(51.45.numeric?).to eq(true)
52
+ expect("+256.375".numeric?).to eq(true)
53
+ expect("-37.3".numeric?).to eq(true)
54
+ end
55
+
56
+ it "to be false" do
57
+ expect("".numeric?).to eq(false)
58
+ expect(" ".numeric?).to eq(false)
59
+ expect("2.3.3".numeric?).to eq(false)
60
+ expect("$9.86".numeric?).to eq(false)
61
+ expect("x".numeric?).to eq(false)
62
+ expect("foo".numeric?).to eq(false)
63
+ end
64
+ end
65
+
66
+ describe "#palindrome?" do
67
+ it "to be true" do
68
+ expect("racecar".palindrome?).to eq(true)
69
+ expect(12321.palindrome?).to eq(true)
70
+ end
71
+
72
+ it "to be false" do
73
+ expect("example".palindrome?).to eq(false)
74
+ expect(12345.palindrome?).to eq(false)
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,236 @@
1
+ require 'spec_helper'
2
+
3
+ describe String do
4
+ describe "#camelize" do
5
+ it "to be ExampleString" do
6
+ expect("example_string".camelize).to eq("ExampleString")
7
+ end
8
+
9
+ it "to be exampleString" do
10
+ expect("example_string".camelize(:lower)).to eq("exampleString")
11
+ end
12
+ end
13
+
14
+ describe "#ends_with?" do
15
+ it "to be true" do
16
+ expect("".ends_with?("")).to eq(true)
17
+ expect(" ".ends_with?(" ")).to eq(true)
18
+ expect(" ".ends_with?("")).to eq(true)
19
+ expect("example string".ends_with?("g")).to eq(true)
20
+ expect("example string".ends_with?("ng")).to eq(true)
21
+ end
22
+
23
+ it "to be false" do
24
+ expect("".ends_with?(" ")).to eq(false)
25
+ expect("e ".ends_with?("e")).to eq(false)
26
+ expect("example string".ends_with?("x")).to eq(false)
27
+ end
28
+ end
29
+
30
+ describe "#humanize" do
31
+ it "to be Example string test" do
32
+ expect("example_string_test".humanize).to eq("Example string test")
33
+ expect("exampleStringTest".humanize).to eq("Example string test")
34
+ expect("ExampleStringTest".humanize).to eq("Example string test")
35
+ end
36
+ end
37
+
38
+ describe "#starts_with?" do
39
+ it "to be true" do
40
+ expect("".starts_with?("")).to eq(true)
41
+ expect(" ".starts_with?(" ")).to eq(true)
42
+ expect(" ".starts_with?("")).to eq(true)
43
+ expect("example string".starts_with?("e")).to eq(true)
44
+ expect("example string".starts_with?("ex")).to eq(true)
45
+ end
46
+
47
+ it "to be false" do
48
+ expect("".starts_with?(" ")).to eq(false)
49
+ expect(" e".starts_with?("e")).to eq(false)
50
+ expect("example string".starts_with?("x")).to eq(false)
51
+ end
52
+ end
53
+
54
+ describe "#titleize" do
55
+ it "to be Example String Test" do
56
+ expect("example string test".titleize).to eq("Example String Test")
57
+ expect("Example string Test".titleize).to eq("Example String Test")
58
+ expect("ExampleStringTest".titleize).to eq("Example String Test")
59
+ expect("Example_string_test".titleize).to eq("Example String Test")
60
+ end
61
+ end
62
+
63
+ describe "#underscore" do
64
+ it "to be example_string" do
65
+ expect("ExampleString".underscore).to eq("example_string")
66
+ expect("exampleString".underscore).to eq("example_string")
67
+ expect("example_string".underscore).to eq("example_string")
68
+ expect("example_String".underscore).to eq("example_string")
69
+ end
70
+ end
71
+
72
+ describe "#domain" do
73
+ it "to be test" do
74
+ expect("".domain).to eq("")
75
+ expect(" ".domain).to eq(" ")
76
+ expect("example string".domain).to eq("example string")
77
+ expect("http://www.example.com".domain).to eq("www.example.com")
78
+ expect("http://www.example.com/fake-page".domain).to eq("www.example.com")
79
+ end
80
+ end
81
+
82
+ describe "#downcase?" do
83
+ it "to be true" do
84
+ expect("downcase".downcase?).to eq(true)
85
+ expect("downcase string".downcase?).to eq(true)
86
+ end
87
+
88
+ it "to be false" do
89
+ expect("Mixedcase".downcase?).to eq(false)
90
+ expect("UPCASE".downcase?).to eq(false)
91
+ expect("Mixedcase string".downcase?).to eq(false)
92
+ end
93
+ end
94
+
95
+ describe "#ellipsize" do
96
+ it "to be example string" do
97
+ expect("example string".ellipsize).to eq("example string")
98
+ end
99
+
100
+ it "to be 0123...WXYZ" do
101
+ expect("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize).to eq("0123...WXYZ")
102
+ end
103
+
104
+ it "to be 012...XYZ" do
105
+ expect("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(length: 50)).to eq("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
106
+ end
107
+
108
+ it "to be 012...XYZ" do
109
+ expect("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(offset: 3)).to eq("012...XYZ")
110
+ end
111
+
112
+ it "to be 0123+++WXYZ" do
113
+ expect("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(separator: "+++")).to eq("0123+++WXYZ")
114
+ end
115
+ end
116
+
117
+ describe "#gnix" do
118
+ it "to be this that " do
119
+ expect("this thing that thing".gnix("thing")).to eq("this that ")
120
+ end
121
+ end
122
+
123
+ describe "#mixedcase?" do
124
+ it "to be true" do
125
+ expect("Mixedcase".mixedcase?).to eq(true)
126
+ expect("Mixedcase STRING type".mixedcase?).to eq(true)
127
+ end
128
+
129
+ it "to be false" do
130
+ expect("downcase".mixedcase?).to eq(false)
131
+ expect("UPCASE".mixedcase?).to eq(false)
132
+ end
133
+ end
134
+
135
+ describe "#nix" do
136
+ it "to be this that thing" do
137
+ expect("this thing that thing".nix("thing")).to eq("this that thing")
138
+ end
139
+ end
140
+
141
+ describe "#pollute" do
142
+ it "to be t^--^--^e^--^--^s^--^--^t^--^--^" do
143
+ expect("test".pollute).to eq("t^--^--^e^--^--^s^--^--^t^--^--^")
144
+ end
145
+
146
+ it "to be t-e-s-t-" do
147
+ expect("test".pollute("-")).to eq("t-e-s-t-")
148
+ end
149
+ end
150
+
151
+ describe "#unpollute" do
152
+ it "to be test" do
153
+ expect("test".unpollute).to eq("test")
154
+ end
155
+
156
+ it "to be test" do
157
+ expect("t-e-s-t-".unpollute("-")).to eq("test")
158
+ end
159
+ end
160
+
161
+ describe "#pollute then #unpollute" do
162
+ it "to be test" do
163
+ expect("test".pollute.unpollute).to eq("test")
164
+ end
165
+
166
+ it "to be test" do
167
+ expect("t-e-s-t-".pollute("-").unpollute("-")).to eq("test")
168
+ end
169
+ end
170
+
171
+ describe "#slugify" do
172
+ it "to be example" do
173
+ expect("example".slugify).to eq("example")
174
+ end
175
+
176
+ it "to be example-string" do
177
+ expect("example string".slugify).to eq("example-string")
178
+ end
179
+
180
+ it "to be example-string-test" do
181
+ expect("Example string @@@ test!".slugify).to eq("example-string-test")
182
+ end
183
+
184
+ it "to be a-real-doozie" do
185
+ expect(" A REal Doozi\"e? \' ".slugify).to eq("a-real-doozie")
186
+ end
187
+ end
188
+
189
+ describe "#strip_tags" do
190
+ it "to be example" do
191
+ expect("example".strip_tags).to eq("example")
192
+ end
193
+
194
+ it "to be click" do
195
+ expect("<a href='http://example.com'>click</a>".strip_tags).to eq("click")
196
+ end
197
+
198
+ it "to be this is bold and emphatic" do
199
+ expect("this is <b>bold</b> and <em>emphatic</em>".strip_tags).to eq("this is bold and emphatic")
200
+ end
201
+ end
202
+
203
+ describe "#strip_tags" do
204
+ it "to be example" do
205
+ expect("example string test".strip_whitespace).to eq("example string test")
206
+ expect(" this \t is also a test ".strip_whitespace).to eq("this is also a test")
207
+ end
208
+ end
209
+
210
+ describe "#truncate_preserving_words" do
211
+ it "to be example string" do
212
+ expect("example string".truncate_preserving_words).to eq("example string")
213
+ expect("example string".truncate_preserving_words(max_words: 10)).to eq("example string")
214
+ expect("example string".truncate_preserving_words(:max_chars => 15, :end_string => "..")).to eq("example string")
215
+ end
216
+
217
+ it "to be example string" do
218
+ expect("example string test another1 another2 another3".truncate_preserving_words).to eq("example string test another1 ...")
219
+ expect("example string test".truncate_preserving_words(max_words: 2)).to eq("example string ...")
220
+ expect("example string test".truncate_preserving_words(max_chars: 10, separator: "+++")).to eq("example +++")
221
+ end
222
+ end
223
+
224
+ describe "#upcase?" do
225
+ it "to be true" do
226
+ expect("UPCASE".upcase?).to eq(true)
227
+ expect("UPCASE STRING".upcase?).to eq(true)
228
+ end
229
+
230
+ it "to be false" do
231
+ expect("downcase".upcase?).to eq(false)
232
+ expect("Mixedcase".upcase?).to eq(false)
233
+ expect("Mixedcase string".upcase?).to eq(false)
234
+ end
235
+ end
236
+ end
@@ -0,0 +1,469 @@
1
+ require 'spec_helper'
2
+
3
+ describe Time do
4
+ describe "#format" do
5
+ datetime = Time.parse("2014-01-09 00:31:58 UTC")
6
+
7
+ context "#day" do
8
+ it "to be 01" do
9
+ expect(datetime.format("d")).to eq("09")
10
+ expect(datetime.format("day")).to eq("09")
11
+ expect(datetime.format("day_zero")).to eq("09")
12
+ end
13
+
14
+ it "to be 1" do
15
+ expect(datetime.format("dd")).to eq("9")
16
+ expect(datetime.format("Day")).to eq("9")
17
+ expect(datetime.format("day_unpadded")).to eq("9")
18
+ end
19
+
20
+ it "to be _1" do
21
+ expect(datetime.format("ddd")).to eq(" 9")
22
+ expect(datetime.format("DAY")).to eq(" 9")
23
+ expect(datetime.format("day_blank")).to eq(" 9")
24
+ end
25
+
26
+ it "to be 009" do
27
+ expect(datetime.format("dddd")).to eq("009")
28
+ expect(datetime.format("day_of_the_year")).to eq("009")
29
+ end
30
+ end
31
+
32
+ context "#hour" do
33
+ it "to be 00" do
34
+ expect(datetime.format("h")).to eq("00")
35
+ expect(datetime.format("hour")).to eq("00")
36
+ expect(datetime.format("hour_zero")).to eq("00")
37
+ end
38
+
39
+ it "to be _0" do
40
+ expect(datetime.format("hh")).to eq(" 0")
41
+ expect(datetime.format("HOUR")).to eq(" 0")
42
+ expect(datetime.format("hour_blank")).to eq(" 0")
43
+ end
44
+
45
+ it "to be 12" do
46
+ expect(datetime.format("hhh")).to eq("12")
47
+ expect(datetime.format("hour_imperical")).to eq("12")
48
+ expect(datetime.format("hour_imperical_zero")).to eq("12")
49
+ end
50
+
51
+ it "to be 12" do
52
+ expect(datetime.format("hhhh")).to eq("12")
53
+ expect(datetime.format("HOUR_IMPERICAL")).to eq("12")
54
+ expect(datetime.format("hour_imperical_blank")).to eq("12")
55
+ end
56
+ end
57
+
58
+ context "#meridian" do
59
+ it "to be am" do
60
+ expect(datetime.format("ampm")).to eq("am")
61
+ expect(datetime.format("meridian")).to eq("am")
62
+ end
63
+
64
+ it "to be AM" do
65
+ expect(datetime.format("AMPM")).to eq("AM")
66
+ expect(datetime.format("MERIDIAN")).to eq("AM")
67
+ end
68
+ end
69
+
70
+ context "#minute" do
71
+ it "to be 31" do
72
+ expect(datetime.format("n")).to eq("31")
73
+ expect(datetime.format("minute")).to eq("31")
74
+ end
75
+ end
76
+
77
+ context "#month" do
78
+ it "to be 01" do
79
+ expect(datetime.format("m")).to eq("01")
80
+ expect(datetime.format("month")).to eq("01")
81
+ expect(datetime.format("month_zero")).to eq("01")
82
+ end
83
+
84
+ it "to be 1" do
85
+ expect(datetime.format("mm")).to eq("1")
86
+ expect(datetime.format("Month")).to eq("1")
87
+ expect(datetime.format("month_unpadded")).to eq("1")
88
+ end
89
+
90
+ it "to be _1" do
91
+ expect(datetime.format("mmm")).to eq(" 1")
92
+ expect(datetime.format("MONTH")).to eq(" 1")
93
+ expect(datetime.format("month_blank")).to eq(" 1")
94
+ end
95
+
96
+ it "to be January" do
97
+ expect(datetime.format("mmmm")).to eq("January")
98
+ expect(datetime.format("month_name")).to eq("January")
99
+ end
100
+
101
+ it "to be Jan" do
102
+ expect(datetime.format("mmmmm")).to eq("Jan")
103
+ expect(datetime.format("month_name_abbr")).to eq("Jan")
104
+ end
105
+ end
106
+
107
+ context "#second" do
108
+ it "to be 58" do
109
+ expect(datetime.format("s")).to eq("58")
110
+ expect(datetime.format("second")).to eq("58")
111
+ end
112
+ end
113
+
114
+ context "#time zone" do
115
+ it "to be +0000" do
116
+ expect(datetime.format("z")).to eq("+0000")
117
+ expect(datetime.format("time_zone")).to eq("+0000")
118
+ end
119
+
120
+ it "to be +00:00" do
121
+ expect(datetime.format("zz")).to eq("+00:00")
122
+ expect(datetime.format("time_zone_offset")).to eq("+00:00")
123
+ end
124
+
125
+ it "to be +00:00:00" do
126
+ expect(datetime.format("zzz")).to eq("+00:00:00")
127
+ expect(datetime.format("time_zone_offset_full")).to eq("+00:00:00")
128
+ end
129
+
130
+ it "to be UTC" do
131
+ expect(datetime.format("zzzz")).to eq("UTC")
132
+ expect(datetime.format("time_zone_name")).to eq("UTC")
133
+ end
134
+ end
135
+
136
+ context "#week" do
137
+ it "to be 01" do
138
+ expect(datetime.format("wwwww")).to eq("01")
139
+ expect(datetime.format("week")).to eq("01")
140
+ end
141
+
142
+ it "to be 01" do
143
+ expect(datetime.format("wwwwww")).to eq("01")
144
+ expect(datetime.format("week_offset")).to eq("01")
145
+ end
146
+ end
147
+
148
+ context "#weekday" do
149
+ it "to be 4" do
150
+ expect(datetime.format("w")).to eq("4")
151
+ expect(datetime.format("weekday")).to eq("4")
152
+ end
153
+
154
+ it "to be 4" do
155
+ expect(datetime.format("ww")).to eq("4")
156
+ expect(datetime.format("weekday_offset")).to eq("4")
157
+ end
158
+
159
+ it "to be Thursday" do
160
+ expect(datetime.format("www")).to eq("Thursday")
161
+ expect(datetime.format("weekday_name")).to eq("Thursday")
162
+ end
163
+
164
+ it "to be Thu" do
165
+ expect(datetime.format("wwww")).to eq("Thu")
166
+ expect(datetime.format("weekday_name_abbr")).to eq("Thu")
167
+ end
168
+ end
169
+
170
+ context "#year" do
171
+ it "to be 2014" do
172
+ expect(datetime.format("yyyy")).to eq("2014")
173
+ expect(datetime.format("year")).to eq("2014")
174
+ end
175
+
176
+ it "to be 14" do
177
+ expect(datetime.format("yy")).to eq("14")
178
+ expect(datetime.format("yr")).to eq("14")
179
+ end
180
+ end
181
+
182
+ context "chaining" do
183
+ it "to be 1 09, 2014" do
184
+ expect(datetime.format("month_unpadded day, year")).to eq("1 09, 2014")
185
+ end
186
+
187
+ it "00:31 am" do
188
+ expect(datetime.format("hour:minute ampm")).to eq("00:31 am")
189
+ end
190
+
191
+ it "to be January 9, 2014 12:31 am +0000" do
192
+ expect(datetime.format("month_name day_unpadded, year hour_imperical:minute ampm time_zone")).to eq("January 9, 2014 12:31 am +0000")
193
+ end
194
+ end
195
+
196
+ context "no string" do
197
+ it "to be 2014-01-09 00:31 +0000" do
198
+ expect(datetime.format).to eq("2014-01-09 00:31 +0000")
199
+ end
200
+
201
+ it "to be 2014-01-09 00:31 +0000" do
202
+ expect(datetime.format("")).to eq("2014-01-09 00:31 +0000")
203
+ end
204
+ end
205
+ end
206
+
207
+ describe "#to_format" do
208
+ datetime = Time.parse("2014-01-09 00:31:58 UTC")
209
+
210
+ context "#day" do
211
+ it "to be January 9" do
212
+ expect(datetime.to_format(:day)).to eq("January 9")
213
+ end
214
+
215
+ it "to be Jan 9" do
216
+ expect(datetime.to_format(:day_abbr)).to eq("Jan 9")
217
+ end
218
+
219
+ it "to be 01-09" do
220
+ expect(datetime.to_format(:day_iso)).to eq("01-09")
221
+ end
222
+ end
223
+
224
+ context "#date" do
225
+ it "to be January 9, 2014" do
226
+ expect(datetime.to_format(:date)).to eq("January 9, 2014")
227
+ end
228
+
229
+ it "to be Jan 9, 2014" do
230
+ expect(datetime.to_format(:date_abbr)).to eq("Jan 9, 2014")
231
+ end
232
+
233
+ it "to be 2014-01-09" do
234
+ expect(datetime.to_format(:date_iso)).to eq("2014-01-09")
235
+ end
236
+ end
237
+
238
+ context "#datetime" do
239
+ it "to be January 9, 2014 00:31" do
240
+ expect(datetime.to_format(:datetime)).to eq("January 9, 2014 00:31")
241
+ end
242
+
243
+ it "to be Jan 9, 2014 00:31" do
244
+ expect(datetime.to_format(:datetime_abbr)).to eq("Jan 9, 2014 00:31")
245
+ end
246
+
247
+ it "to be 2014-01-09 00:31" do
248
+ expect(datetime.to_format(:datetime_iso)).to eq("2014-01-09 00:31")
249
+ end
250
+
251
+ it "to be January 9, 2014 12:31 am" do
252
+ expect(datetime.to_format(:datetime_imperical)).to eq("January 9, 2014 12:31 am")
253
+ end
254
+
255
+ it "to be Jan 9, 2014 12:31 am" do
256
+ expect(datetime.to_format(:datetime_imperical_abbr)).to eq("Jan 9, 2014 12:31 am")
257
+ end
258
+
259
+ it "to be 2014-01-09 12:31 am" do
260
+ expect(datetime.to_format(:datetime_imperical_iso)).to eq("2014-01-09 12:31 am")
261
+ end
262
+
263
+ it "to be January 9, 2014 00:31 UTC" do
264
+ expect(datetime.to_format(:datetime_tzn)).to eq("January 9, 2014 00:31 UTC")
265
+ end
266
+
267
+ it "to be Jan 9, 2014 00:31 UTC" do
268
+ expect(datetime.to_format(:datetime_abbr_tzn)).to eq("Jan 9, 2014 00:31 UTC")
269
+ end
270
+
271
+ it "to be 2014-01-09 00:31 UTC" do
272
+ expect(datetime.to_format(:datetime_iso_tzn)).to eq("2014-01-09 00:31 +0000")
273
+ end
274
+
275
+ it "to be January 9, 2014 12:31 am UTC" do
276
+ expect(datetime.to_format(:datetime_imperical_tzn)).to eq("January 9, 2014 12:31 am UTC")
277
+ end
278
+
279
+ it "to be Jan 9, 2014 12:31 am UTC" do
280
+ expect(datetime.to_format(:datetime_imperical_abbr_tzn)).to eq("Jan 9, 2014 12:31 am UTC")
281
+ end
282
+
283
+ it "to be 2014-01-09 12:31 am UTC" do
284
+ expect(datetime.to_format(:datetime_imperical_iso_tzn)).to eq("2014-01-09 12:31 am +0000")
285
+ end
286
+ end
287
+
288
+ context "#daytime" do
289
+ it "to be January 9 00:31" do
290
+ expect(datetime.to_format(:daytime)).to eq("January 9 00:31")
291
+ end
292
+
293
+ it "to be Jan 9 00:31" do
294
+ expect(datetime.to_format(:daytime_abbr)).to eq("Jan 9 00:31")
295
+ end
296
+
297
+ it "to be 01-09 00:31" do
298
+ expect(datetime.to_format(:daytime_iso)).to eq("01-09 00:31")
299
+ end
300
+
301
+ it "to be January 9 12:31 am" do
302
+ expect(datetime.to_format(:daytime_imperical)).to eq("January 9 12:31 am")
303
+ end
304
+
305
+ it "to be Jan 9 12:31 am" do
306
+ expect(datetime.to_format(:daytime_imperical_abbr)).to eq("Jan 9 12:31 am")
307
+ end
308
+
309
+ it "to be 01-09 12:31 am" do
310
+ expect(datetime.to_format(:daytime_imperical_iso)).to eq("01-09 12:31 am")
311
+ end
312
+ end
313
+
314
+ context "#hour" do
315
+ it "to be 00" do
316
+ expect(datetime.to_format(:hour)).to eq("00")
317
+ expect(datetime.to_format(:hour_zero)).to eq("00")
318
+ end
319
+
320
+ it "to be _0" do
321
+ expect(datetime.to_format(:hour_blank)).to eq(" 0")
322
+ end
323
+
324
+ it "to be 12" do
325
+ expect(datetime.to_format(:hour_imperical)).to eq("12")
326
+ expect(datetime.to_format(:hour_imperical_zero)).to eq("12")
327
+ end
328
+
329
+ it "to be 12" do
330
+ expect(datetime.to_format(:hour_imperical_blank)).to eq("12")
331
+ end
332
+ end
333
+
334
+ context "#meridian" do
335
+ it "to be am" do
336
+ expect(datetime.to_format(:ampm)).to eq("am")
337
+ expect(datetime.to_format(:meridian)).to eq("am")
338
+ end
339
+ end
340
+
341
+ context "#minute" do
342
+ it "to be 31" do
343
+ expect(datetime.to_format(:minute)).to eq("31")
344
+ end
345
+ end
346
+
347
+ context "#month" do
348
+ it "to be 01" do
349
+ expect(datetime.to_format(:month)).to eq("01")
350
+ expect(datetime.to_format(:month_zero)).to eq("01")
351
+ end
352
+
353
+ it "to be 1" do
354
+ expect(datetime.to_format(:month_unpadded)).to eq("1")
355
+ end
356
+
357
+ it "to be _1" do
358
+ expect(datetime.to_format(:month_blank)).to eq(" 1")
359
+ end
360
+
361
+ it "to be January" do
362
+ expect(datetime.to_format(:month_name)).to eq("January")
363
+ end
364
+
365
+ it "to be Jan" do
366
+ expect(datetime.to_format(:month_name_abbr)).to eq("Jan")
367
+ end
368
+ end
369
+
370
+ context "#second" do
371
+ it "to be 58" do
372
+ expect(datetime.to_format(:second)).to eq("58")
373
+ end
374
+ end
375
+
376
+ context "#time" do
377
+ it "to be 00:31" do
378
+ expect(datetime.to_format(:time)).to eq("00:31")
379
+ expect(datetime.to_format(:time_zero)).to eq("00:31")
380
+ end
381
+
382
+ it "to be 00:31 +0000" do
383
+ expect(datetime.to_format(:time_tz)).to eq("00:31 +0000")
384
+ end
385
+
386
+ it "to be 00:31 UTC" do
387
+ expect(datetime.to_format(:time_tzn)).to eq("00:31 UTC")
388
+ end
389
+
390
+ it "to be _0:31" do
391
+ expect(datetime.to_format(:time_blank)).to eq(" 0:31")
392
+ end
393
+
394
+ it "to be 12:31" do
395
+ expect(datetime.to_format(:time_imperical)).to eq("12:31 am")
396
+ expect(datetime.to_format(:time_imperical_zero)).to eq("12:31 am")
397
+ end
398
+
399
+ it "to be 12:31 +0000" do
400
+ expect(datetime.to_format(:time_imperical_tz)).to eq("12:31 am +0000")
401
+ end
402
+
403
+ it "to be 12:31 UTC" do
404
+ expect(datetime.to_format(:time_imperical_tzn)).to eq("12:31 am UTC")
405
+ end
406
+
407
+ it "to be 12:31" do
408
+ expect(datetime.to_format(:time_imperical_blank)).to eq("12:31 am")
409
+ end
410
+ end
411
+
412
+ context "#time zone" do
413
+ it "to be +0000" do
414
+ expect(datetime.to_format(:time_zone)).to eq("+0000")
415
+ end
416
+
417
+ it "to be +00:00" do
418
+ expect(datetime.to_format(:time_zone_offset)).to eq("+00:00")
419
+ end
420
+
421
+ it "to be +00:00:00" do
422
+ expect(datetime.to_format(:time_zone_offset_full)).to eq("+00:00:00")
423
+ end
424
+
425
+ it "to be UTC" do
426
+ expect(datetime.to_format(:time_zone_name)).to eq("UTC")
427
+ end
428
+ end
429
+
430
+ context "#weekday" do
431
+ it "to be 09" do
432
+ expect(datetime.to_format(:weekday)).to eq("09")
433
+ expect(datetime.to_format(:weekday_zero)).to eq("09")
434
+ end
435
+
436
+ it "to be 9" do
437
+ expect(datetime.to_format(:weekday_unpadded)).to eq("9")
438
+ end
439
+
440
+ it "to be _9" do
441
+ expect(datetime.to_format(:weekday_blank)).to eq(" 9")
442
+ end
443
+
444
+ it "to be Thursday" do
445
+ expect(datetime.to_format(:weekday_name)).to eq("Thursday")
446
+ end
447
+
448
+ it "to be Thu" do
449
+ expect(datetime.to_format(:weekday_name_abbr)).to eq("Thu")
450
+ end
451
+ end
452
+
453
+ context "#year" do
454
+ it "to be 14" do
455
+ expect(datetime.to_format(:yr)).to eq("14")
456
+ end
457
+
458
+ it "to be 2014" do
459
+ expect(datetime.to_format(:year)).to eq("2014")
460
+ end
461
+ end
462
+
463
+ context "no key" do
464
+ it "to be 2014-01-09 00:31 +0000" do
465
+ expect(datetime.to_format).to eq("2014-01-09 00:31 +0000")
466
+ end
467
+ end
468
+ end
469
+ end