menu_helper 0.0.1 → 0.0.4
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/CHANGELOG +31 -0
- data/MIT-LICENSE +2 -2
- data/README +30 -33
- data/Rakefile +9 -8
- data/lib/menu_helper/html_element.rb +45 -47
- data/lib/menu_helper/menu.rb +98 -93
- data/lib/menu_helper/menu_bar.rb +141 -141
- data/lib/menu_helper.rb +72 -73
- data/test/app_root/log/in_memory.log +1 -0
- data/test/test_helper.rb +1 -3
- data/test/unit/html_element_test.rb +73 -49
- data/test/unit/menu_bar_test.rb +31 -19
- data/test/unit/menu_helper_test.rb +5 -5
- data/test/unit/menu_test.rb +28 -23
- metadata +57 -47
data/test/unit/menu_bar_test.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
3
|
-
class
|
4
|
-
def
|
5
|
-
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class MenuBarByDefaultTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller)
|
6
7
|
end
|
7
8
|
|
8
9
|
def test_should_have_no_menus_by_default
|
9
|
-
|
10
|
-
assert_equal [], menu_bar.menus
|
10
|
+
assert_equal [], @menu_bar.menus
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_should_set_default_id_if_no_parent_specified
|
14
|
-
|
15
|
-
assert_equal 'menubar', menu_bar[:id]
|
14
|
+
assert_equal 'menubar', @menu_bar[:id]
|
16
15
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
class MenuBarTest < Test::Unit::TestCase
|
19
|
+
def test_should_raise_exception_if_invalid_option_specified
|
20
|
+
assert_raise(ArgumentError) {create_menu_bar(:invalid => true)}
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_should_accept_block
|
@@ -47,14 +47,26 @@ class MenuBarTest < Test::Unit::TestCase
|
|
47
47
|
expected = <<-eos
|
48
48
|
<ul id="menubar">
|
49
49
|
<li id="home"><a href="http://test.host/">Home</a></li>
|
50
|
-
<li class="last
|
50
|
+
<li class="selected last" id="contact"><a href="http://test.host/contact">Contact Us</a></li>
|
51
51
|
</ul>
|
52
52
|
eos
|
53
|
-
assert_equal expected.gsub(/\n\s*/, ''), menu_bar.
|
53
|
+
assert_equal expected.gsub(/\n\s*/, ''), menu_bar.html
|
54
54
|
end
|
55
55
|
|
56
56
|
private
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
57
|
+
def create_menu_bar(*args, &block)
|
58
|
+
PluginAWeek::MenuHelper::MenuBar.new(@controller, *args, &block)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class MenuBarWithParentTest < Test::Unit::TestCase
|
63
|
+
def setup
|
64
|
+
super
|
65
|
+
parent = PluginAWeek::MenuHelper::Menu.new(:home, @controller)
|
66
|
+
@menu_bar = PluginAWeek::MenuHelper::MenuBar.new(@controller, {}, {}, parent)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_should_set_default_id_based_on_parent
|
70
|
+
assert_equal 'home_menubar', @menu_bar[:id]
|
71
|
+
end
|
72
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
3
|
class MenuHelperTest < Test::Unit::TestCase
|
4
|
-
include PluginAWeek::
|
4
|
+
include PluginAWeek::MenuHelper
|
5
5
|
|
6
6
|
def test_should_build_menu_bar
|
7
7
|
menu_bar_html = menu_bar({}, :class => 'pretty') do |main|
|
@@ -26,5 +26,5 @@ class MenuHelperTest < Test::Unit::TestCase
|
|
26
26
|
</ul>
|
27
27
|
eos
|
28
28
|
assert_equal expected.gsub(/\n\s*/, ''), menu_bar_html
|
29
|
-
end
|
30
|
-
end
|
29
|
+
end
|
30
|
+
end
|
data/test/unit/menu_test.rb
CHANGED
@@ -1,19 +1,24 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
class
|
4
|
-
def
|
5
|
-
|
6
|
-
|
3
|
+
class MenuByDefaultTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@menu = PluginAWeek::MenuHelper::Menu.new(:home, @controller)
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
assert_equal 'home', menu[:id]
|
9
|
+
def test_should_use_humanized_id_for_content
|
10
|
+
assert_equal '<li id="home"><a href="http://test.host/">Home</a></li>', @menu.html
|
12
11
|
end
|
13
12
|
|
13
|
+
def test_should_set_html_id_to_id
|
14
|
+
assert_equal 'home', @menu[:id]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class MenuTest < Test::Unit::TestCase
|
14
19
|
def test_should_not_linkify_if_not_auto_linking
|
15
20
|
menu = create_menu(:home, nil, :auto_link => false)
|
16
|
-
assert_equal '<li id="home">Home</li>', menu.
|
21
|
+
assert_equal '<li id="home">Home</li>', menu.html
|
17
22
|
end
|
18
23
|
|
19
24
|
def test_default_menubar_id_should_use_menu_id
|
@@ -120,27 +125,27 @@ class MenuTest < Test::Unit::TestCase
|
|
120
125
|
|
121
126
|
def test_should_include_selected_class_in_html_if_selected
|
122
127
|
menu = create_menu(:contact)
|
123
|
-
assert_equal '<li class="selected" id="contact"><a href="http://test.host/contact">Contact</a></li>', menu.
|
128
|
+
assert_equal '<li class="selected" id="contact"><a href="http://test.host/contact">Contact</a></li>', menu.html
|
124
129
|
end
|
125
130
|
|
126
|
-
def
|
131
|
+
def test_should_append_selected_class_if_class_attribute_already_exists
|
127
132
|
menu = create_menu(:contact, nil, {}, :class => 'pretty')
|
128
|
-
assert_equal '<li class="selected
|
133
|
+
assert_equal '<li class="pretty selected" id="contact"><a href="http://test.host/contact">Contact</a></li>', menu.html
|
129
134
|
end
|
130
135
|
|
131
136
|
def test_should_include_last_class_in_html_if_last_menu
|
132
137
|
menu = create_menu(:home)
|
133
|
-
assert_equal '<li class="last" id="home"><a href="http://test.host/">Home</a></li>', menu.
|
138
|
+
assert_equal '<li class="last" id="home"><a href="http://test.host/">Home</a></li>', menu.html(true)
|
134
139
|
end
|
135
140
|
|
136
|
-
def
|
141
|
+
def test_should_append_last_class_if_class_attribute_already_exists
|
137
142
|
menu = create_menu(:home, nil, {}, :class => 'pretty')
|
138
|
-
assert_equal '<li class="last
|
143
|
+
assert_equal '<li class="pretty last" id="home"><a href="http://test.host/">Home</a></li>', menu.html(true)
|
139
144
|
end
|
140
145
|
|
141
146
|
def test_should_not_modify_html_options_after_building_menu
|
142
147
|
menu = create_menu(:home)
|
143
|
-
menu.
|
148
|
+
menu.html
|
144
149
|
assert_nil menu[:class]
|
145
150
|
end
|
146
151
|
|
@@ -154,19 +159,19 @@ class MenuTest < Test::Unit::TestCase
|
|
154
159
|
expected = <<-eos
|
155
160
|
<li class="selected" id="home"><a href="http://test.host/">Home</a>
|
156
161
|
<ul id="home_menubar">
|
157
|
-
<li class="last
|
162
|
+
<li class="selected last" id="about_us"><a href="http://test.host/about_us">About Us</a>
|
158
163
|
<ul id="about_us_menubar">
|
159
|
-
<li class="last
|
164
|
+
<li class="selected last" id="contact"><a href="http://test.host/contact">Contact</a></li>
|
160
165
|
</ul>
|
161
166
|
</li>
|
162
167
|
</ul>
|
163
168
|
</li>
|
164
169
|
eos
|
165
|
-
assert_equal expected.gsub(/\n\s*/, ''), menu.
|
170
|
+
assert_equal expected.gsub(/\n\s*/, ''), menu.html
|
166
171
|
end
|
167
172
|
|
168
173
|
private
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
end
|
174
|
+
def create_menu(id, parent = nil, *args, &block)
|
175
|
+
PluginAWeek::MenuHelper::Menu.new(id, @controller, parent, *args, &block)
|
176
|
+
end
|
177
|
+
end
|
metadata
CHANGED
@@ -1,71 +1,81 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: menu_helper
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-08-16 00:00:00 -04:00
|
8
|
-
summary: Adds a helper method for generating a menubar
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: info@pluginaweek.org
|
12
|
-
homepage: http://www.pluginaweek.org
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
15
|
-
autorequire: menu_helper
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.0.4
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
|
-
- Aaron Pfeifer
|
7
|
+
- Aaron Pfeifer
|
8
|
+
autorequire: menu_helper
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-01 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: aaron@pluginaweek.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
31
24
|
files:
|
32
25
|
- lib/menu_helper.rb
|
33
26
|
- lib/menu_helper
|
27
|
+
- lib/menu_helper/menu.rb
|
34
28
|
- lib/menu_helper/html_element.rb
|
35
29
|
- lib/menu_helper/menu_bar.rb
|
36
|
-
- lib/menu_helper/menu.rb
|
37
|
-
- test/test_helper.rb
|
38
30
|
- test/app_root
|
39
|
-
- test/unit
|
40
|
-
- test/app_root/config
|
41
31
|
- test/app_root/app
|
42
|
-
- test/app_root/config/routes.rb
|
43
32
|
- test/app_root/app/controllers
|
44
|
-
- test/app_root/app/controllers/contact_controller.rb
|
45
|
-
- test/app_root/app/controllers/about_us_controller.rb
|
46
33
|
- test/app_root/app/controllers/home_controller.rb
|
47
|
-
- test/
|
34
|
+
- test/app_root/app/controllers/about_us_controller.rb
|
35
|
+
- test/app_root/app/controllers/contact_controller.rb
|
36
|
+
- test/app_root/config
|
37
|
+
- test/app_root/config/routes.rb
|
38
|
+
- test/app_root/log
|
39
|
+
- test/app_root/log/in_memory.log
|
40
|
+
- test/test_helper.rb
|
41
|
+
- test/unit
|
42
|
+
- test/unit/menu_bar_test.rb
|
48
43
|
- test/unit/menu_test.rb
|
49
44
|
- test/unit/menu_helper_test.rb
|
50
|
-
- test/unit/
|
45
|
+
- test/unit/html_element_test.rb
|
46
|
+
- CHANGELOG
|
51
47
|
- init.rb
|
52
48
|
- MIT-LICENSE
|
53
49
|
- Rakefile
|
54
50
|
- README
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
- test/unit/menu_helper_test.rb
|
59
|
-
- test/unit/menu_bar_test.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://www.pluginaweek.org
|
53
|
+
post_install_message:
|
60
54
|
rdoc_options: []
|
61
55
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
68
70
|
requirements: []
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.1.1
|
74
|
+
signing_key:
|
75
|
+
specification_version: 2
|
76
|
+
summary: Adds a helper method for generating a menubar
|
77
|
+
test_files:
|
78
|
+
- test/unit/menu_bar_test.rb
|
79
|
+
- test/unit/menu_test.rb
|
80
|
+
- test/unit/menu_helper_test.rb
|
81
|
+
- test/unit/html_element_test.rb
|