flextures 3.1.3 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -1
- data/Gemfile.lock +17 -13
- data/README.ja.md +15 -13
- data/README.md +9 -8
- data/Rakefile +5 -0
- data/flextures.gemspec +3 -1
- data/lib/flextures.rb +0 -3
- data/lib/flextures/flextures.rake +1 -42
- data/lib/flextures/flextures.rb +4 -7
- data/lib/flextures/flextures_base_config.rb +17 -28
- data/lib/flextures/flextures_command.rb +3 -5
- data/lib/flextures/flextures_dumper.rb +27 -29
- data/lib/flextures/flextures_extension_modules.rb +1 -14
- data/lib/flextures/flextures_factory.rb +3 -5
- data/lib/flextures/flextures_loader.rb +49 -51
- data/lib/flextures/flextures_railtie.rb +0 -2
- data/lib/flextures/rspec_flextures_support.rb +125 -71
- data/lib/flextures/version.rb +1 -1
- data/test/models/flextures_test.rb +8 -0
- data/test/test_helper.rb +4 -3
- data/test/unit/flextures_args_test.rb +178 -0
- data/test/unit/flextures_dumper_test.rb +232 -0
- data/test/unit/{test_flextures_extention_modules.rb → flextures_extention_modules_test.rb} +18 -13
- data/test/unit/flextures_hooks_test.rb +111 -0
- data/test/unit/flextures_loader_test.rb +313 -0
- metadata +9 -18
- data/lib/flextures/testunit_flextures_support.rb +0 -43
- data/test/unit/test_flextures.rb +0 -8
- data/test/unit/test_flextures_args.rb +0 -147
- data/test/unit/test_flextures_dumper.rb +0 -187
- data/test/unit/test_flextures_hooks.rb +0 -90
- data/test/unit/test_flextures_loader.rb +0 -271
- data/test/unit/test_simple.rb +0 -8
@@ -0,0 +1,111 @@
|
|
1
|
+
$:.push( File.join(File.dirname(File.expand_path(__FILE__)), '../') )
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
describe :Hook do
|
6
|
+
describe Flextures::Loader do
|
7
|
+
describe ".parse_flextures_options" do
|
8
|
+
describe "set one table" do
|
9
|
+
before do
|
10
|
+
@list = Flextures::Loader.parse_flextures_options({},:users)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "return table is Array" do
|
14
|
+
assert_equal true, @list.is_a?(Array)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "return table is only one" do
|
18
|
+
assert_equal 1, @list.size
|
19
|
+
end
|
20
|
+
|
21
|
+
it "return data is content Hash data" do
|
22
|
+
assert_equal true, @list.first.is_a?(Hash)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "return data is contain loading table infomation" do
|
26
|
+
h = { table: :users, file: "users", loader: :fun }
|
27
|
+
assert_equal h, @list.first
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "if set file name option" do
|
32
|
+
before do
|
33
|
+
@list = Flextures::Loader.parse_flextures_options( {}, :users => :users_another3 )
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returned data size is only one" do
|
37
|
+
assert_equal 1, @list.size
|
38
|
+
end
|
39
|
+
|
40
|
+
it " 'file' option is changed setted file name" do
|
41
|
+
assert_equal :users_another3, @list.first[:file]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returned data include data" do
|
45
|
+
h = { table: :users, file: :users_another3, loader: :fun }
|
46
|
+
assert_equal h, @list.first
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "if set 'cache' option" do
|
51
|
+
before do
|
52
|
+
@list = Flextures::Loader.parse_flextures_options( { cache: true }, :users )
|
53
|
+
end
|
54
|
+
|
55
|
+
it "setted cache option" do
|
56
|
+
assert_equal true, @list.first[:cache]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe " if set 'dir' option " do
|
61
|
+
before do
|
62
|
+
@list = Flextures::Loader.parse_flextures_options( { dir: "a/b/c" }, :users )
|
63
|
+
end
|
64
|
+
|
65
|
+
it "setted cache option" do
|
66
|
+
assert_equal "a/b/c", @list.first[:dir]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe " if set 'controller' option " do
|
71
|
+
before do
|
72
|
+
@list = Flextures::Loader.parse_flextures_options( {}, { controller: "top" }, :users )
|
73
|
+
end
|
74
|
+
|
75
|
+
it "setted cache option" do
|
76
|
+
assert_equal "controllers/top", @list.first[:dir]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe " if set 'controller' and 'action' option " do
|
81
|
+
before do
|
82
|
+
@list = Flextures::Loader.parse_flextures_options( {}, { controller: "top", action:"index" }, :users )
|
83
|
+
end
|
84
|
+
|
85
|
+
it "setted cache option" do
|
86
|
+
assert_equal "controllers/top/index", @list.first[:dir]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe " if set 'model' option " do
|
91
|
+
before do
|
92
|
+
@list = Flextures::Loader.parse_flextures_options( {}, { model: "users" }, :users )
|
93
|
+
end
|
94
|
+
|
95
|
+
it "setted cache option" do
|
96
|
+
assert_equal "models/users", @list.first[:dir]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe " if set 'model' and 'method' option " do
|
101
|
+
before do
|
102
|
+
@list = Flextures::Loader.parse_flextures_options( {}, { model: "users", method:"login" }, :users )
|
103
|
+
end
|
104
|
+
|
105
|
+
it "setted cache option" do
|
106
|
+
assert_equal "models/users/login", @list.first[:dir]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,313 @@
|
|
1
|
+
$:.push( File.join(File.dirname(File.expand_path(__FILE__)), '../') )
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
describe Flextures::Loader do
|
5
|
+
describe "TRANSLATER" do
|
6
|
+
describe :binary do
|
7
|
+
it "'nil' value not changed" do
|
8
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:binary].call(nil)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe :boolean do
|
13
|
+
it "'nil' value not changed" do
|
14
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:boolean].call(nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "true value not changed" do
|
18
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "false value not changed" do
|
22
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(false)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "0 is change to 'false'" do
|
26
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(0)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "1 is change to 'true'" do
|
30
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(1)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "-1 is change to 'true'" do
|
34
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(-1)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "'0' is change to 'false'" do
|
38
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call('0')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "'1' is change to 'true'" do
|
42
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call('1')
|
43
|
+
end
|
44
|
+
|
45
|
+
it "'true' value not changed" do
|
46
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call('true')
|
47
|
+
end
|
48
|
+
|
49
|
+
it "'false' value not changed" do
|
50
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call('false')
|
51
|
+
end
|
52
|
+
|
53
|
+
it "'non-falsy string data' is change to 'true'" do
|
54
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call("Hello")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "'empty string' is change to 'true'" do
|
58
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call("")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe :date do
|
63
|
+
it "正常値の文字列" do
|
64
|
+
assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
|
65
|
+
end
|
66
|
+
|
67
|
+
it "Timeオブジェクト" do
|
68
|
+
now = Time.now
|
69
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
|
70
|
+
end
|
71
|
+
|
72
|
+
it "DateTimeオブジェクト" do
|
73
|
+
now = DateTime.now
|
74
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "日付っぽい数字" do
|
78
|
+
now = "20111121"
|
79
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "nil" do
|
83
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "空文字" do
|
87
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe :datetime do
|
92
|
+
it "正常値の文字列" do
|
93
|
+
assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:date].call("2011/11/21").strftime("%Y/%m/%d")
|
94
|
+
end
|
95
|
+
|
96
|
+
it "Timeオブジェクト" do
|
97
|
+
now = Time.now
|
98
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "DateTimeオブジェクト" do
|
102
|
+
now = DateTime.now
|
103
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:date].call(now).strftime("%Y/%m/%d")
|
104
|
+
end
|
105
|
+
|
106
|
+
it "日付っぽい数字" do
|
107
|
+
now = "20111121"
|
108
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:date].call(now).is_a?(Date)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "nil" do
|
112
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:date].call(nil)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "空文字" do
|
116
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:date].call("")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe :decimal do
|
121
|
+
it "null" do
|
122
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:decimal].call(nil)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe :float do
|
127
|
+
it "null" do
|
128
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:float].call(nil)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe :integer do
|
133
|
+
it "null" do
|
134
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:integer].call(nil)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe :string do
|
139
|
+
it "null" do
|
140
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:string].call(nil)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "空文字" do
|
144
|
+
assert_equal "", Flextures::Loader::TRANSLATER[:string].call("")
|
145
|
+
end
|
146
|
+
|
147
|
+
it "タブ混じり" do
|
148
|
+
s="\taaaaa"
|
149
|
+
assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "改行混じり" do
|
153
|
+
s="aa\naaa"
|
154
|
+
assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "スペース混じり" do
|
158
|
+
s="aa aaa"
|
159
|
+
assert_equal s, Flextures::Loader::TRANSLATER[:string].call(s)
|
160
|
+
end
|
161
|
+
# "@#%{}|[]&:`'>?~"
|
162
|
+
end
|
163
|
+
|
164
|
+
describe :text do
|
165
|
+
it "null" do
|
166
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:text].call(nil)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "空文字" do
|
170
|
+
assert_equal "", Flextures::Loader::TRANSLATER[:text].call("")
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe :time do
|
175
|
+
it "正常値の文字列" do
|
176
|
+
assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:time].call("2011/11/21").strftime("%Y/%m/%d")
|
177
|
+
end
|
178
|
+
|
179
|
+
it "Timeオブジェクト" do
|
180
|
+
now = Time.now
|
181
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
|
182
|
+
end
|
183
|
+
|
184
|
+
it "DateTimeオブジェクト" do
|
185
|
+
now = DateTime.now
|
186
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:time].call(now).strftime("%Y/%m/%d")
|
187
|
+
end
|
188
|
+
|
189
|
+
it "日付っぽい数字はDateTime型" do
|
190
|
+
now = "20111121"
|
191
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:time].call(now).is_a?(DateTime)
|
192
|
+
end
|
193
|
+
|
194
|
+
it "nilはnilのまま" do
|
195
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:time].call(nil)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "空文字はnil" do
|
199
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:time].call("")
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe :timestamp do
|
204
|
+
it "正常値の文字列はDateTimeに変換" do
|
205
|
+
assert_equal "2011/11/21", Flextures::Loader::TRANSLATER[:timestamp].call("2011/11/21").strftime("%Y/%m/%d")
|
206
|
+
end
|
207
|
+
|
208
|
+
it "Timeオブジェクト" do
|
209
|
+
now = Time.now
|
210
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
|
211
|
+
end
|
212
|
+
|
213
|
+
it "DateTimeオブジェクトはDateTime" do
|
214
|
+
now = DateTime.now
|
215
|
+
assert_equal now.strftime("%Y/%m/%d"), Flextures::Loader::TRANSLATER[:timestamp].call(now).strftime("%Y/%m/%d")
|
216
|
+
end
|
217
|
+
|
218
|
+
it "日付っぽい数字はDateTime" do
|
219
|
+
now = "20111121"
|
220
|
+
assert_equal true, Flextures::Loader::TRANSLATER[:timestamp].call(now).is_a?(DateTime)
|
221
|
+
end
|
222
|
+
|
223
|
+
it "nilからnil" do
|
224
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call(nil)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "空文字はnil" do
|
228
|
+
assert_equal nil, Flextures::Loader::TRANSLATER[:timestamp].call("")
|
229
|
+
end
|
230
|
+
end
|
231
|
+
describe ".stair_list" do
|
232
|
+
describe " stair is 'false' " do
|
233
|
+
describe "argument is null" do
|
234
|
+
before do
|
235
|
+
@list = Flextures::Loader::stair_list nil, false
|
236
|
+
end
|
237
|
+
|
238
|
+
it " return array include only empty string" do
|
239
|
+
assert_equal @list, [""]
|
240
|
+
end
|
241
|
+
end
|
242
|
+
describe "argument is empty string" do
|
243
|
+
before do
|
244
|
+
@list = Flextures::Loader::stair_list "", false
|
245
|
+
end
|
246
|
+
|
247
|
+
it " return array include only empty string" do
|
248
|
+
assert_equal @list, [""]
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe "include '/' mark" do
|
253
|
+
before do
|
254
|
+
@list = Flextures::Loader::stair_list "a/b/c", false
|
255
|
+
end
|
256
|
+
|
257
|
+
it " return directory list" do
|
258
|
+
assert_equal @list, ["a/b/c"]
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe " stair is 'true' " do
|
264
|
+
describe "argument is null" do
|
265
|
+
before do
|
266
|
+
@list = Flextures::Loader::stair_list nil, true
|
267
|
+
end
|
268
|
+
|
269
|
+
it " return array include only empty string" do
|
270
|
+
assert_equal @list, [""]
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
describe "include '/' mark" do
|
275
|
+
before do
|
276
|
+
@list = Flextures::Loader::stair_list "a/b/c", true
|
277
|
+
end
|
278
|
+
|
279
|
+
it " return directory list" do
|
280
|
+
assert_equal @list, ["a/b/c","a/b","a",""]
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
describe ".loading_order" do
|
286
|
+
describe "simple test" do
|
287
|
+
before do
|
288
|
+
@proc = Flextures::Loader.loading_order
|
289
|
+
end
|
290
|
+
|
291
|
+
it "not sort" do
|
292
|
+
assert_equal ["a","b","c"].sort(&@proc), ["a","b","c"]
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
describe "set orderd table name" do
|
297
|
+
before do
|
298
|
+
Flextures::Config.table_load_order=["b"]
|
299
|
+
@proc = Flextures::Loader.loading_order
|
300
|
+
end
|
301
|
+
|
302
|
+
it "first table name is setted table" do
|
303
|
+
assert_equal ["a","b","c"].sort(&@proc), ["b","a","c"]
|
304
|
+
end
|
305
|
+
|
306
|
+
after do
|
307
|
+
Flextures::Config.table_load_order=[]
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flextures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- baban
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,16 +66,14 @@ files:
|
|
66
66
|
- lib/flextures/flextures_loader.rb
|
67
67
|
- lib/flextures/flextures_railtie.rb
|
68
68
|
- lib/flextures/rspec_flextures_support.rb
|
69
|
-
- lib/flextures/testunit_flextures_support.rb
|
70
69
|
- lib/flextures/version.rb
|
70
|
+
- test/models/flextures_test.rb
|
71
71
|
- test/test_helper.rb
|
72
|
-
- test/unit/
|
73
|
-
- test/unit/
|
74
|
-
- test/unit/
|
75
|
-
- test/unit/
|
76
|
-
- test/unit/
|
77
|
-
- test/unit/test_flextures_loader.rb
|
78
|
-
- test/unit/test_simple.rb
|
72
|
+
- test/unit/flextures_args_test.rb
|
73
|
+
- test/unit/flextures_dumper_test.rb
|
74
|
+
- test/unit/flextures_extention_modules_test.rb
|
75
|
+
- test/unit/flextures_hooks_test.rb
|
76
|
+
- test/unit/flextures_loader_test.rb
|
79
77
|
homepage: http://github.com/baban/flextures
|
80
78
|
licenses:
|
81
79
|
- MIT
|
@@ -101,11 +99,4 @@ signing_key:
|
|
101
99
|
specification_version: 4
|
102
100
|
summary: load and dump fixtures.
|
103
101
|
test_files:
|
104
|
-
- test/
|
105
|
-
- test/unit/test_flextures.rb
|
106
|
-
- test/unit/test_flextures_args.rb
|
107
|
-
- test/unit/test_flextures_dumper.rb
|
108
|
-
- test/unit/test_flextures_extention_modules.rb
|
109
|
-
- test/unit/test_flextures_hooks.rb
|
110
|
-
- test/unit/test_flextures_loader.rb
|
111
|
-
- test/unit/test_simple.rb
|
102
|
+
- test/unit/flextures_args_test.rb
|