navi 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +41 -0
- data/Gemfile.lock +196 -0
- data/Guardfile +23 -0
- data/LICENSE.txt +20 -0
- data/README.textile +26 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/features/create_menu_items.feature +13 -0
- data/features/step_definitions/category_steps.rb +3 -0
- data/features/step_definitions/menu_item_steps.rb +19 -0
- data/features/step_definitions/page_steps.rb +3 -0
- data/features/step_definitions/web_steps.rb +211 -0
- data/features/support/env.rb +61 -0
- data/features/support/paths.rb +33 -0
- data/features/support/selectors.rb +39 -0
- data/lib/navi/helpers.rb +24 -0
- data/lib/navi/navigable/base.rb +16 -0
- data/lib/navi/navigable/instance_methods.rb +24 -0
- data/lib/navi/navigator/.base.rb.swo +0 -0
- data/lib/navi/navigator/base.rb +11 -0
- data/lib/navi/navigator/class_methods.rb +27 -0
- data/lib/navi/navigator/instance_methods.rb +57 -0
- data/lib/navi/railtie.rb +11 -0
- data/lib/navi/renderers/base.rb +31 -0
- data/lib/navi/renderers/simple_navigation.rb +30 -0
- data/lib/navi.rb +29 -0
- data/navi.gemspec +281 -0
- data/spec/blueprints.rb +16 -0
- data/spec/dummy/.gitignore +6 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/categories_controller.rb +7 -0
- data/spec/dummy/app/controllers/menu_items_controller.rb +15 -0
- data/spec/dummy/app/controllers/pages_controller.rb +7 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/category.rb +3 -0
- data/spec/dummy/app/models/menu_item.rb +2 -0
- data/spec/dummy/app/models/page.rb +3 -0
- data/spec/dummy/app/views/categories/_form.html.haml +2 -0
- data/spec/dummy/app/views/categories/edit.html.haml +5 -0
- data/spec/dummy/app/views/categories/index.html.haml +17 -0
- data/spec/dummy/app/views/categories/new.html.haml +5 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/menu_items/edit.html.haml +14 -0
- data/spec/dummy/app/views/menu_items/index.html.haml +11 -0
- data/spec/dummy/app/views/pages/_form.html.haml +2 -0
- data/spec/dummy/app/views/pages/edit.html.haml +5 -0
- data/spec/dummy/app/views/pages/index.html.haml +17 -0
- data/spec/dummy/app/views/pages/new.html.haml +5 -0
- data/spec/dummy/app/widgets/menu_editor/category/form/.display.html.haml.swo +0 -0
- data/spec/dummy/app/widgets/menu_editor/category/form/display.html.haml +7 -0
- data/spec/dummy/app/widgets/menu_editor/category/form_widget.rb +18 -0
- data/spec/dummy/app/widgets/menu_editor/display.html.haml +5 -0
- data/spec/dummy/app/widgets/menu_editor/page/form/.display.html.haml.swo +0 -0
- data/spec/dummy/app/widgets/menu_editor/page/form/display.html.haml +8 -0
- data/spec/dummy/app/widgets/menu_editor/page/form_widget.rb +18 -0
- data/spec/dummy/app/widgets/menu_editor/tree/display.html.haml +4 -0
- data/spec/dummy/app/widgets/menu_editor/tree/item.html.haml +7 -0
- data/spec/dummy/app/widgets/menu_editor/tree/items.html.haml +2 -0
- data/spec/dummy/app/widgets/menu_editor/tree_widget.rb +48 -0
- data/spec/dummy/app/widgets/menu_editor_widget.rb +11 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/cucumber.yml +8 -0
- data/spec/dummy/config/database.yml +19 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/navigable.rb +1 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/navigation.rb +7 -0
- data/spec/dummy/config/routes.rb +61 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20110607155019_create_menu_items.rb +20 -0
- data/spec/dummy/db/migrate/20110607155202_create_categories.rb +13 -0
- data/spec/dummy/db/migrate/20110607160052_create_pages.rb +13 -0
- data/spec/dummy/db/schema.rb +41 -0
- data/spec/dummy/db/seeds.rb +15 -0
- data/spec/dummy/lib/tasks/.gitkeep +0 -0
- data/spec/dummy/lib/tasks/cucumber.rake +57 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/images/rails.png +0 -0
- data/spec/dummy/public/index.html +239 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/jquery-ui.js +11603 -0
- data/spec/dummy/public/javascripts/jquery-ui.min.js +406 -0
- data/spec/dummy/public/javascripts/jquery.js +8936 -0
- data/spec/dummy/public/javascripts/jquery.min.js +18 -0
- data/spec/dummy/public/javascripts/jquery_ujs.js +315 -0
- data/spec/dummy/public/javascripts/menu_items/index.js +40 -0
- data/spec/dummy/public/javascripts/rails.js +315 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/cucumber +10 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/navi/helpers_spec.rb +5 -0
- data/spec/navi/navi_spec.rb +76 -0
- data/spec/navi/navigator_spec.rb +204 -0
- data/spec/navi/renderers/simple_navigation_spec.rb +49 -0
- data/spec/spec_helper.rb +125 -0
- metadata +683 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm @navi
|
data/Gemfile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# These gems are the only ones that this gem needs
|
4
|
+
gem "activesupport", ">= 3.0.0"
|
5
|
+
gem "activerecord", ">= 3.0.0"
|
6
|
+
gem "ordered_tree", "0.1.2"
|
7
|
+
|
8
|
+
# Comment out group block first because cucumber features were complaining that
|
9
|
+
# These gems didn't exist, even if the group included the cucumber/test
|
10
|
+
# group! `bundle exec guard` doesn't work!
|
11
|
+
#group :development, :test, :cucumber do
|
12
|
+
gem "rspec", "~> 2.6.0"
|
13
|
+
gem "bundler", "~> 1.0.0"
|
14
|
+
gem "jeweler", "~> 1.5.2"
|
15
|
+
gem "rcov", ">= 0"
|
16
|
+
gem "simple-navigation", "3.2.0"
|
17
|
+
gem 'inherited_resources'
|
18
|
+
gem 'guard-rspec'
|
19
|
+
gem 'libnotify'
|
20
|
+
gem 'rb-inotify'
|
21
|
+
gem 'sqlite3'
|
22
|
+
# force the use of rake version, because of http://stackoverflow.com/questions/6199301/global-access-to-rake-dsl-methods-is-deprecated
|
23
|
+
gem 'rake', '0.8.7'
|
24
|
+
gem 'apotomo', '1.1.1'
|
25
|
+
gem 'rails', '3.0.7'
|
26
|
+
gem 'haml'
|
27
|
+
gem 'simple-navigation', '3.2.0'
|
28
|
+
gem 'jquery-rails', '>= 1.0.3'
|
29
|
+
gem 'rspec-rails', '2.6.1'
|
30
|
+
gem 'cucumber-rails', '0.5.2'
|
31
|
+
gem 'cucumber'
|
32
|
+
gem 'capybara', ">= 1.0.0.rc1"
|
33
|
+
gem 'database_cleaner'
|
34
|
+
gem 'launchy'
|
35
|
+
gem 'machinist'
|
36
|
+
gem 'faker'
|
37
|
+
gem 'guard-cucumber', '0.3.4'
|
38
|
+
gem 'libnotify'
|
39
|
+
gem 'rb-inotify'
|
40
|
+
gem 'nifty-generators'
|
41
|
+
#end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.7)
|
6
|
+
actionpack (= 3.0.7)
|
7
|
+
mail (~> 2.2.15)
|
8
|
+
actionpack (3.0.7)
|
9
|
+
activemodel (= 3.0.7)
|
10
|
+
activesupport (= 3.0.7)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.7)
|
19
|
+
activesupport (= 3.0.7)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.7)
|
23
|
+
activemodel (= 3.0.7)
|
24
|
+
activesupport (= 3.0.7)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.7)
|
28
|
+
activemodel (= 3.0.7)
|
29
|
+
activesupport (= 3.0.7)
|
30
|
+
activesupport (3.0.7)
|
31
|
+
apotomo (1.1.1)
|
32
|
+
cells (~> 3.5.6)
|
33
|
+
hooks (~> 0.1.3)
|
34
|
+
onfire (~> 0.2.0)
|
35
|
+
rails (~> 3.0)
|
36
|
+
arel (2.0.10)
|
37
|
+
builder (2.1.2)
|
38
|
+
capybara (1.0.0.rc1)
|
39
|
+
mime-types (>= 1.16)
|
40
|
+
nokogiri (>= 1.3.3)
|
41
|
+
rack (>= 1.0.0)
|
42
|
+
rack-test (>= 0.5.4)
|
43
|
+
selenium-webdriver (~> 0.2.0)
|
44
|
+
xpath (~> 0.1.4)
|
45
|
+
cells (3.5.6)
|
46
|
+
actionpack (~> 3.0.0)
|
47
|
+
railties (~> 3.0.0)
|
48
|
+
childprocess (0.1.9)
|
49
|
+
ffi (~> 1.0.6)
|
50
|
+
configuration (1.2.0)
|
51
|
+
cucumber (0.10.6)
|
52
|
+
builder (>= 2.1.2)
|
53
|
+
diff-lcs (>= 1.1.2)
|
54
|
+
gherkin (~> 2.4.0)
|
55
|
+
json (>= 1.4.6)
|
56
|
+
term-ansicolor (>= 1.0.5)
|
57
|
+
cucumber-rails (0.5.2)
|
58
|
+
capybara (>= 1.0.0.rc1)
|
59
|
+
cucumber (>= 0.10.5)
|
60
|
+
nokogiri (>= 1.4.4)
|
61
|
+
rack-test (>= 0.5.7)
|
62
|
+
database_cleaner (0.6.7)
|
63
|
+
diff-lcs (1.1.2)
|
64
|
+
erubis (2.6.6)
|
65
|
+
abstract (>= 1.0.0)
|
66
|
+
faker (0.9.5)
|
67
|
+
i18n (~> 0.4)
|
68
|
+
ffi (1.0.9)
|
69
|
+
gherkin (2.4.0)
|
70
|
+
json (>= 1.4.6)
|
71
|
+
git (1.2.5)
|
72
|
+
guard (0.3.4)
|
73
|
+
thor (~> 0.14.6)
|
74
|
+
guard-cucumber (0.3.4)
|
75
|
+
cucumber (~> 0.10.0)
|
76
|
+
guard (~> 0.3.0)
|
77
|
+
guard-rspec (0.3.1)
|
78
|
+
guard (>= 0.2.2)
|
79
|
+
haml (3.1.2)
|
80
|
+
has_scope (0.5.0)
|
81
|
+
hooks (0.1.4)
|
82
|
+
i18n (0.5.0)
|
83
|
+
inherited_resources (1.2.2)
|
84
|
+
has_scope (~> 0.5.0)
|
85
|
+
responders (~> 0.6.0)
|
86
|
+
jeweler (1.5.2)
|
87
|
+
bundler (~> 1.0.0)
|
88
|
+
git (>= 1.2.5)
|
89
|
+
rake
|
90
|
+
jquery-rails (1.0.9)
|
91
|
+
railties (~> 3.0)
|
92
|
+
thor (~> 0.14)
|
93
|
+
json (1.5.1)
|
94
|
+
json_pure (1.5.1)
|
95
|
+
launchy (0.4.0)
|
96
|
+
configuration (>= 0.0.5)
|
97
|
+
rake (>= 0.8.1)
|
98
|
+
libnotify (0.5.5)
|
99
|
+
machinist (1.0.6)
|
100
|
+
mail (2.2.19)
|
101
|
+
activesupport (>= 2.3.6)
|
102
|
+
i18n (>= 0.4.0)
|
103
|
+
mime-types (~> 1.16)
|
104
|
+
treetop (~> 1.4.8)
|
105
|
+
mime-types (1.16)
|
106
|
+
nifty-generators (0.4.6)
|
107
|
+
nokogiri (1.4.4)
|
108
|
+
onfire (0.2.0)
|
109
|
+
ordered_tree (0.1.2)
|
110
|
+
activerecord (>= 3.0.0)
|
111
|
+
polyglot (0.3.1)
|
112
|
+
rack (1.2.3)
|
113
|
+
rack-mount (0.6.14)
|
114
|
+
rack (>= 1.0.0)
|
115
|
+
rack-test (0.5.7)
|
116
|
+
rack (>= 1.0)
|
117
|
+
rails (3.0.7)
|
118
|
+
actionmailer (= 3.0.7)
|
119
|
+
actionpack (= 3.0.7)
|
120
|
+
activerecord (= 3.0.7)
|
121
|
+
activeresource (= 3.0.7)
|
122
|
+
activesupport (= 3.0.7)
|
123
|
+
bundler (~> 1.0)
|
124
|
+
railties (= 3.0.7)
|
125
|
+
railties (3.0.7)
|
126
|
+
actionpack (= 3.0.7)
|
127
|
+
activesupport (= 3.0.7)
|
128
|
+
rake (>= 0.8.7)
|
129
|
+
thor (~> 0.14.4)
|
130
|
+
rake (0.8.7)
|
131
|
+
rb-inotify (0.8.5)
|
132
|
+
ffi (>= 0.5.0)
|
133
|
+
rcov (0.9.9)
|
134
|
+
responders (0.6.4)
|
135
|
+
rspec (2.6.0)
|
136
|
+
rspec-core (~> 2.6.0)
|
137
|
+
rspec-expectations (~> 2.6.0)
|
138
|
+
rspec-mocks (~> 2.6.0)
|
139
|
+
rspec-core (2.6.4)
|
140
|
+
rspec-expectations (2.6.0)
|
141
|
+
diff-lcs (~> 1.1.2)
|
142
|
+
rspec-mocks (2.6.0)
|
143
|
+
rspec-rails (2.6.1)
|
144
|
+
actionpack (~> 3.0)
|
145
|
+
activesupport (~> 3.0)
|
146
|
+
railties (~> 3.0)
|
147
|
+
rspec (~> 2.6.0)
|
148
|
+
rubyzip (0.9.4)
|
149
|
+
selenium-webdriver (0.2.1)
|
150
|
+
childprocess (>= 0.1.7)
|
151
|
+
ffi (>= 1.0.7)
|
152
|
+
json_pure
|
153
|
+
rubyzip
|
154
|
+
simple-navigation (3.2.0)
|
155
|
+
activesupport (>= 2.3.2)
|
156
|
+
sqlite3 (1.3.3)
|
157
|
+
term-ansicolor (1.0.5)
|
158
|
+
thor (0.14.6)
|
159
|
+
treetop (1.4.9)
|
160
|
+
polyglot (>= 0.3.1)
|
161
|
+
tzinfo (0.3.27)
|
162
|
+
xpath (0.1.4)
|
163
|
+
nokogiri (~> 1.3)
|
164
|
+
|
165
|
+
PLATFORMS
|
166
|
+
ruby
|
167
|
+
|
168
|
+
DEPENDENCIES
|
169
|
+
activerecord (>= 3.0.0)
|
170
|
+
activesupport (>= 3.0.0)
|
171
|
+
apotomo (= 1.1.1)
|
172
|
+
bundler (~> 1.0.0)
|
173
|
+
capybara (>= 1.0.0.rc1)
|
174
|
+
cucumber
|
175
|
+
cucumber-rails (= 0.5.2)
|
176
|
+
database_cleaner
|
177
|
+
faker
|
178
|
+
guard-cucumber (= 0.3.4)
|
179
|
+
guard-rspec
|
180
|
+
haml
|
181
|
+
inherited_resources
|
182
|
+
jeweler (~> 1.5.2)
|
183
|
+
jquery-rails (>= 1.0.3)
|
184
|
+
launchy
|
185
|
+
libnotify
|
186
|
+
machinist
|
187
|
+
nifty-generators
|
188
|
+
ordered_tree (= 0.1.2)
|
189
|
+
rails (= 3.0.7)
|
190
|
+
rake (= 0.8.7)
|
191
|
+
rb-inotify
|
192
|
+
rcov
|
193
|
+
rspec (~> 2.6.0)
|
194
|
+
rspec-rails (= 2.6.1)
|
195
|
+
simple-navigation (= 3.2.0)
|
196
|
+
sqlite3
|
data/Guardfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2 do
|
5
|
+
watch(%r{^spec/.+_spec\.rb})
|
6
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch('spec/spec_helper.rb') { "spec" }
|
11
|
+
watch('config/routes.rb') { "spec/routing" }
|
12
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
13
|
+
watch(%r{^spec/.+_spec\.rb})
|
14
|
+
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
15
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
16
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
17
|
+
end
|
18
|
+
|
19
|
+
guard 'cucumber' do
|
20
|
+
watch(%r{^features/.+\.feature$})
|
21
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
22
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
23
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Ramon Tayag
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
h1. navigable
|
2
|
+
|
3
|
+
*navigable* puts the navigation (aka menu) in the database. That means you and/or your users can edit and control it. It was made with "WordPress' menu editor":http://dl.dropbox.com/u/16150176/until%20dec%202013/wp-menu.png in mind.
|
4
|
+
|
5
|
+
h2. Installation
|
6
|
+
|
7
|
+
In your Gemfile: @gem 'navigable'@
|
8
|
+
|
9
|
+
h2. Usage
|
10
|
+
|
11
|
+
h2. More on renderers
|
12
|
+
|
13
|
+
h2. Contributing to navigable
|
14
|
+
|
15
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
16
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
17
|
+
* Fork the project
|
18
|
+
* Start a feature/bugfix branch
|
19
|
+
* Commit and push until you are happy with your contribution
|
20
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
21
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
22
|
+
|
23
|
+
h2. Copyright
|
24
|
+
|
25
|
+
Copyright (c) 2011 Ramon Tayag. See LICENSE.txt for
|
26
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "navi"
|
16
|
+
gem.homepage = "http://github.com/ramontayag/navi"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Allows you to save menu items in the database.}
|
19
|
+
gem.description = %Q{Allows you to save menu items in the database. You can create your own renderer.}
|
20
|
+
gem.email = "ramon@tayag.net"
|
21
|
+
gem.authors = ["Ramon Tayag"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "navi #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: So that I can create a menu for my viewers to navigate my site
|
2
|
+
As a user
|
3
|
+
I should be able to manage menu items
|
4
|
+
|
5
|
+
@javascript
|
6
|
+
Scenario: Adding menu items
|
7
|
+
Given a page "Home" exists
|
8
|
+
And a category "Misc" exists
|
9
|
+
And I am on the menu items page
|
10
|
+
When I create the page "Home" menu item
|
11
|
+
Then I should see "Home" in the list of menu items
|
12
|
+
When I create the category "Misc" menu item
|
13
|
+
Then I should see "Misc" in the list of menu items
|
@@ -0,0 +1,19 @@
|
|
1
|
+
When /^I create the page "([^"]*)" menu item$/ do |page_name|
|
2
|
+
within "div#menu_item_page_form" do
|
3
|
+
select page_name, :from => "menu_item_navigable_id"
|
4
|
+
click_button "Save Menu Item"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^I create the category "([^"]*)" menu item$/ do |category_name|
|
9
|
+
within "div#menu_item_category_form" do
|
10
|
+
select category_name, :from => "menu_item_navigable_id"
|
11
|
+
click_button "Save Menu Item"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Then /^I should see "([^"]*)" in the list of menu items$/ do |text|
|
16
|
+
within "div#menu_item_tree" do
|
17
|
+
page.should have_content(text)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
# TL;DR: YOU SHOULD DELETE THIS FILE
|
2
|
+
#
|
3
|
+
# This file was generated by Cucumber-Rails and is only here to get you a head start
|
4
|
+
# These step definitions are thin wrappers around the Capybara/Webrat API that lets you
|
5
|
+
# visit pages, interact with widgets and make assertions about page content.
|
6
|
+
#
|
7
|
+
# If you use these step definitions as basis for your features you will quickly end up
|
8
|
+
# with features that are:
|
9
|
+
#
|
10
|
+
# * Hard to maintain
|
11
|
+
# * Verbose to read
|
12
|
+
#
|
13
|
+
# A much better approach is to write your own higher level step definitions, following
|
14
|
+
# the advice in the following blog posts:
|
15
|
+
#
|
16
|
+
# * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
|
17
|
+
# * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
|
18
|
+
# * http://elabs.se/blog/15-you-re-cuking-it-wrong
|
19
|
+
#
|
20
|
+
|
21
|
+
|
22
|
+
require 'uri'
|
23
|
+
require 'cgi'
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
26
|
+
|
27
|
+
module WithinHelpers
|
28
|
+
def with_scope(locator)
|
29
|
+
locator ? within(*selector_for(locator)) { yield } : yield
|
30
|
+
end
|
31
|
+
end
|
32
|
+
World(WithinHelpers)
|
33
|
+
|
34
|
+
# Single-line step scoper
|
35
|
+
When /^(.*) within ([^:]+)$/ do |step, parent|
|
36
|
+
with_scope(parent) { When step }
|
37
|
+
end
|
38
|
+
|
39
|
+
# Multi-line step scoper
|
40
|
+
When /^(.*) within ([^:]+):$/ do |step, parent, table_or_string|
|
41
|
+
with_scope(parent) { When "#{step}:", table_or_string }
|
42
|
+
end
|
43
|
+
|
44
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
45
|
+
visit path_to(page_name)
|
46
|
+
end
|
47
|
+
|
48
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
49
|
+
visit path_to(page_name)
|
50
|
+
end
|
51
|
+
|
52
|
+
When /^(?:|I )press "([^"]*)"$/ do |button|
|
53
|
+
click_button(button)
|
54
|
+
end
|
55
|
+
|
56
|
+
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
57
|
+
click_link(link)
|
58
|
+
end
|
59
|
+
|
60
|
+
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
61
|
+
fill_in(field, :with => value)
|
62
|
+
end
|
63
|
+
|
64
|
+
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
65
|
+
fill_in(field, :with => value)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Use this to fill in an entire form with data from a table. Example:
|
69
|
+
#
|
70
|
+
# When I fill in the following:
|
71
|
+
# | Account Number | 5002 |
|
72
|
+
# | Expiry date | 2009-11-01 |
|
73
|
+
# | Note | Nice guy |
|
74
|
+
# | Wants Email? | |
|
75
|
+
#
|
76
|
+
# TODO: Add support for checkbox, select og option
|
77
|
+
# based on naming conventions.
|
78
|
+
#
|
79
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
80
|
+
fields.rows_hash.each do |name, value|
|
81
|
+
When %{I fill in "#{name}" with "#{value}"}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
86
|
+
select(value, :from => field)
|
87
|
+
end
|
88
|
+
|
89
|
+
When /^(?:|I )check "([^"]*)"$/ do |field|
|
90
|
+
check(field)
|
91
|
+
end
|
92
|
+
|
93
|
+
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
94
|
+
uncheck(field)
|
95
|
+
end
|
96
|
+
|
97
|
+
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
98
|
+
choose(field)
|
99
|
+
end
|
100
|
+
|
101
|
+
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
102
|
+
attach_file(field, File.expand_path(path))
|
103
|
+
end
|
104
|
+
|
105
|
+
Then /^(?:|I )should see "([^"]*)"$/ do |text|
|
106
|
+
if page.respond_to? :should
|
107
|
+
page.should have_content(text)
|
108
|
+
else
|
109
|
+
assert page.has_content?(text)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
114
|
+
regexp = Regexp.new(regexp)
|
115
|
+
|
116
|
+
if page.respond_to? :should
|
117
|
+
page.should have_xpath('//*', :text => regexp)
|
118
|
+
else
|
119
|
+
assert page.has_xpath?('//*', :text => regexp)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
124
|
+
if page.respond_to? :should
|
125
|
+
page.should have_no_content(text)
|
126
|
+
else
|
127
|
+
assert page.has_no_content?(text)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
132
|
+
regexp = Regexp.new(regexp)
|
133
|
+
|
134
|
+
if page.respond_to? :should
|
135
|
+
page.should have_no_xpath('//*', :text => regexp)
|
136
|
+
else
|
137
|
+
assert page.has_no_xpath?('//*', :text => regexp)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
142
|
+
with_scope(parent) do
|
143
|
+
field = find_field(field)
|
144
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
145
|
+
if field_value.respond_to? :should
|
146
|
+
field_value.should =~ /#{value}/
|
147
|
+
else
|
148
|
+
assert_match(/#{value}/, field_value)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
|
154
|
+
with_scope(parent) do
|
155
|
+
field = find_field(field)
|
156
|
+
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
157
|
+
if field_value.respond_to? :should_not
|
158
|
+
field_value.should_not =~ /#{value}/
|
159
|
+
else
|
160
|
+
assert_no_match(/#{value}/, field_value)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
166
|
+
with_scope(parent) do
|
167
|
+
field_checked = find_field(label)['checked']
|
168
|
+
if field_checked.respond_to? :should
|
169
|
+
field_checked.should be_true
|
170
|
+
else
|
171
|
+
assert field_checked
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
177
|
+
with_scope(parent) do
|
178
|
+
field_checked = find_field(label)['checked']
|
179
|
+
if field_checked.respond_to? :should
|
180
|
+
field_checked.should be_false
|
181
|
+
else
|
182
|
+
assert !field_checked
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
188
|
+
current_path = URI.parse(current_url).path
|
189
|
+
if current_path.respond_to? :should
|
190
|
+
current_path.should == path_to(page_name)
|
191
|
+
else
|
192
|
+
assert_equal path_to(page_name), current_path
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
197
|
+
query = URI.parse(current_url).query
|
198
|
+
actual_params = query ? CGI.parse(query) : {}
|
199
|
+
expected_params = {}
|
200
|
+
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
201
|
+
|
202
|
+
if actual_params.respond_to? :should
|
203
|
+
actual_params.should == expected_params
|
204
|
+
else
|
205
|
+
assert_equal expected_params, actual_params
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
Then /^show me the page$/ do
|
210
|
+
save_and_open_page
|
211
|
+
end
|