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.
@@ -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 "通常動作" do
6
+ context "set one table" do
7
7
  setup do
8
- @ret, @options = Flextures::Loader.parse_flextures_options(:users)
8
+ @list = Flextures::Loader.parse_flextures_options(:users)
9
9
  end
10
- should "指定したテーブル分だけハッシュが返されている" do
11
- assert_equal 1, @ret.size
10
+ should "return table is Array" do
11
+ assert_equal true, @list.is_a?(Array)
12
12
  end
13
- should "ハッシュの中身は読み込み設定のハッシュ" do
14
- h = { table: :users, file: :users, loader: :fun }
15
- assert_equal h, @ret.first
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 "違うファイルをロードした時" do
24
+ context "if set file name option" do
19
25
  setup do
20
- @ret, @options = Flextures::Loader.parse_flextures_options( :users => :users_another3 )
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 "指定したテーブル分だけハッシュが返されている" do
23
- assert_equal 1, @ret.size
31
+ should " 'file' option is changed setted file name" do
32
+ assert_equal :users_another3, @list.first[:file]
24
33
  end
25
- should "ハッシュの中身は読み込み設定のハッシュ" do
34
+ should "returned data include data" do
26
35
  h = { table: :users, file: :users_another3, loader: :fun }
27
- assert_equal h, @ret.first
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 "オプション指定があった時" do
79
+ context " if set 'model' and 'method' option " do
31
80
  setup do
32
- @ret, @options = Flextures::Loader.parse_flextures_options({ cache: true }, :users)
81
+ @list = Flextures::Loader.parse_flextures_options( { model: "users", method:"login" }, :users )
33
82
  end
34
- should "オプションを取り出している" do
35
- assert_equal true, @options[:cache]
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はそのまま" do
12
+ should "'nil' value not changed" do
16
13
  assert_equal nil, Flextures::Loader::TRANSLATER[:boolean].call(nil)
17
14
  end
18
- should "trueもそのまま" do
15
+ should "'true' value not changed" do
19
16
  assert_equal true, Flextures::Loader::TRANSLATER[:boolean].call(true)
20
17
  end
21
- should "falseもそのまま" do
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 "空白文字" do
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
 
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class SimpleTest < Test::Unit::TestCase
4
- should "テストの作動確認" do
4
+ should "comfirm should move" do
5
5
  assert_equal true, true
6
6
  end
7
7
  end
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: 2.1.0
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-02-03 00:00:00.000000000 Z
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.2.0
21
+ version: 1.3.5
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
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: !ruby/object:Gem::Requirement
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: 586239309
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.25
101
+ rubygems_version: 1.8.10
111
102
  signing_key:
112
103
  specification_version: 3
113
104
  summary: load and dump fixtures