flextures 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.ja.rdoc +33 -22
- data/README.rdoc +29 -22
- data/VERSION +1 -1
- data/flextures.gemspec +7 -6
- data/lib/flextures/flextures.rake +28 -4
- data/lib/flextures/flextures.rb +33 -28
- data/lib/flextures/flextures_base_config.rb +17 -6
- data/lib/flextures/flextures_command.rb +25 -27
- data/lib/flextures/flextures_dumper.rb +82 -55
- data/lib/flextures/flextures_extension_modules.rb +12 -8
- data/lib/flextures/flextures_factory.rb +13 -11
- data/lib/flextures/flextures_loader.rb +208 -132
- data/lib/flextures/rspec_flextures_support.rb +13 -7
- data/lib/flextures/testunit_flextures_support.rb +30 -4
- data/lib/flextures/version.rb +1 -1
- data/test/unit/test_flextures.rb +1 -1
- data/test/unit/test_flextures_args.rb +70 -17
- data/test/unit/test_flextures_dumper.rb +48 -37
- data/test/unit/test_flextures_extention_modules.rb +37 -0
- data/test/unit/test_flextures_hooks.rb +66 -17
- data/test/unit/test_flextures_loader.rb +89 -14
- data/test/unit/test_simple.rb +1 -1
- metadata +12 -21
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class FlexturesTest < Test::Unit::TestCase
|
4
|
+
context "Array#to_hash" do
|
5
|
+
context "when column size is equal data size" do
|
6
|
+
setup do
|
7
|
+
@keys = %W[id name hp]
|
8
|
+
@values = %W[1 hoge 100]
|
9
|
+
@h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
|
10
|
+
end
|
11
|
+
should "return hash" do
|
12
|
+
assert_equal @h, { "id"=>"1", "name"=>"hoge", "hp"=>"100" }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
context "when column size is bigger than data size" do
|
16
|
+
setup do
|
17
|
+
@keys = %W[id name hp]
|
18
|
+
@values = %W[1 hoge]
|
19
|
+
@h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
|
20
|
+
end
|
21
|
+
should "return hash, overflow key is filled 'nil'" do
|
22
|
+
assert_equal @h, { "id"=>"1", "name"=>"hoge", "hp"=> nil }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context "when column size is smaller than data size" do
|
26
|
+
setup do
|
27
|
+
@keys = %W[id name]
|
28
|
+
@values = %W[1 hoge 200]
|
29
|
+
@h = @values.extend(Flextures::Extensions::Array).to_hash(@keys)
|
30
|
+
end
|
31
|
+
should "return hash, overflow value is cut offed" do
|
32
|
+
assert_equal @h, { "id"=>"1", "name"=>"hoge" }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -3,36 +3,85 @@
|
|
3
3
|
class FlexturesHookTest < Test::Unit::TestCase
|
4
4
|
context Flextures::Loader do
|
5
5
|
context ".parse_flextures_options" do
|
6
|
-
context "
|
6
|
+
context "set one table" do
|
7
7
|
setup do
|
8
|
-
@
|
8
|
+
@list = Flextures::Loader.parse_flextures_options(:users)
|
9
9
|
end
|
10
|
-
should "
|
11
|
-
assert_equal
|
10
|
+
should "return table is Array" do
|
11
|
+
assert_equal true, @list.is_a?(Array)
|
12
12
|
end
|
13
|
-
should "
|
14
|
-
|
15
|
-
|
13
|
+
should "return table is only one" do
|
14
|
+
assert_equal 1, @list.size
|
15
|
+
end
|
16
|
+
should "return data is content Hash data" do
|
17
|
+
assert_equal true, @list.first.is_a?(Hash)
|
18
|
+
end
|
19
|
+
should "return data is contain loading table infomation" do
|
20
|
+
h = { table: :users, file: "users", loader: :fun }
|
21
|
+
assert_equal h, @list.first
|
16
22
|
end
|
17
23
|
end
|
18
|
-
context "
|
24
|
+
context "if set file name option" do
|
19
25
|
setup do
|
20
|
-
@
|
26
|
+
@list = Flextures::Loader.parse_flextures_options( :users => :users_another3 )
|
27
|
+
end
|
28
|
+
should "returned data size is only one" do
|
29
|
+
assert_equal 1, @list.size
|
21
30
|
end
|
22
|
-
should "
|
23
|
-
assert_equal
|
31
|
+
should " 'file' option is changed setted file name" do
|
32
|
+
assert_equal :users_another3, @list.first[:file]
|
24
33
|
end
|
25
|
-
should "
|
34
|
+
should "returned data include data" do
|
26
35
|
h = { table: :users, file: :users_another3, loader: :fun }
|
27
|
-
assert_equal h, @
|
36
|
+
assert_equal h, @list.first
|
37
|
+
end
|
38
|
+
end
|
39
|
+
context "if set 'cache' option" do
|
40
|
+
setup do
|
41
|
+
@list = Flextures::Loader.parse_flextures_options( { cache: true }, :users )
|
42
|
+
end
|
43
|
+
should "setted cache option" do
|
44
|
+
assert_equal true, @list.first[:cache]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
context " if set 'dir' option " do
|
48
|
+
setup do
|
49
|
+
@list = Flextures::Loader.parse_flextures_options( { dir: "a/b/c" }, :users )
|
50
|
+
end
|
51
|
+
should "setted cache option" do
|
52
|
+
assert_equal "a/b/c", @list.first[:dir]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
context " if set 'controller' option " do
|
56
|
+
setup do
|
57
|
+
@list = Flextures::Loader.parse_flextures_options( { controller: "top" }, :users )
|
58
|
+
end
|
59
|
+
should "setted cache option" do
|
60
|
+
assert_equal "controllers/top", @list.first[:dir]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
context " if set 'controller' and 'action' option " do
|
64
|
+
setup do
|
65
|
+
@list = Flextures::Loader.parse_flextures_options( { controller: "top", action:"index" }, :users )
|
66
|
+
end
|
67
|
+
should "setted cache option" do
|
68
|
+
assert_equal "controllers/top/index", @list.first[:dir]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
context " if set 'model' option " do
|
72
|
+
setup do
|
73
|
+
@list = Flextures::Loader.parse_flextures_options( { model: "users" }, :users )
|
74
|
+
end
|
75
|
+
should "setted cache option" do
|
76
|
+
assert_equal "models/users", @list.first[:dir]
|
28
77
|
end
|
29
78
|
end
|
30
|
-
context "
|
79
|
+
context " if set 'model' and 'method' option " do
|
31
80
|
setup do
|
32
|
-
@
|
81
|
+
@list = Flextures::Loader.parse_flextures_options( { model: "users", method:"login" }, :users )
|
33
82
|
end
|
34
|
-
should "
|
35
|
-
assert_equal
|
83
|
+
should "setted cache option" do
|
84
|
+
assert_equal "models/users/login", @list.first[:dir]
|
36
85
|
end
|
37
86
|
end
|
38
87
|
end
|
@@ -1,41 +1,38 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# ruby -I"lib:lib:test" -I"/Users/matsubaramasanao/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib" "/Users/matsubaramasanao/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" test/**/test_*.rb
|
4
|
-
# ruby -I"lib:lib:test" "/Users/matsubaramasanao/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" test/**/test_*.rb
|
5
|
-
|
6
3
|
class FlexturesLoaderTest < Test::Unit::TestCase
|
7
4
|
context Flextures::Loader do
|
8
5
|
context "TRANSLATER" do
|
9
6
|
context :binary do
|
10
|
-
should "nil" do
|
7
|
+
should "'nil' value not changed" do
|
11
8
|
assert_equal nil, Flextures::Loader::TRANSLATER[:binary].call(nil)
|
12
9
|
end
|
13
10
|
end
|
14
11
|
context :boolean do
|
15
|
-
should "nil
|
12
|
+
should "'nil' value not changed" do
|
16
13
|
assert_equal nil, Flextures::Loader::TRANSLATER[:boolean].call(nil)
|
17
14
|
end
|
18
|
-
should "true
|
15
|
+
should "'true' value not changed" do
|
19
16
|
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(true)
|
20
17
|
end
|
21
|
-
should "false
|
18
|
+
should "'false' value not changed" do
|
22
19
|
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(false)
|
23
20
|
end
|
24
|
-
should "0" do
|
21
|
+
should "'0' is change to 'false'" do
|
25
22
|
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call(0)
|
26
23
|
end
|
27
|
-
should "1" do
|
24
|
+
should "'1' is change to 'true'" do
|
28
25
|
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(1)
|
29
26
|
end
|
30
|
-
should "-1" do
|
27
|
+
should "'-1' is change to 'true'" do
|
31
28
|
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(-1)
|
32
29
|
end
|
33
|
-
should "
|
34
|
-
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call("")
|
35
|
-
end
|
36
|
-
should "文字" do
|
30
|
+
should "'string data' is change to 'true'" do
|
37
31
|
assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call("Hello")
|
38
32
|
end
|
33
|
+
should "'empty string' is change to 'true'" do
|
34
|
+
assert_equal false, Flextures::Loader::TRANSLATER[:boolean].call("")
|
35
|
+
end
|
39
36
|
end
|
40
37
|
context :date do
|
41
38
|
should "正常値の文字列" do
|
@@ -174,6 +171,84 @@ class FlexturesLoaderTest < Test::Unit::TestCase
|
|
174
171
|
end
|
175
172
|
end
|
176
173
|
end
|
174
|
+
|
175
|
+
context ".stair_list" do
|
176
|
+
context " stair is 'false' " do
|
177
|
+
context "argument is null" do
|
178
|
+
setup do
|
179
|
+
@list = Flextures::Loader::stair_list nil, false
|
180
|
+
end
|
181
|
+
should " return array include only empty string" do
|
182
|
+
assert_equal @list, [""]
|
183
|
+
end
|
184
|
+
end
|
185
|
+
context "argument is empty string" do
|
186
|
+
setup do
|
187
|
+
@list = Flextures::Loader::stair_list "", false
|
188
|
+
end
|
189
|
+
should " return array include only empty string" do
|
190
|
+
assert_equal @list, [""]
|
191
|
+
end
|
192
|
+
end
|
193
|
+
context "include '/' mark" do
|
194
|
+
setup do
|
195
|
+
@list = Flextures::Loader::stair_list "a/b/c", false
|
196
|
+
end
|
197
|
+
should " return directory list" do
|
198
|
+
assert_equal @list, ["a/b/c"]
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
context " stair is 'true' " do
|
203
|
+
context "argument is null" do
|
204
|
+
setup do
|
205
|
+
@list = Flextures::Loader::stair_list nil, true
|
206
|
+
end
|
207
|
+
should " return array include only empty string" do
|
208
|
+
assert_equal @list, [""]
|
209
|
+
end
|
210
|
+
end
|
211
|
+
context "argument is empty string" do
|
212
|
+
setup do
|
213
|
+
@list = Flextures::Loader::stair_list "", true
|
214
|
+
end
|
215
|
+
should " return array include only empty string" do
|
216
|
+
assert_equal @list, [""]
|
217
|
+
end
|
218
|
+
end
|
219
|
+
context "include '/' mark" do
|
220
|
+
setup do
|
221
|
+
@list = Flextures::Loader::stair_list "a/b/c", true
|
222
|
+
end
|
223
|
+
should " return directory list" do
|
224
|
+
assert_equal @list, ["a/b/c","a/b","a",""]
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
context ".loading_order" do
|
231
|
+
context "simple test" do
|
232
|
+
setup do
|
233
|
+
@proc = Flextures::Loader.loading_order
|
234
|
+
end
|
235
|
+
should "not sort" do
|
236
|
+
assert_equal ["a","b","c"].sort(&@proc), ["a","b","c"]
|
237
|
+
end
|
238
|
+
end
|
239
|
+
context "set orderd table name" do
|
240
|
+
setup do
|
241
|
+
Flextures::Config.table_load_order=["b"]
|
242
|
+
@proc = Flextures::Loader.loading_order
|
243
|
+
end
|
244
|
+
should "first table name is setted table" do
|
245
|
+
assert_equal ["a","b","c"].sort(&@proc), ["b","a","c"]
|
246
|
+
end
|
247
|
+
teardown do
|
248
|
+
Flextures::Config.table_load_order=[]
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
177
252
|
end
|
178
253
|
end
|
179
254
|
|
data/test/unit/test_simple.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flextures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,40 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70233206393700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.3.5
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - '='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.2.0
|
24
|
+
version_requirements: *70233206393700
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: jeweler
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70233206392820 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
|
-
- -
|
30
|
+
- - =
|
36
31
|
- !ruby/object:Gem::Version
|
37
32
|
version: 1.8.3
|
38
33
|
type: :development
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - '='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.8.3
|
35
|
+
version_requirements: *70233206392820
|
46
36
|
description: load and dump fixtures
|
47
37
|
email: babanba.n@gmail.com
|
48
38
|
executables: []
|
@@ -80,6 +70,7 @@ files:
|
|
80
70
|
- test/unit/test_flextures.rb
|
81
71
|
- test/unit/test_flextures_args.rb
|
82
72
|
- test/unit/test_flextures_dumper.rb
|
73
|
+
- test/unit/test_flextures_extention_modules.rb
|
83
74
|
- test/unit/test_flextures_hooks.rb
|
84
75
|
- test/unit/test_flextures_loader.rb
|
85
76
|
- test/unit/test_simple.rb
|
@@ -98,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
89
|
version: '0'
|
99
90
|
segments:
|
100
91
|
- 0
|
101
|
-
hash:
|
92
|
+
hash: -2779467246243318574
|
102
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
94
|
none: false
|
104
95
|
requirements:
|
@@ -107,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
98
|
version: '0'
|
108
99
|
requirements: []
|
109
100
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.8.
|
101
|
+
rubygems_version: 1.8.10
|
111
102
|
signing_key:
|
112
103
|
specification_version: 3
|
113
104
|
summary: load and dump fixtures
|