flextures 3.1.3 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,271 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class FlexturesLoaderTest < Test::Unit::TestCase
4
- context Flextures::Loader do
5
- context "TRANSLATER" do
6
- context :binary do
7
- should "'nil' value not changed" do
8
- assert_equal nil, Flextures::Loader::TRANSLATER[:binary].call(nil)
9
- end
10
- end
11
- context :boolean do
12
- should "'nil' value not changed" do
13
- assert_equal nil, Flextures::Loader::TRANSLATER[:boolean].call(nil)
14
- end
15
- should "true value not changed" do
16
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(true)
17
- end
18
- should "false value not changed" do
19
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(false)
20
- end
21
- should "0 is change to 'false'" do
22
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(0)
23
- end
24
- should "1 is change to 'true'" do
25
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(1)
26
- end
27
- should "-1 is change to 'true'" do
28
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(-1)
29
- end
30
- should "'0' is change to 'false'" do
31
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call('0')
32
- end
33
- should "'1' is change to 'true'" do
34
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call('1')
35
- end
36
- should "'true' value not changed" do
37
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call('true')
38
- end
39
- should "'TRUE' value not changed" do
40
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call('TRUE')
41
- end
42
- should "'false' value not changed" do
43
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call('false')
44
- end
45
- should "'FALSE' value not changed" do
46
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call('FALSE')
47
- end
48
- should "'non-falsy string data' is change to 'true'" do
49
- assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call("Hello")
50
- end
51
- should "'empty string' is change to 'true'" do
52
- assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call("")
53
- end
54
- end
55
- context :date do
56
- should "正常値の文字列" do
57
- assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
58
- end
59
- should "Timeオブジェクト" do
60
- now = Time.now
61
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
62
- end
63
- should "DateTimeオブジェクト" do
64
- now = DateTime.now
65
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
66
- end
67
- should "日付っぽい数字" do
68
- now = "20111121"
69
- assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
70
- end
71
- should "nil" do
72
- assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
73
- end
74
- should "空文字" do
75
- assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
76
- end
77
- end
78
- context :datetime do
79
- should "正常値の文字列" do
80
- assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
81
- end
82
- should "Timeオブジェクト" do
83
- now = Time.now
84
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
85
- end
86
- should "DateTimeオブジェクト" do
87
- now = DateTime.now
88
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
89
- end
90
- should "日付っぽい数字" do
91
- now = "20111121"
92
- assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
93
- end
94
- should "nil" do
95
- assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
96
- end
97
- should "空文字" do
98
- assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
99
- end
100
- end
101
- context :decimal do
102
- should "null" do
103
- assert_equal nil, Flextures::Loader::TRANSLATER[:decimal].call(nil)
104
- end
105
- end
106
- context :float do
107
- should "null" do
108
- assert_equal nil, Flextures::Loader::TRANSLATER[:float].call(nil)
109
- end
110
- end
111
- context :integer do
112
- should "null" do
113
- assert_equal nil, Flextures::Loader::TRANSLATER[:integer].call(nil)
114
- end
115
- end
116
- context :string do
117
- should "null" do
118
- assert_equal nil, Flextures::Loader::TRANSLATER[:string].call(nil)
119
- end
120
- should "空文字" do
121
- assert_equal "", Flextures::Loader::TRANSLATER[:string].call("")
122
- end
123
- should "タブ混じり" do
124
- s="\taaaaa"
125
- assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
126
- end
127
- should "改行混じり" do
128
- s="aa\naaa"
129
- assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
130
- end
131
- should "スペース混じり" do
132
- s="aa aaa"
133
- assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
134
- end
135
- # "@#%{}|[]&:`'>?~"
136
- end
137
- context :text do
138
- should "null" do
139
- assert_equal nil, Flextures::Loader::TRANSLATER[:text].call(nil)
140
- end
141
- should "空文字" do
142
- assert_equal "", Flextures::Loader::TRANSLATER[:text].call("")
143
- end
144
- end
145
- context :time do
146
- should "正常値の文字列" do
147
- assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:time].call("2011/11/21").strftime("%Y/%m/%d")
148
- end
149
- should "Timeオブジェクト" do
150
- now = Time.now
151
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
152
- end
153
- should "DateTimeオブジェクト" do
154
- now = DateTime.now
155
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
156
- end
157
- should "日付っぽい数字はDateTime型" do
158
- now = "20111121"
159
- assert_equal true, Flextures::Loader::TRANSLATER[:time].call(now).is_a?(DateTime)
160
- end
161
- should "nilはnilのまま" do
162
- assert_equal nil, Flextures::Loader::TRANSLATER[:time].call(nil)
163
- end
164
- should "空文字はnil" do
165
- assert_equal nil, Flextures::Loader::TRANSLATER[:time].call("")
166
- end
167
- end
168
- context :timestamp do
169
- should "正常値の文字列はDateTimeに変換" do
170
- assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:timestamp].call("2011/11/21").strftime("%Y/%m/%d")
171
- end
172
- should "Timeオブジェクト" do
173
- now = Time.now
174
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
175
- end
176
- should "DateTimeオブジェクトはDateTime" do
177
- now = DateTime.now
178
- assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
179
- end
180
- should "日付っぽい数字はDateTime" do
181
- now = "20111121"
182
- assert_equal true, Flextures::Loader::TRANSLATER[:timestamp].call(now).is_a?(DateTime)
183
- end
184
- should "nilからnil" do
185
- assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call(nil)
186
- end
187
- should "空文字はnil" do
188
- assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call("")
189
- end
190
- end
191
- end
192
-
193
- context ".stair_list" do
194
- context " stair is 'false' " do
195
- context "argument is null" do
196
- setup do
197
- @list = Flextures::Loader::stair_list nil, false
198
- end
199
- should " return array include only empty string" do
200
- assert_equal @list, [""]
201
- end
202
- end
203
- context "argument is empty string" do
204
- setup do
205
- @list = Flextures::Loader::stair_list "", false
206
- end
207
- should " return array include only empty string" do
208
- assert_equal @list, [""]
209
- end
210
- end
211
- context "include '/' mark" do
212
- setup do
213
- @list = Flextures::Loader::stair_list "a/b/c", false
214
- end
215
- should " return directory list" do
216
- assert_equal @list, ["a/b/c"]
217
- end
218
- end
219
- end
220
- context " stair is 'true' " do
221
- context "argument is null" do
222
- setup do
223
- @list = Flextures::Loader::stair_list nil, true
224
- end
225
- should " return array include only empty string" do
226
- assert_equal @list, [""]
227
- end
228
- end
229
- context "argument is empty string" do
230
- setup do
231
- @list = Flextures::Loader::stair_list "", true
232
- end
233
- should " return array include only empty string" do
234
- assert_equal @list, [""]
235
- end
236
- end
237
- context "include '/' mark" do
238
- setup do
239
- @list = Flextures::Loader::stair_list "a/b/c", true
240
- end
241
- should " return directory list" do
242
- assert_equal @list, ["a/b/c","a/b","a",""]
243
- end
244
- end
245
- end
246
- end
247
-
248
- context ".loading_order" do
249
- context "simple test" do
250
- setup do
251
- @proc = Flextures::Loader.loading_order
252
- end
253
- should "not sort" do
254
- assert_equal ["a","b","c"].sort(&@proc), ["a","b","c"]
255
- end
256
- end
257
- context "set orderd table name" do
258
- setup do
259
- Flextures::Config.table_load_order=["b"]
260
- @proc = Flextures::Loader.loading_order
261
- end
262
- should "first table name is setted table" do
263
- assert_equal ["a","b","c"].sort(&@proc), ["b","a","c"]
264
- end
265
- teardown do
266
- Flextures::Config.table_load_order=[]
267
- end
268
- end
269
- end
270
- end
271
- end
@@ -1,8 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class SimpleTest < Test::Unit::TestCase
4
- should "comfirm should move" do
5
- assert_equal true, true
6
- end
7
- end
8
-