menu_maker 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/menu_maker/menu.rb +3 -3
- data/lib/menu_maker/menu_renderer.rb +1 -1
- data/lib/menu_maker/path.rb +55 -36
- data/lib/menu_maker/version.rb +1 -1
- data/test/dummy/log/test.log +6705 -0
- data/test/menu_item_test.rb +4 -4
- data/test/path_test.rb +8 -14
- metadata +1 -1
data/test/menu_item_test.rb
CHANGED
@@ -12,7 +12,7 @@ module MenuMaker
|
|
12
12
|
|
13
13
|
test 'accepts many paths' do
|
14
14
|
item = Menu::MenuItem.new 'My title', 'path/1', 'path/2', 'path/3'
|
15
|
-
assert_equal ['path/1', 'path/2', 'path/3'], item.paths.map(&:
|
15
|
+
assert_equal ['path/1', 'path/2', 'path/3'], item.paths.map(&:path)
|
16
16
|
end
|
17
17
|
|
18
18
|
test 'submenu_paths returns submenu paths recursively' do
|
@@ -33,7 +33,7 @@ module MenuMaker
|
|
33
33
|
|
34
34
|
expected = %w[level/2 level/2/1 level/2/2 level/3 level/4 level/5 level/6]
|
35
35
|
|
36
|
-
assert_equal expected, item.submenu_paths.map(&:
|
36
|
+
assert_equal expected, item.submenu_paths.map(&:path).sort
|
37
37
|
end
|
38
38
|
|
39
39
|
test 'all_paths returns submenu paths + current menu path' do
|
@@ -52,7 +52,7 @@ module MenuMaker
|
|
52
52
|
|
53
53
|
expected = %w[level/1 level/2 level/3 level/4 level/5 level/6]
|
54
54
|
|
55
|
-
assert_equal expected, item.all_paths.map(&:
|
55
|
+
assert_equal expected, item.all_paths.map(&:path).sort
|
56
56
|
end
|
57
57
|
|
58
58
|
test 'has_path? also checks for submenus' do
|
@@ -78,7 +78,7 @@ module MenuMaker
|
|
78
78
|
menu = Menu.new proc {}
|
79
79
|
menu.add('Item', 'path/1', [:post, 'path/2'], [:put, 'path/3'], option: 'optional')
|
80
80
|
|
81
|
-
result = menu.items.first.paths.map(&:
|
81
|
+
result = menu.items.first.paths.map(&:path)
|
82
82
|
|
83
83
|
expected = %w[path/1 path/2 path/3]
|
84
84
|
|
data/test/path_test.rb
CHANGED
@@ -14,29 +14,29 @@ module MenuMaker
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
test 'to_s returns the
|
17
|
+
test 'to_s returns the path string' do
|
18
18
|
assert_equal '/path', Path.new(:get, '/path').to_s
|
19
19
|
end
|
20
20
|
|
21
21
|
test 'creates a get path from a given string' do
|
22
|
-
assert_equal Path.new(:get, '/path'), Path.convert('/path')
|
22
|
+
assert_equal Path.new(:get, '/path'), Path::Converter.convert('/path')
|
23
23
|
end
|
24
24
|
|
25
25
|
test 'creates a path from an array' do
|
26
|
-
assert_equal Path.new(:post, '/path'), Path.convert([:post, '/path'])
|
26
|
+
assert_equal Path.new(:post, '/path'), Path::Converter.convert([:post, '/path'])
|
27
27
|
end
|
28
28
|
|
29
29
|
test "creates a path from an array assumes get when can't find request method" do
|
30
|
-
assert_equal Path.new(:get, '/path'), Path.convert(['/path'])
|
30
|
+
assert_equal Path.new(:get, '/path'), Path::Converter.convert(['/path'])
|
31
31
|
end
|
32
32
|
|
33
33
|
test "creates a path from an array on empty array creates empty get path" do
|
34
|
-
assert_equal Path.new(:get, ''), Path.convert([])
|
34
|
+
assert_equal Path.new(:get, ''), Path::Converter.convert([])
|
35
35
|
end
|
36
36
|
|
37
37
|
test "returns back the path if already a Path" do
|
38
38
|
path = Path.new :put, '/path'
|
39
|
-
assert_equal path, Path.convert(path)
|
39
|
+
assert_equal path, Path::Converter.convert(path)
|
40
40
|
end
|
41
41
|
|
42
42
|
test "creates a path from an object wich responds to path and method" do
|
@@ -50,18 +50,12 @@ module MenuMaker
|
|
50
50
|
end
|
51
51
|
end.new
|
52
52
|
|
53
|
-
assert_equal Path.new(:put, '/path'), Path.convert(request)
|
53
|
+
assert_equal Path.new(:put, '/path'), Path::Converter.convert(request)
|
54
54
|
end
|
55
55
|
|
56
56
|
test "fails if can't create path from object which responds to path and method" do
|
57
57
|
assert_raise Path::PathError do
|
58
|
-
Path.convert(Object.new)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
test "from_path fails when not a path" do
|
63
|
-
assert_raise Path::PathError do
|
64
|
-
Path.from_path(Object.new)
|
58
|
+
Path::Converter.convert(Object.new)
|
65
59
|
end
|
66
60
|
end
|
67
61
|
|