cowtech-extensions 2.7.1 → 2.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +4 -2
- data/README.md +4 -1
- data/doc/Cowtech.html +2 -2
- data/doc/Cowtech/Extensions.html +96 -93
- data/doc/Cowtech/Extensions/Boolean.html +10 -8
- data/doc/Cowtech/Extensions/DateTime.html +58 -52
- data/doc/Cowtech/Extensions/DateTime/ClassMethods.html +91 -79
- data/doc/Cowtech/Extensions/Exceptions.html +2 -2
- data/doc/Cowtech/Extensions/Exceptions/Dump.html +2 -2
- data/doc/Cowtech/Extensions/Hash.html +20 -18
- data/doc/Cowtech/Extensions/Math.html +2 -2
- data/doc/Cowtech/Extensions/Math/ClassMethods.html +24 -22
- data/doc/Cowtech/Extensions/Object.html +95 -81
- data/doc/Cowtech/Extensions/Pathname.html +11 -10
- data/doc/Cowtech/Extensions/Settings.html +80 -70
- data/doc/Cowtech/Extensions/String.html +26 -22
- data/doc/Cowtech/Extensions/TimeZone.html +98 -86
- data/doc/Cowtech/Extensions/TimeZone/ClassMethods.html +79 -72
- data/doc/Cowtech/Extensions/Version.html +11 -7
- data/doc/_index.html +2 -2
- data/doc/file.README.html +9 -6
- data/doc/index.html +9 -6
- data/doc/top-level-namespace.html +2 -2
- data/lib/cowtech-extensions.rb +2 -1
- data/lib/cowtech-extensions/version.rb +2 -2
- data/spec/cowtech-extensions/boolean_spec.rb +9 -4
- data/spec/cowtech-extensions/datetime_spec.rb +106 -100
- data/spec/cowtech-extensions/hash_spec.rb +4 -4
- data/spec/cowtech-extensions/math_spec.rb +8 -8
- data/spec/cowtech-extensions/object_spec.rb +115 -103
- data/spec/cowtech-extensions/pathname_spec.rb +3 -1
- data/spec/cowtech-extensions/settings_spec.rb +30 -30
- data/spec/cowtech-extensions/string_spec.rb +13 -7
- data/spec/cowtech-extensions_spec.rb +21 -11
- data/spec/spec_helper.rb +7 -1
- metadata +4 -4
@@ -18,13 +18,13 @@ describe Cowtech::Extensions::Hash do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "allows access to keys using method syntax" do
|
21
|
-
it "should allow method reference for symbol key" do reference.b.
|
21
|
+
it "should allow method reference for symbol key" do expect(reference.b).to eq(2) end
|
22
22
|
it "should use super for missing key" do expect {reference.c}.to raise_error(NoMethodError) end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#respond_to" do
|
26
|
-
it "should return true for string key" do reference.respond_to?(:a).
|
27
|
-
it "should return true for symbol key" do reference.respond_to?(:b).
|
28
|
-
it "should return false for missing key" do reference.respond_to?(:c).
|
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
29
|
end
|
30
30
|
end
|
@@ -17,25 +17,25 @@ describe Cowtech::Extensions::Math do
|
|
17
17
|
|
18
18
|
describe "::min" do
|
19
19
|
it "should return the minimum argument" do
|
20
|
-
::Math.min(first).
|
21
|
-
::Math.min(first, second).
|
22
|
-
::Math.min([first, [second, third]]).
|
20
|
+
expect(::Math.min(first)).to eq(first)
|
21
|
+
expect(::Math.min(first, second)).to eq(first)
|
22
|
+
expect(::Math.min([first, [second, third]])).to eq(third)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should return nil for an empty array" do
|
26
|
-
::Math.min().
|
26
|
+
expect(::Math.min()).to be_nil
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "::max" do
|
31
31
|
it "should return the maximum argument" do
|
32
|
-
::Math.max(first).
|
33
|
-
::Math.max(first, second).
|
34
|
-
::Math.max([first, [second, third]]).
|
32
|
+
expect(::Math.max(first)).to eq(first)
|
33
|
+
expect(::Math.max(first, second)).to eq(second)
|
34
|
+
expect(::Math.max([first, [second, third]])).to eq(second)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should return nil for an empty array" do
|
38
|
-
::Math.max().
|
38
|
+
expect(::Math.max()).to be_nil
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -13,207 +13,219 @@ describe Cowtech::Extensions::Object do
|
|
13
13
|
|
14
14
|
describe "#normalize_number" do
|
15
15
|
it "should correctly sanitize numbers" do
|
16
|
-
123.normalize_number.
|
17
|
-
"123.45".normalize_number.
|
18
|
-
"1,23.45".normalize_number.
|
19
|
-
"-1.23.45".normalize_number.
|
20
|
-
"+123.45".normalize_number.
|
21
|
-
"+1.231,45".normalize_number.
|
16
|
+
expect(123.normalize_number).to eq("123")
|
17
|
+
expect("123.45".normalize_number).to eq("123.45")
|
18
|
+
expect("1,23.45".normalize_number).to eq("123.45")
|
19
|
+
expect("-1.23.45".normalize_number).to eq("-123.45")
|
20
|
+
expect("+123.45".normalize_number).to eq("+123.45")
|
21
|
+
expect("+1.231,45".normalize_number).to eq("+1231.45")
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#is_number?" do
|
26
26
|
it "should return true for a valid number" do
|
27
|
-
"123.45".is_number
|
28
|
-
"1,23.45".is_number
|
29
|
-
"-1.23.45".is_number
|
30
|
-
"+123.45".is_number
|
31
|
-
"+1.231,45".is_number
|
27
|
+
expect("123.45".is_number?).to be_true
|
28
|
+
expect("1,23.45".is_number?).to be_true
|
29
|
+
expect("-1.23.45".is_number?).to be_true
|
30
|
+
expect("+123.45".is_number?).to be_true
|
31
|
+
expect("+1.231,45".is_number?).to be_true
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should return true for a invalid number" do
|
35
|
-
"s213".is_number
|
36
|
-
nil.is_number
|
35
|
+
expect("s213".is_number?).to be_false
|
36
|
+
expect(nil.is_number?).to be_false
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "#is_integer?" do
|
41
41
|
it "should return true for a valid number" do
|
42
|
-
"123".is_integer
|
43
|
-
"-123".is_integer
|
44
|
-
"+123".is_integer
|
42
|
+
expect("123".is_integer?).to be_true
|
43
|
+
expect("-123".is_integer?).to be_true
|
44
|
+
expect("+123".is_integer?).to be_true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should return true for a invalid number" do
|
48
|
-
"s123".is_integer
|
49
|
-
"123.12".is_integer
|
48
|
+
expect("s123".is_integer?).to be_false
|
49
|
+
expect("123.12".is_integer?).to be_false
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "#is_float?" do
|
54
54
|
it "should return true for a valid number" do
|
55
|
-
"123.45".is_float
|
56
|
-
"1,23.45".is_float
|
57
|
-
"-1.23.45".is_float
|
58
|
-
"+123.45".is_float
|
59
|
-
"+1.231,45".is_float
|
55
|
+
expect("123.45".is_float?).to be_true
|
56
|
+
expect("1,23.45".is_float?).to be_true
|
57
|
+
expect("-1.23.45".is_float?).to be_true
|
58
|
+
expect("+123.45".is_float?).to be_true
|
59
|
+
expect("+1.231,45".is_float?).to be_true
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should return true for a invalid number" do
|
63
|
-
"s213".is_float
|
64
|
-
nil.is_float
|
63
|
+
expect("s213".is_float?).to be_false
|
64
|
+
expect(nil.is_float?).to be_false
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
describe "#is_boolean?" do
|
69
69
|
it "should return true for a valid boolean" do
|
70
|
-
true.is_boolean
|
71
|
-
false.is_boolean
|
72
|
-
nil.is_boolean
|
73
|
-
"y".is_boolean
|
74
|
-
"n".is_boolean
|
75
|
-
"yes".is_boolean
|
76
|
-
"no".is_boolean
|
77
|
-
"1".is_boolean
|
78
|
-
"0".is_boolean
|
79
|
-
"true".is_boolean
|
80
|
-
"false".is_boolean
|
81
|
-
"t".is_boolean
|
82
|
-
"f".is_boolean
|
83
|
-
1.is_boolean
|
84
|
-
0.is_boolean
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should return true for a invalid boolean" do
|
70
|
+
expect(true.is_boolean?).to be_true
|
71
|
+
expect(false.is_boolean?).to be_true
|
72
|
+
expect(nil.is_boolean?).to be_true
|
73
|
+
expect("y".is_boolean?).to be_true
|
74
|
+
expect("n".is_boolean?).to be_true
|
75
|
+
expect("yes".is_boolean?).to be_true
|
76
|
+
expect("no".is_boolean?).to be_true
|
77
|
+
expect("1".is_boolean?).to be_true
|
78
|
+
expect("0".is_boolean?).to be_true
|
79
|
+
expect("true".is_boolean?).to be_true
|
80
|
+
expect("false".is_boolean?).to be_true
|
81
|
+
expect("t".is_boolean?).to be_true
|
82
|
+
expect("f".is_boolean?).to be_true
|
83
|
+
expect(1.is_boolean?).to be_true
|
84
|
+
expect(0.is_boolean?).to be_true
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return true for a invalid boolean" do
|
88
|
+
expect("11".is_boolean?).to be_false
|
89
|
+
end
|
88
90
|
end
|
89
91
|
|
90
92
|
describe "#ensure_string" do
|
91
93
|
it "should correctly handle strings" do
|
92
|
-
" abc ".ensure_string.
|
94
|
+
expect(" abc ".ensure_string).to eq(" abc ")
|
93
95
|
1.ensure_string == "1"
|
94
|
-
1.0.ensure_string.
|
95
|
-
:abc.ensure_string.
|
96
|
-
nil.ensure_string.
|
96
|
+
expect(1.0.ensure_string).to eq("1.0")
|
97
|
+
expect(:abc.ensure_string).to eq("abc")
|
98
|
+
expect(nil.ensure_string).to eq("")
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
100
102
|
describe "#to_float" do
|
101
103
|
it "should correctly convert number" do
|
102
|
-
123.45.to_float.
|
103
|
-
123.to_float.
|
104
|
-
"123.45".to_float.
|
105
|
-
"1,23.45".to_float.
|
106
|
-
"-1.23.45".to_float.
|
107
|
-
"+123.45".to_float.
|
108
|
-
"+1.231,45".to_float.
|
104
|
+
expect(123.45.to_float).to eq(123.45)
|
105
|
+
expect(123.to_float).to eq(123.00)
|
106
|
+
expect("123.45".to_float).to eq(123.45)
|
107
|
+
expect("1,23.45".to_float).to eq(123.45)
|
108
|
+
expect("-1.23.45".to_float).to eq(-123.45)
|
109
|
+
expect("+123.45".to_float).to eq(123.45)
|
110
|
+
expect("+1.231,45".to_float).to eq(1231.45)
|
109
111
|
end
|
110
112
|
|
111
|
-
it "should return 0.0 for a invalid number without a default" do
|
113
|
+
it "should return 0.0 for a invalid number without a default" do
|
114
|
+
expect("s213".to_float).to eq(0.0)
|
115
|
+
end
|
112
116
|
|
113
|
-
it "should return the default for a invalid number" do
|
117
|
+
it "should return the default for a invalid number" do
|
118
|
+
expect("s213".to_float(1.0)).to eq(1.0)
|
119
|
+
end
|
114
120
|
end
|
115
121
|
|
116
122
|
describe "#to_integer" do
|
117
123
|
it "should correctly convert number" do
|
118
|
-
123.45.to_integer.
|
119
|
-
123.to_integer.
|
120
|
-
"+123".to_integer.
|
121
|
-
"-123".to_integer.
|
124
|
+
expect(123.45.to_integer).to eq(123)
|
125
|
+
expect(123.to_integer).to eq(123)
|
126
|
+
expect("+123".to_integer).to eq(123)
|
127
|
+
expect("-123".to_integer).to eq(-123)
|
122
128
|
end
|
123
129
|
|
124
|
-
it "should return 0 for a invalid number without a default" do
|
130
|
+
it "should return 0 for a invalid number without a default" do
|
131
|
+
expect("s213".to_integer).to eq(0)
|
132
|
+
end
|
125
133
|
|
126
|
-
it "should return the default for a invalid number" do
|
134
|
+
it "should return the default for a invalid number" do
|
135
|
+
expect("s213".to_integer(1)).to eq(1)
|
136
|
+
end
|
127
137
|
end
|
128
138
|
|
129
139
|
describe "#to_boolean" do
|
130
140
|
it "should return true for a valid true boolean" do
|
131
|
-
true.to_boolean.
|
132
|
-
"y".to_boolean.
|
133
|
-
"yes".to_boolean.
|
134
|
-
"1".to_boolean.
|
135
|
-
1.to_boolean.
|
136
|
-
1.0.to_boolean.
|
141
|
+
expect(true.to_boolean).to be_true
|
142
|
+
expect("y".to_boolean).to be_true
|
143
|
+
expect("yes".to_boolean).to be_true
|
144
|
+
expect("1".to_boolean).to be_true
|
145
|
+
expect(1.to_boolean).to be_true
|
146
|
+
expect(1.0.to_boolean).to be_true
|
137
147
|
end
|
138
148
|
|
139
149
|
it "should return false for all other values" do
|
140
|
-
false.to_boolean.
|
141
|
-
nil.to_boolean.
|
142
|
-
"n".to_boolean.
|
143
|
-
"no".to_boolean.
|
144
|
-
"2".to_boolean.
|
145
|
-
2.0.to_boolean.
|
146
|
-
"false".to_boolean.
|
147
|
-
"abc".to_boolean.
|
148
|
-
0.to_boolean.
|
150
|
+
expect(false.to_boolean).to be_false
|
151
|
+
expect(nil.to_boolean).to be_false
|
152
|
+
expect("n".to_boolean).to be_false
|
153
|
+
expect("no".to_boolean).to be_false
|
154
|
+
expect("2".to_boolean).to be_false
|
155
|
+
expect(2.0.to_boolean).to be_false
|
156
|
+
expect("false".to_boolean).to be_false
|
157
|
+
expect("abc".to_boolean).to be_false
|
158
|
+
expect(0.to_boolean).to be_false
|
149
159
|
end
|
150
160
|
end
|
151
161
|
|
152
162
|
describe "#round_to_precision" do
|
153
163
|
it "should round number" do
|
154
|
-
123.456789.round_to_precision(2).
|
155
|
-
123.456789.round_to_precision(0).
|
156
|
-
"123.456789".round_to_precision(2).
|
164
|
+
expect(123.456789.round_to_precision(2)).to eq("123.46")
|
165
|
+
expect(123.456789.round_to_precision(0)).to eq("123")
|
166
|
+
expect("123.456789".round_to_precision(2)).to eq("123.46")
|
157
167
|
end
|
158
168
|
|
159
169
|
it "should return nil for non numeric values" do
|
160
|
-
123.456789.round_to_precision(-1).
|
161
|
-
"abc".round_to_precision(-1).
|
170
|
+
expect(123.456789.round_to_precision(-1)).to eq(nil)
|
171
|
+
expect("abc".round_to_precision(-1)).to eq(nil)
|
162
172
|
end
|
163
173
|
end
|
164
174
|
|
165
175
|
describe "#format_number" do
|
166
176
|
it "should format number" do
|
167
|
-
123123.456789.format_number.
|
168
|
-
123123.456789.format_number(2).
|
169
|
-
123123.456789.format_number(3, "@").
|
170
|
-
123123.456789.format_number(3, "@", "$").
|
171
|
-
"123123.456789".format_number(3, "@", "$", "!").
|
177
|
+
expect(123123.456789.format_number).to eq("123,123.46")
|
178
|
+
expect(123123.456789.format_number(2)).to eq("123,123.46")
|
179
|
+
expect(123123.456789.format_number(3, "@")).to eq("123,123@457")
|
180
|
+
expect(123123.456789.format_number(3, "@", "$")).to eq("123,123@457 $")
|
181
|
+
expect("123123.456789".format_number(3, "@", "$", "!")).to eq("123!123@457 $")
|
172
182
|
|
173
183
|
Cowtech::Extensions.settings.setup_format_number(5, ",", "£", ".")
|
174
|
-
123123.456789.format_number.
|
184
|
+
expect(123123.456789.format_number).to eq("123.123,45679 £")
|
175
185
|
end
|
176
186
|
|
177
187
|
it "should return nil for non numeric values" do
|
178
|
-
123.456789.format_number(-1).
|
179
|
-
"abc".format_number(-1).
|
188
|
+
expect(123.456789.format_number(-1)).to eq(nil)
|
189
|
+
expect("abc".format_number(-1)).to eq(nil)
|
180
190
|
end
|
181
191
|
end
|
182
192
|
|
183
193
|
describe "#format_boolean" do
|
184
194
|
it "should return the correct string for all values" do
|
185
|
-
"yes".format_boolean.
|
186
|
-
"abc".format_boolean.
|
195
|
+
expect("yes".format_boolean).to eq("Yes")
|
196
|
+
expect("abc".format_boolean).to eq("No")
|
187
197
|
end
|
188
198
|
|
189
199
|
it "should support localization" do
|
190
200
|
Cowtech::Extensions.settings.setup_boolean_names("YYY", "NNN")
|
191
|
-
"yes".format_boolean.
|
192
|
-
"abc".format_boolean.
|
201
|
+
expect("yes".format_boolean).to eq("YYY")
|
202
|
+
expect("abc".format_boolean).to eq("NNN")
|
193
203
|
end
|
194
204
|
|
195
205
|
it "should support overrides" do
|
196
206
|
Cowtech::Extensions.settings.setup_boolean_names
|
197
|
-
"yes".format_boolean("TTT").
|
198
|
-
"yes".format_boolean(nil, "FFF").
|
199
|
-
"abc".format_boolean("TTT").
|
200
|
-
"abc".format_boolean(nil, "FFF").
|
207
|
+
expect("yes".format_boolean("TTT")).to eq("TTT")
|
208
|
+
expect("yes".format_boolean(nil, "FFF")).to eq("Yes")
|
209
|
+
expect("abc".format_boolean("TTT")).to eq("No")
|
210
|
+
expect("abc".format_boolean(nil, "FFF")).to eq("FFF")
|
201
211
|
end
|
202
212
|
end
|
203
213
|
|
204
214
|
describe "#debug_dump" do
|
205
215
|
it "should return the correct representation for an object" do
|
206
216
|
reference = {:a => "b"}
|
207
|
-
reference.debug_dump(:json, false).
|
208
|
-
reference.debug_dump(:pretty_json, false).
|
209
|
-
reference.debug_dump(:yaml, false).
|
217
|
+
expect(reference.debug_dump(:json, false)).to eq(reference.to_json)
|
218
|
+
expect(reference.debug_dump(:pretty_json, false)).to eq(::JSON.pretty_generate(reference))
|
219
|
+
expect(reference.debug_dump(:yaml, false)).to eq(reference.to_yaml)
|
210
220
|
end
|
211
221
|
|
212
222
|
it "should inspect the object if the format is not recognized" do
|
213
223
|
reference = {:a => "b"}
|
214
|
-
reference.debug_dump(:unknown, false).
|
224
|
+
expect(reference.debug_dump(:unknown, false)).to eq(reference.inspect)
|
215
225
|
end
|
216
226
|
|
217
|
-
it "should raise an exception if requested" do
|
227
|
+
it "should raise an exception if requested" do
|
228
|
+
expect { {:a => "b"}.debug_dump }.to raise_error(::Cowtech::Extensions::Exceptions::Dump)
|
229
|
+
end
|
218
230
|
end
|
219
231
|
end
|
@@ -14,6 +14,8 @@ describe Cowtech::Extensions::Pathname do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#components" do
|
17
|
-
it "should return the components of the path" do
|
17
|
+
it "should return the components of the path" do
|
18
|
+
expect([""] + reference.components).to eq(reference.to_s.split("/"))
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
@@ -18,52 +18,52 @@ describe Cowtech::Extensions::Settings do
|
|
18
18
|
describe "#initialize" do
|
19
19
|
it "should create good defaults" do
|
20
20
|
settings = ::Cowtech::Extensions::Settings.new
|
21
|
-
settings.format_number.
|
22
|
-
settings.boolean_names.
|
23
|
-
settings.date_names.
|
24
|
-
settings.date_formats.
|
21
|
+
expect(settings.format_number).to be_a(Hash)
|
22
|
+
expect(settings.boolean_names).to be_a(Hash)
|
23
|
+
expect(settings.date_names).to be_a(Hash)
|
24
|
+
expect(settings.date_formats).to be_a(Hash)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should create good defaults for the singleton" do
|
28
|
-
reference.format_number.
|
29
|
-
reference.boolean_names.
|
30
|
-
reference.date_names.
|
31
|
-
reference.date_formats.
|
28
|
+
expect(reference.format_number).to be_a(Hash)
|
29
|
+
expect(reference.boolean_names).to be_a(Hash)
|
30
|
+
expect(reference.date_names).to be_a(Hash)
|
31
|
+
expect(reference.date_formats).to be_a(Hash)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "#setup_format_number" do
|
36
36
|
it "should save format numbering options for usage" do
|
37
37
|
reference.setup_format_number(2)
|
38
|
-
number_reference.format_number.
|
38
|
+
expect(number_reference.format_number).to eq("123,456.65")
|
39
39
|
|
40
40
|
reference.setup_format_number(3, "A")
|
41
|
-
number_reference.format_number.
|
41
|
+
expect(number_reference.format_number).to eq("123,456A654")
|
42
42
|
|
43
43
|
reference.setup_format_number(4, "A", "B")
|
44
|
-
number_reference.format_number.
|
44
|
+
expect(number_reference.format_number).to eq("123,456A6543 B")
|
45
45
|
|
46
46
|
reference.setup_format_number(5, "A", "B", "C")
|
47
|
-
number_reference.format_number.
|
47
|
+
expect(number_reference.format_number).to eq("123C456A65432 B")
|
48
48
|
|
49
49
|
reference.setup_format_number
|
50
|
-
number_reference.format_number.
|
50
|
+
expect(number_reference.format_number).to eq("123,456.65")
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "#setup_boolean_names" do
|
55
55
|
it "should save names for boolean values" do
|
56
56
|
reference.setup_boolean_names("TRUE1")
|
57
|
-
[true.format_boolean, false.format_boolean].
|
57
|
+
expect([true.format_boolean, false.format_boolean]).to eq(["TRUE1", "No"])
|
58
58
|
|
59
59
|
reference.setup_boolean_names(nil, "FALSE1")
|
60
|
-
[true.format_boolean, false.format_boolean].
|
60
|
+
expect([true.format_boolean, false.format_boolean]).to eq(["Yes", "FALSE1"])
|
61
61
|
|
62
62
|
reference.setup_boolean_names("TRUE2", "FALSE2")
|
63
|
-
[true.format_boolean, false.format_boolean].
|
63
|
+
expect([true.format_boolean, false.format_boolean]).to eq(["TRUE2", "FALSE2"])
|
64
64
|
|
65
65
|
reference.setup_boolean_names
|
66
|
-
[true.format_boolean, false.format_boolean].
|
66
|
+
expect([true.format_boolean, false.format_boolean]).to eq(["Yes", "No"])
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -72,20 +72,20 @@ describe Cowtech::Extensions::Settings do
|
|
72
72
|
reference.setup_date_formats(nil, true)
|
73
73
|
|
74
74
|
reference.setup_date_formats({:c1 => "%Y"})
|
75
|
-
date_reference.lstrftime(:ct_date)
|
76
|
-
date_reference.lstrftime(:c1)
|
75
|
+
expect(date_reference.lstrftime(:ct_date)).to eq(date_reference.strftime("%Y-%m-%d"))
|
76
|
+
expect(date_reference.lstrftime(:c1)).to eq(date_reference.year.to_s)
|
77
77
|
|
78
78
|
reference.setup_date_formats({:c1 => "%Y"}, true)
|
79
|
-
date_reference.lstrftime(:ct_date).
|
80
|
-
date_reference.lstrftime(:c1).
|
79
|
+
expect(date_reference.lstrftime(:ct_date)).to eq("ct_date")
|
80
|
+
expect(date_reference.lstrftime(:c1)).to eq(date_reference.year.to_s)
|
81
81
|
|
82
82
|
reference.setup_date_formats()
|
83
|
-
date_reference.lstrftime(:ct_date).
|
84
|
-
date_reference.lstrftime(:c1).
|
83
|
+
expect(date_reference.lstrftime(:ct_date)).to eq(date_reference.strftime("%Y-%m-%d"))
|
84
|
+
expect(date_reference.lstrftime(:c1)).to eq(date_reference.year.to_s)
|
85
85
|
|
86
86
|
reference.setup_date_formats(nil, true)
|
87
|
-
date_reference.lstrftime(:ct_date)
|
88
|
-
date_reference.lstrftime(:c1).
|
87
|
+
expect(date_reference.lstrftime(:ct_date)).to eq(date_reference.strftime("%Y-%m-%d"))
|
88
|
+
expect(date_reference.lstrftime(:c1)).to eq("c1")
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -100,19 +100,19 @@ describe Cowtech::Extensions::Settings do
|
|
100
100
|
short_days = 7.times.collect {|i| (i + 1).to_s}
|
101
101
|
|
102
102
|
reference.setup_date_names(long_months)
|
103
|
-
date_reference.lstrftime(:sdn).
|
103
|
+
expect(date_reference.lstrftime(:sdn)).to eq("66 Jun Tuesday Tue")
|
104
104
|
|
105
105
|
reference.setup_date_names(long_months, short_months)
|
106
|
-
date_reference.lstrftime(:sdn).
|
106
|
+
expect(date_reference.lstrftime(:sdn)).to eq("66 6 Tuesday Tue")
|
107
107
|
|
108
108
|
reference.setup_date_names(long_months, short_months, long_days)
|
109
|
-
date_reference.lstrftime(:sdn).
|
109
|
+
expect(date_reference.lstrftime(:sdn)).to eq("66 6 33 Tue")
|
110
110
|
|
111
111
|
reference.setup_date_names(long_months, short_months, long_days, short_days)
|
112
|
-
date_reference.lstrftime(:sdn).
|
112
|
+
expect(date_reference.lstrftime(:sdn)).to eq("66 6 33 3")
|
113
113
|
|
114
114
|
reference.setup_date_names
|
115
|
-
date_reference.lstrftime(:sdn).
|
115
|
+
expect(date_reference.lstrftime(:sdn)).to eq("June Jun Tuesday Tue")
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|