navi 0.0.2
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/.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/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Configure Rails Envinronment
|
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
|
3
|
+
|
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
5
|
+
require File.expand_path("../blueprints.rb", __FILE__)
|
|
6
|
+
require "rails/test_help"
|
|
7
|
+
require "rspec/rails"
|
|
8
|
+
|
|
9
|
+
ActionMailer::Base.delivery_method = :test
|
|
10
|
+
ActionMailer::Base.perform_deliveries = true
|
|
11
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
|
12
|
+
|
|
13
|
+
Rails.backtrace_cleaner.remove_silencers!
|
|
14
|
+
|
|
15
|
+
# Configure capybara for integration testing
|
|
16
|
+
require "capybara/rails"
|
|
17
|
+
Capybara.default_driver = :rack_test
|
|
18
|
+
Capybara.default_selector = :css
|
|
19
|
+
|
|
20
|
+
# Run down then up any available migration in the dummy app
|
|
21
|
+
def migrate(direction)
|
|
22
|
+
migration_directory = File.expand_path "../dummy/db/migrate", __FILE__
|
|
23
|
+
migration_files = Dir["#{migration_directory}/[0-9]*_*.rb"]
|
|
24
|
+
migration_files.each {|migration_file| require migration_file} # require them so we can execute them
|
|
25
|
+
case direction
|
|
26
|
+
when :up : migration_files.each { |file_name| $1.camelize.constantize.up if file_name =~ /[\w\/\.]*\/\d*_(.*)\.rb$/ }
|
|
27
|
+
when :down
|
|
28
|
+
# Originally: migration_files.sort.reverse.each { |file_name| $1.camelize.constantize.down if file_name =~ /[\w\/\.]*\/\d*_(.*)\.rb$/ }
|
|
29
|
+
# But better to just drop all tables
|
|
30
|
+
ActiveRecord::Base.connection.tables.each do |table_name|
|
|
31
|
+
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS '#{table_name}'")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
migrate :down
|
|
36
|
+
migrate :up
|
|
37
|
+
|
|
38
|
+
# Load support files
|
|
39
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
40
|
+
|
|
41
|
+
RSpec.configure do |config|
|
|
42
|
+
# Remove this line if you don't want RSpec's should and should_not
|
|
43
|
+
# methods or matchers
|
|
44
|
+
require 'rspec/expectations'
|
|
45
|
+
config.include RSpec::Matchers
|
|
46
|
+
|
|
47
|
+
# == Mock Framework
|
|
48
|
+
config.mock_with :rspec
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Adds the *args to the klass and yields the new_klass
|
|
52
|
+
# Good for temporarily testing out certain arguments
|
|
53
|
+
def navigable(klass, *args)
|
|
54
|
+
klass.class_eval do
|
|
55
|
+
# navigable method here isn't actually this method,
|
|
56
|
+
# it's the method in the navigable gem
|
|
57
|
+
navigable *args
|
|
58
|
+
end
|
|
59
|
+
yield
|
|
60
|
+
ensure
|
|
61
|
+
# Reset navigable to nothing again
|
|
62
|
+
klass.navigable
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
#$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
66
|
+
#$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
67
|
+
#require 'rubygems'
|
|
68
|
+
#require 'active_support'
|
|
69
|
+
#require 'active_record'
|
|
70
|
+
#require 'rspec'
|
|
71
|
+
#require 'navi'
|
|
72
|
+
#require 'spec/fixtures/category'
|
|
73
|
+
#require 'spec/fixtures/nav_item'
|
|
74
|
+
|
|
75
|
+
##Allow to connect to SQLite
|
|
76
|
+
#ActiveRecord::Base.establish_connection(
|
|
77
|
+
#:adapter => "sqlite3",
|
|
78
|
+
#:database => ":memory:"
|
|
79
|
+
#)
|
|
80
|
+
|
|
81
|
+
#def reset_database
|
|
82
|
+
#%W(nav_items categories pages).each do |table_name|
|
|
83
|
+
#ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS '#{table_name}'")
|
|
84
|
+
#end
|
|
85
|
+
#ActiveRecord::Base.connection.create_table(:nav_items) do |t|
|
|
86
|
+
#t.string :label
|
|
87
|
+
#t.string :link
|
|
88
|
+
#t.string :title
|
|
89
|
+
#t.integer :parent_id, :default => 0
|
|
90
|
+
#t.integer :position
|
|
91
|
+
#t.string :highlights_on
|
|
92
|
+
#t.integer :navigable_id
|
|
93
|
+
#t.string :navigable_type
|
|
94
|
+
#end
|
|
95
|
+
#ActiveRecord::Base.connection.create_table(:categories) do |t|
|
|
96
|
+
#t.string :name
|
|
97
|
+
#t.string :nombre
|
|
98
|
+
#end
|
|
99
|
+
#ActiveRecord::Base.connection.create_table(:pages) do |t|
|
|
100
|
+
#t.string :name
|
|
101
|
+
#end
|
|
102
|
+
#end
|
|
103
|
+
|
|
104
|
+
## Adds the *args to the klass and yields the new_klass
|
|
105
|
+
## Good for temporarily testing out certain arguments
|
|
106
|
+
#def navigable(klass, *args)
|
|
107
|
+
#klass.class_eval do
|
|
108
|
+
## navigable method here isn't actually this method,
|
|
109
|
+
## it's the method in the navigable gem
|
|
110
|
+
#navigable *args
|
|
111
|
+
#end
|
|
112
|
+
#yield
|
|
113
|
+
#ensure
|
|
114
|
+
## Reset navigable to nothing again
|
|
115
|
+
#klass.navigable
|
|
116
|
+
#end
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
## Requires supporting files with custom matchers and macros, etc,
|
|
120
|
+
## in ./support/ and its subdirectories.
|
|
121
|
+
#Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
122
|
+
|
|
123
|
+
#RSpec.configure do |config|
|
|
124
|
+
|
|
125
|
+
#end
|