lazier 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.gitignore +6 -0
  2. data/.travis.yml +8 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +9 -0
  5. data/Gemfile.lock +82 -0
  6. data/README.md +33 -0
  7. data/Rakefile +18 -0
  8. data/doc/Lazier.html +557 -0
  9. data/doc/Lazier/Boolean.html +297 -0
  10. data/doc/Lazier/DateTime.html +787 -0
  11. data/doc/Lazier/DateTime/ClassMethods.html +1592 -0
  12. data/doc/Lazier/Exceptions.html +125 -0
  13. data/doc/Lazier/Exceptions/Dump.html +133 -0
  14. data/doc/Lazier/Hash.html +393 -0
  15. data/doc/Lazier/Math.html +130 -0
  16. data/doc/Lazier/Math/ClassMethods.html +362 -0
  17. data/doc/Lazier/Object.html +1565 -0
  18. data/doc/Lazier/Pathname.html +225 -0
  19. data/doc/Lazier/Settings.html +1249 -0
  20. data/doc/Lazier/String.html +471 -0
  21. data/doc/Lazier/TimeZone.html +1675 -0
  22. data/doc/Lazier/TimeZone/ClassMethods.html +1055 -0
  23. data/doc/Lazier/Version.html +189 -0
  24. data/doc/_index.html +306 -0
  25. data/doc/class_list.html +53 -0
  26. data/doc/css/common.css +1 -0
  27. data/doc/css/full_list.css +57 -0
  28. data/doc/css/style.css +328 -0
  29. data/doc/file.README.html +107 -0
  30. data/doc/file_list.html +55 -0
  31. data/doc/frames.html +28 -0
  32. data/doc/index.html +107 -0
  33. data/doc/js/app.js +214 -0
  34. data/doc/js/full_list.js +173 -0
  35. data/doc/js/jquery.js +4 -0
  36. data/doc/method_list.html +652 -0
  37. data/doc/top-level-namespace.html +112 -0
  38. data/lazier.gemspec +36 -0
  39. data/lib/lazier.rb +127 -0
  40. data/lib/lazier/boolean.rb +26 -0
  41. data/lib/lazier/datetime.rb +548 -0
  42. data/lib/lazier/exceptions.rb +14 -0
  43. data/lib/lazier/hash.rb +40 -0
  44. data/lib/lazier/math.rb +47 -0
  45. data/lib/lazier/object.rb +163 -0
  46. data/lib/lazier/pathname.rb +26 -0
  47. data/lib/lazier/settings.rb +118 -0
  48. data/lib/lazier/string.rb +54 -0
  49. data/lib/lazier/version.rb +24 -0
  50. data/spec/coverage_helper.rb +19 -0
  51. data/spec/cowtech-extensions/boolean_spec.rb +30 -0
  52. data/spec/cowtech-extensions/datetime_spec.rb +352 -0
  53. data/spec/cowtech-extensions/hash_spec.rb +30 -0
  54. data/spec/cowtech-extensions/math_spec.rb +41 -0
  55. data/spec/cowtech-extensions/object_spec.rb +231 -0
  56. data/spec/cowtech-extensions/pathname_spec.rb +21 -0
  57. data/spec/cowtech-extensions/settings_spec.rb +118 -0
  58. data/spec/cowtech-extensions/string_spec.rb +45 -0
  59. data/spec/lazier_spec.rb +57 -0
  60. data/spec/spec_helper.rb +16 -0
  61. metadata +292 -0
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the lazier gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ module Lazier
8
+ # The current version of lazier, according to semantic versioning.
9
+ #
10
+ # @see http://semver.org
11
+ module Version
12
+ # The major version.
13
+ MAJOR = 1
14
+
15
+ # The minor version.
16
+ MINOR = 0
17
+
18
+ # The patch version.
19
+ PATCH = 0
20
+
21
+ # The current version of lazier.
22
+ STRING = [MAJOR, MINOR, PATCH].compact.join(".")
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the lazier gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "simplecov"
8
+ require "pathname"
9
+
10
+ if ENV["COWTECH_EXTENSIONS_COVERAGE"] == "TRUE" then
11
+ root = Pathname.new(File.dirname(__FILE__)) + ".."
12
+
13
+ SimpleCov.start do
14
+ add_filter do |src_file|
15
+ path = Pathname.new(src_file.filename).relative_path_from(root).to_s
16
+ path !~ /^lib/
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the lazier gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "spec_helper"
8
+
9
+ describe Lazier::Boolean do
10
+ before(:all) do
11
+ ::Lazier.load!
12
+ end
13
+
14
+ describe "#to_i" do
15
+ it "should return 1 for true" do
16
+ expect(true.to_i).to eq(1)
17
+ end
18
+
19
+ it "should return 0 for false" do
20
+ expect(false.to_i).to eq(0)
21
+ end
22
+ end
23
+
24
+ describe "#value" do
25
+ it "should return self" do
26
+ expect(true.value).to be_true
27
+ expect(false.value).to be_false
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,352 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the lazier gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "spec_helper"
8
+
9
+ describe Lazier::DateTime do
10
+ let(:random_reference) { ::DateTime.civil(1990 + rand(30), 1 + rand(10), 1 + rand(25), 1 + rand(20), 1 + rand(58), 1 + rand(58)).in_time_zone }
11
+ let(:fixed_reference){ ::DateTime.civil(2005, 6, 7, 8, 9, 10, ::DateTime.rationalize_offset(25200)) }
12
+ let(:reference_zone) { ::ActiveSupport::TimeZone["Mountain Time (US & Canada)"] }
13
+ let(:zone_without_dst) { ::ActiveSupport::TimeZone["International Date Line West"] }
14
+
15
+ before(:all) do
16
+ ::Lazier.load!
17
+ end
18
+
19
+ describe ".days" do
20
+ it "should return the list of the days of the week" do
21
+ expect(::DateTime.days).to be_kind_of(::Array)
22
+ expect(::DateTime.days[3]).to eq({:value => "4", :label => "Wed"})
23
+ expect(::DateTime.days(false)).to be_kind_of(::Array)
24
+ expect(::DateTime.days(false)[3]).to eq({:value => "4", :label => "Wednesday"})
25
+
26
+ ::Lazier.settings.setup_date_names(nil, nil, 7.times.collect {|i| (i + 1).to_s * 2}, 7.times.collect {|i| (i + 1).to_s})
27
+ expect(::DateTime.days).to be_kind_of(::Array)
28
+ expect(::DateTime.days[3]).to eq({:value => "4", :label => "4"})
29
+ expect(::DateTime.days(false)).to be_kind_of(::Array)
30
+ expect(::DateTime.days(false)[3]).to eq({:value => "4", :label => "44"})
31
+ end
32
+ end
33
+
34
+ describe ".months" do
35
+ it "should return the list of the months of the year" do
36
+ expect(::DateTime.months).to be_kind_of(::Array)
37
+ expect(::DateTime.months[6]).to eq({:value => "07", :label => "Jul"})
38
+ expect(::DateTime.months(false)).to be_kind_of(::Array)
39
+ expect(::DateTime.months(false)[6]).to eq({:value => "07", :label => "July"})
40
+
41
+ ::Lazier.settings.setup_date_names(12.times.collect {|i| (i + 1).to_s * 2}, 12.times.collect {|i| (i + 1).to_s}, nil, nil)
42
+ expect(::DateTime.months).to be_kind_of(::Array)
43
+ expect(::DateTime.months[6]).to eq({:value => "07", :label => "7"})
44
+ expect(::DateTime.months(false)).to be_kind_of(::Array)
45
+ expect(::DateTime.months(false)[6]).to eq({:value => "07", :label => "77"})
46
+ end
47
+
48
+ end
49
+
50
+ describe ".years" do
51
+ it "should return a range of years" do
52
+ expect(::DateTime.years).to eq((::Date.today.year - 10..::Date.today.year + 10).to_a)
53
+ expect(::DateTime.years(5)).to eq((::Date.today.year - 5..::Date.today.year + 5).to_a)
54
+ expect(::DateTime.years(5, true, nil, true).collect(&:value)).to eq((::Date.today.year - 5..::Date.today.year + 5).to_a)
55
+ expect(::DateTime.years(5, false)).to eq((::Date.today.year - 5..::Date.today.year).to_a)
56
+ expect(::DateTime.years(5, false, 1900)).to eq((1895..1900).to_a)
57
+ end
58
+ end
59
+
60
+ describe ".timezones" do
61
+ it "should list all timezones" do
62
+ expect(::DateTime.timezones).to eq(::ActiveSupport::TimeZone.all)
63
+ end
64
+ end
65
+
66
+ describe ".list_timezones" do
67
+ it "should forward to ActiveSupport::TimeZone" do
68
+ ::ActiveSupport::TimeZone.should_receive(:list_all)
69
+ ::DateTime.list_timezones
70
+ end
71
+ end
72
+
73
+ describe ".find_timezone" do
74
+ it "should forward to ActiveSupport::TimeZone" do
75
+ ::ActiveSupport::TimeZone.should_receive(:find)
76
+ ::DateTime.find_timezone(reference_zone.name)
77
+ end
78
+ end
79
+
80
+ describe ".rationalize_offset" do
81
+ it "should return the correct rational value" do
82
+ ::ActiveSupport::TimeZone.should_receive(:rationalize_offset)
83
+ ::DateTime.rationalize_offset(0)
84
+ end
85
+ end
86
+
87
+ describe ".parameterize_zone" do
88
+ it "should forward to ActiveSupport::TimeZone" do
89
+ ::ActiveSupport::TimeZone.should_receive(:parameterize_zone)
90
+ ::DateTime.parameterize_zone(reference_zone)
91
+ end
92
+ end
93
+
94
+ describe ".unparameterize_zone" do
95
+ it "should forward to ActiveSupport::TimeZone" do
96
+ ::ActiveSupport::TimeZone.should_receive(:unparameterize_zone)
97
+ ::DateTime.unparameterize_zone(reference_zone)
98
+ end
99
+ end
100
+
101
+ describe ".easter" do
102
+ it "should compute the valid Easter day" do
103
+ {1984 => "0422", 1995 => "0416", 2006 => "0416", 2017 => "0416"}.each do |year, date|
104
+ expect(::DateTime.easter(year).strftime("%Y%m%d")).to eq("#{year}#{date}")
105
+ end
106
+ end
107
+ end
108
+
109
+ describe ".custom_format" do
110
+ it "should find the format" do
111
+ expect(::DateTime.custom_format(:ct_date)).to eq("%Y-%m-%d")
112
+ expect(::DateTime.custom_format("ct_date")).to eq("%Y-%m-%d")
113
+
114
+ ::Lazier.settings.setup_date_formats({:ct_foo => "%ABC"})
115
+
116
+ expect(::DateTime.custom_format(:ct_foo)).to eq("%ABC")
117
+ expect(::DateTime.custom_format("ct_foo")).to eq("%ABC")
118
+ end
119
+
120
+ it "should return the key if format is not found" do
121
+ ::DateTime.custom_format(:ct_unused) == "ct_unused"
122
+ end
123
+ end
124
+
125
+ describe ".is_valid?" do
126
+ it "should recognize a valid date" do
127
+ expect(::DateTime.is_valid?("2012-04-05", "%F")).to be_true
128
+ expect(::DateTime.is_valid?("2012-04-05", :ct_date)).to be_true
129
+ end
130
+
131
+ it "should fail if the argument or the format is not valid" do
132
+ expect(::DateTime.is_valid?("ABC", "%F")).to be_false
133
+ expect(::DateTime.is_valid?("2012-04-05", "%X")).to be_false
134
+ end
135
+ end
136
+
137
+ describe "#utc_time" do
138
+ it "should convert to UTC Time" do
139
+ expect(random_reference.utc_time).to be_a(::Time)
140
+ end
141
+ end
142
+
143
+ describe "#in_months" do
144
+ it "should return the amount of months passed since the start of the reference year" do
145
+ expect(::Date.today.in_months).to eq(::Date.today.month)
146
+ expect(fixed_reference.in_months(2000)).to eq(66)
147
+ end
148
+ end
149
+
150
+ describe "#padded_month" do
151
+ it "should pad the month number" do
152
+ expect(random_reference.padded_month).to eq(random_reference.month.to_s.rjust(2, "0"))
153
+ expect(::Date.civil(2000, 8, 8).padded_month).to eq("08")
154
+ end
155
+ end
156
+
157
+ describe "#lstrftime" do
158
+ it "should return corrected formatted string" do
159
+ expect(fixed_reference.lstrftime(:db)).to eq("db")
160
+ expect(fixed_reference.lstrftime("%F")).to eq("2005-06-07")
161
+ expect(fixed_reference.lstrftime(:ct_iso_8601)).to eq("2005-06-07T08:09:10+0700")
162
+
163
+ ::Lazier.settings.setup_date_names
164
+ ::Lazier.settings.setup_date_formats({:ct_local_test => "%a %A %b %B %d %Y %H"})
165
+ expect(fixed_reference.lstrftime(:ct_local_test)).to eq("Tue Tuesday Jun June 07 2005 08")
166
+
167
+ ::Lazier.settings.setup_date_names(
168
+ 12.times.collect {|i| (i + 1).to_s * 2}, 12.times.collect {|i| (i + 1).to_s},
169
+ 7.times.collect {|i| (i + 1).to_s * 2}, 7.times.collect {|i| (i + 1).to_s}
170
+ )
171
+
172
+ expect(fixed_reference.lstrftime(:ct_local_test)).to eq("3 33 6 66 07 2005 08")
173
+ end
174
+
175
+ it "should fix Ruby 1.8 %z and %Z bug" do
176
+ original_ruby_version = RUBY_VERSION
177
+ ::Kernel::silence_warnings { Object.const_set("RUBY_VERSION", "1.9.3") }
178
+ expect(fixed_reference.lstrftime("%z")).to eq("+0700")
179
+ expect(fixed_reference.lstrftime("%:z")).to eq("+07:00")
180
+ ::Kernel::silence_warnings { Object.const_set("RUBY_VERSION", original_ruby_version) }
181
+ end
182
+ end
183
+
184
+ describe "#local_strftime" do
185
+ it "should retrieve the date in the current timezone" do
186
+ ::Time.zone = ::ActiveSupport::TimeZone[0]
187
+ ::Lazier.settings.setup_date_formats({:ct_local_test => "%a %A %b %B %d %Y %H"})
188
+ expect(fixed_reference.local_strftime(:ct_local_test)).to eq("Tue Tuesday Jun June 07 2005 01")
189
+ end
190
+ end
191
+
192
+ describe "#local_lstrftime" do
193
+ it "should retrieve the date in the current timezone" do
194
+ ::Time.zone = ::ActiveSupport::TimeZone[0]
195
+
196
+ ::Lazier.settings.setup_date_names
197
+ ::Lazier.settings.setup_date_formats({:ct_local_test => "%a %A %b %B %d %Y %H"})
198
+
199
+ ::Lazier.settings.setup_date_names(
200
+ 12.times.collect {|i| (i + 1).to_s * 2}, 12.times.collect {|i| (i + 1).to_s},
201
+ 7.times.collect {|i| (i + 1).to_s * 2}, 7.times.collect {|i| (i + 1).to_s}
202
+ )
203
+
204
+ expect(fixed_reference.local_lstrftime(:ct_local_test)).to eq("3 33 6 66 07 2005 01")
205
+ end
206
+ end
207
+ end
208
+
209
+ describe Lazier::TimeZone do
210
+ let(:reference_zone) { ::ActiveSupport::TimeZone["Mountain Time (US & Canada)"] }
211
+ let(:zone_without_dst) { ::ActiveSupport::TimeZone["International Date Line West"] }
212
+
213
+ before(:all) do
214
+ ::Lazier.load!
215
+ end
216
+
217
+ describe ".rationalize_offset" do
218
+ it "should return the correct rational value" do
219
+ expect(::ActiveSupport::TimeZone.rationalize_offset(::ActiveSupport::TimeZone[4])).to eq(Rational(1, 6))
220
+ expect(::ActiveSupport::TimeZone.rationalize_offset(-25200)).to eq(Rational(-7, 24))
221
+ end
222
+ end
223
+
224
+ describe ".format_offset" do
225
+ it "should correctly format an offset" do
226
+ expect(::ActiveSupport::TimeZone.format_offset(-25200)).to eq("-07:00")
227
+ expect(::ActiveSupport::TimeZone.format_offset(Rational(-4, 24), false)).to eq("-0400")
228
+ end
229
+ end
230
+
231
+ describe ".parameterize_zone" do
232
+ it "should return the parameterized version of the zone" do
233
+ expect(::ActiveSupport::TimeZone.parameterize_zone(reference_zone.to_str)).to eq(reference_zone.to_str_parameterized)
234
+ expect(::ActiveSupport::TimeZone.parameterize_zone(reference_zone.to_str)).to eq(reference_zone.to_str_parameterized)
235
+ expect(::ActiveSupport::TimeZone.parameterize_zone(reference_zone.to_str, false)).to eq(reference_zone.to_str_parameterized(false))
236
+ expect(::ActiveSupport::TimeZone.parameterize_zone("INVALID")).to eq("invalid")
237
+ end
238
+ end
239
+
240
+ describe ".unparameterize_zone" do
241
+ it "should return the parameterized version of the zone" do
242
+ expect(::ActiveSupport::TimeZone.unparameterize_zone(reference_zone.to_str_parameterized)).to eq(reference_zone)
243
+ expect(::ActiveSupport::TimeZone.unparameterize_zone(reference_zone.to_str_parameterized, true)).to eq(reference_zone.to_str)
244
+ expect(::ActiveSupport::TimeZone.unparameterize_zone(reference_zone.to_str_with_dst_parameterized)).to eq(reference_zone)
245
+ expect(::ActiveSupport::TimeZone.unparameterize_zone(reference_zone.to_str_with_dst_parameterized, true)).to eq(reference_zone.to_str_with_dst)
246
+ expect(::ActiveSupport::TimeZone.unparameterize_zone("INVALID")).to eq(nil)
247
+ end
248
+ end
249
+
250
+ describe ".find" do
251
+ it "should find timezones" do
252
+ expect(::ActiveSupport::TimeZone.find("(GMT-07:00) Mountain Time (US & Canada)")).to eq(reference_zone)
253
+ expect(::ActiveSupport::TimeZone.find("(GMT-06:00) Mountain Time (US & Canada) (DST)")).to eq(reference_zone)
254
+ expect(::ActiveSupport::TimeZone.find("(GMT-06:00) Mountain Time (US & Canada) Daylight Saving Time", "Daylight Saving Time")).to eq(reference_zone)
255
+ expect(::ActiveSupport::TimeZone.find("INVALID", "INVALID")).to be_nil
256
+ end
257
+ end
258
+
259
+ describe ".list_all" do
260
+ it "should list all timezones" do
261
+ expect(::ActiveSupport::TimeZone.list_all(false)).to eq(::ActiveSupport::TimeZone.all.collect(&:to_s))
262
+ expect(::ActiveSupport::TimeZone.list_all(true)).to include("(GMT-06:00) #{reference_zone.aliases.first} (DST)")
263
+ expect(::ActiveSupport::TimeZone.list_all(true, "Daylight Saving Time")).to include("(GMT-06:00) #{reference_zone.aliases.first} Daylight Saving Time")
264
+ end
265
+ end
266
+
267
+ describe "#offset" do
268
+ it "should correctly return zone offset" do
269
+ expect(reference_zone.offset).to eq(reference_zone.utc_offset)
270
+ end
271
+ end
272
+
273
+ describe "#current_offset" do
274
+ it "should correctly return current zone offset" do
275
+ expect(reference_zone.current_offset(false, ::DateTime.civil(2012, 1, 15))).to eq(reference_zone.offset)
276
+ expect(reference_zone.current_offset(true, ::DateTime.civil(2012, 7, 15))).to eq(reference_zone.dst_offset(true))
277
+ end
278
+ end
279
+
280
+ describe "#dst_period" do
281
+ it "should correctly return zone offset" do
282
+ expect(reference_zone.dst_period).to be_a(::TZInfo::TimezonePeriod)
283
+ expect(reference_zone.dst_period(1000)).to be_nil
284
+ expect(zone_without_dst.dst_period).to be_nil
285
+ end
286
+ end
287
+
288
+ describe "#uses_dst?" do
289
+ it "should correctly detect offset usage" do
290
+ expect(reference_zone.uses_dst?).to be_true
291
+ expect(reference_zone.uses_dst?(DateTime.civil(2012, 7, 15))).to be_true
292
+ expect(reference_zone.uses_dst?(DateTime.civil(2012, 1, 15))).to be_false
293
+ expect(reference_zone.uses_dst?(1000)).to be_false
294
+ expect(zone_without_dst.uses_dst?).to be_false
295
+ end
296
+ end
297
+
298
+ describe "#dst_name" do
299
+ it "should correctly get zone name with Daylight Saving Time" do
300
+ expect(reference_zone.dst_name).to eq("Mountain Time (US & Canada) (DST)")
301
+ expect(reference_zone.dst_name("Daylight Saving Time")).to eq("Mountain Time (US & Canada) Daylight Saving Time")
302
+ expect(reference_zone.dst_name(nil, 1000)).to be_nil
303
+ expect(zone_without_dst.to_str_with_dst).to be_nil
304
+ end
305
+ end
306
+
307
+ describe "#dst_correction" do
308
+ it "should correctly detect offset usage" do
309
+ expect(reference_zone.dst_correction).to eq(3600)
310
+ expect(reference_zone.dst_correction(true)).to eq(Rational(1, 24))
311
+ expect(reference_zone.dst_correction(false, 1000)).to eq(0)
312
+ expect(zone_without_dst.dst_correction).to eq(0)
313
+ end
314
+ end
315
+
316
+ describe "#dst_offset" do
317
+ it "should correctly return zone offset" do
318
+ expect(reference_zone.dst_offset).to eq(reference_zone.dst_correction + reference_zone.utc_offset)
319
+ expect(reference_zone.dst_offset(true)).to eq(::ActiveSupport::TimeZone.rationalize_offset(reference_zone.dst_correction + reference_zone.utc_offset))
320
+ expect(zone_without_dst.dst_offset(false, 1000)).to eq(0)
321
+ expect(zone_without_dst.dst_offset).to eq(0)
322
+ end
323
+ end
324
+
325
+ describe "#to_str_with_dst" do
326
+ it "should correctly format zone with Daylight Saving Time" do
327
+ expect(reference_zone.to_str_with_dst).to eq("(GMT-06:00) #{reference_zone.aliases.first} (DST)")
328
+ expect(reference_zone.to_str_with_dst("Daylight Saving Time")).to eq("(GMT-06:00) #{reference_zone.aliases.first} Daylight Saving Time")
329
+ expect(reference_zone.to_str_with_dst("Daylight Saving Time", nil, "NAME")).to eq("(GMT-06:00) NAME Daylight Saving Time")
330
+ expect(reference_zone.to_str_with_dst(nil, 1000)).to be_nil
331
+ expect(zone_without_dst.to_str_with_dst).to be_nil
332
+ end
333
+ end
334
+
335
+ describe "#to_str_parameterized" do
336
+ it "should correctly format (parameterized) zone" do
337
+ expect(reference_zone.to_str_parameterized).to eq(::ActiveSupport::TimeZone.parameterize_zone(reference_zone.to_str))
338
+ expect(reference_zone.to_str_parameterized(false)).to eq(::ActiveSupport::TimeZone.parameterize_zone(reference_zone.to_str, false))
339
+ expect(reference_zone.to_str_parameterized(false, "NAME SPACE")).to eq(::ActiveSupport::TimeZone.parameterize_zone("NAME SPACE", false))
340
+ end
341
+ end
342
+
343
+ describe "#to_str_with_dst_parameterized" do
344
+ it "should correctly format (parameterized) zone with Daylight Saving Time" do
345
+ expect(reference_zone.to_str_with_dst_parameterized).to eq("-0600@america-denver-dst")
346
+ expect(reference_zone.to_str_with_dst_parameterized("Daylight Saving Time")).to eq("-0600@america-denver-daylight-saving-time")
347
+ expect(reference_zone.to_str_with_dst_parameterized(nil, false, 1000)).to be_nil
348
+ expect(reference_zone.to_str_with_dst_parameterized("Daylight Saving Time", true, nil, "NAME SPACE")).to eq("-0600@name-space-daylight-saving-time")
349
+ expect(zone_without_dst.to_str_with_dst_parameterized).to be_nil
350
+ end
351
+ end
352
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the lazier gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "spec_helper"
8
+
9
+ describe Lazier::Hash do
10
+ let(:reference) {
11
+ rv = {:a => 1, "b" => 2}
12
+ rv.default = 0
13
+ rv
14
+ }
15
+
16
+ before(:all) do
17
+ ::Lazier.load!
18
+ end
19
+
20
+ describe "allows access to keys using method syntax" do
21
+ it "should allow method reference for symbol key" do expect(reference.b).to eq(2) end
22
+ it "should use super for missing key" do expect {reference.c}.to raise_error(NoMethodError) end
23
+ end
24
+
25
+ describe "#respond_to" do
26
+ it "should return true for string key" do expect(reference.respond_to?(:a)).to be_true end
27
+ it "should return true for symbol key" do expect(reference.respond_to?(:b)).to be_true end
28
+ it "should return false for missing key" do expect(reference.respond_to?(:c)).to be_false end
29
+ end
30
+ end