navi 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +41 -0
  5. data/Gemfile.lock +196 -0
  6. data/Guardfile +23 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.textile +26 -0
  9. data/Rakefile +50 -0
  10. data/VERSION +1 -0
  11. data/features/create_menu_items.feature +13 -0
  12. data/features/step_definitions/category_steps.rb +3 -0
  13. data/features/step_definitions/menu_item_steps.rb +19 -0
  14. data/features/step_definitions/page_steps.rb +3 -0
  15. data/features/step_definitions/web_steps.rb +211 -0
  16. data/features/support/env.rb +61 -0
  17. data/features/support/paths.rb +33 -0
  18. data/features/support/selectors.rb +39 -0
  19. data/lib/navi/helpers.rb +24 -0
  20. data/lib/navi/navigable/base.rb +16 -0
  21. data/lib/navi/navigable/instance_methods.rb +24 -0
  22. data/lib/navi/navigator/.base.rb.swo +0 -0
  23. data/lib/navi/navigator/base.rb +11 -0
  24. data/lib/navi/navigator/class_methods.rb +27 -0
  25. data/lib/navi/navigator/instance_methods.rb +57 -0
  26. data/lib/navi/railtie.rb +11 -0
  27. data/lib/navi/renderers/base.rb +31 -0
  28. data/lib/navi/renderers/simple_navigation.rb +30 -0
  29. data/lib/navi.rb +29 -0
  30. data/navi.gemspec +281 -0
  31. data/spec/blueprints.rb +16 -0
  32. data/spec/dummy/.gitignore +6 -0
  33. data/spec/dummy/Rakefile +7 -0
  34. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  35. data/spec/dummy/app/controllers/categories_controller.rb +7 -0
  36. data/spec/dummy/app/controllers/menu_items_controller.rb +15 -0
  37. data/spec/dummy/app/controllers/pages_controller.rb +7 -0
  38. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  39. data/spec/dummy/app/models/category.rb +3 -0
  40. data/spec/dummy/app/models/menu_item.rb +2 -0
  41. data/spec/dummy/app/models/page.rb +3 -0
  42. data/spec/dummy/app/views/categories/_form.html.haml +2 -0
  43. data/spec/dummy/app/views/categories/edit.html.haml +5 -0
  44. data/spec/dummy/app/views/categories/index.html.haml +17 -0
  45. data/spec/dummy/app/views/categories/new.html.haml +5 -0
  46. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  47. data/spec/dummy/app/views/menu_items/edit.html.haml +14 -0
  48. data/spec/dummy/app/views/menu_items/index.html.haml +11 -0
  49. data/spec/dummy/app/views/pages/_form.html.haml +2 -0
  50. data/spec/dummy/app/views/pages/edit.html.haml +5 -0
  51. data/spec/dummy/app/views/pages/index.html.haml +17 -0
  52. data/spec/dummy/app/views/pages/new.html.haml +5 -0
  53. data/spec/dummy/app/widgets/menu_editor/category/form/.display.html.haml.swo +0 -0
  54. data/spec/dummy/app/widgets/menu_editor/category/form/display.html.haml +7 -0
  55. data/spec/dummy/app/widgets/menu_editor/category/form_widget.rb +18 -0
  56. data/spec/dummy/app/widgets/menu_editor/display.html.haml +5 -0
  57. data/spec/dummy/app/widgets/menu_editor/page/form/.display.html.haml.swo +0 -0
  58. data/spec/dummy/app/widgets/menu_editor/page/form/display.html.haml +8 -0
  59. data/spec/dummy/app/widgets/menu_editor/page/form_widget.rb +18 -0
  60. data/spec/dummy/app/widgets/menu_editor/tree/display.html.haml +4 -0
  61. data/spec/dummy/app/widgets/menu_editor/tree/item.html.haml +7 -0
  62. data/spec/dummy/app/widgets/menu_editor/tree/items.html.haml +2 -0
  63. data/spec/dummy/app/widgets/menu_editor/tree_widget.rb +48 -0
  64. data/spec/dummy/app/widgets/menu_editor_widget.rb +11 -0
  65. data/spec/dummy/config/application.rb +45 -0
  66. data/spec/dummy/config/boot.rb +10 -0
  67. data/spec/dummy/config/cucumber.yml +8 -0
  68. data/spec/dummy/config/database.yml +19 -0
  69. data/spec/dummy/config/environment.rb +5 -0
  70. data/spec/dummy/config/environments/development.rb +26 -0
  71. data/spec/dummy/config/environments/production.rb +49 -0
  72. data/spec/dummy/config/environments/test.rb +35 -0
  73. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  74. data/spec/dummy/config/initializers/inflections.rb +10 -0
  75. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  76. data/spec/dummy/config/initializers/navigable.rb +1 -0
  77. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  78. data/spec/dummy/config/initializers/session_store.rb +8 -0
  79. data/spec/dummy/config/locales/en.yml +5 -0
  80. data/spec/dummy/config/navigation.rb +7 -0
  81. data/spec/dummy/config/routes.rb +61 -0
  82. data/spec/dummy/config.ru +4 -0
  83. data/spec/dummy/db/migrate/20110607155019_create_menu_items.rb +20 -0
  84. data/spec/dummy/db/migrate/20110607155202_create_categories.rb +13 -0
  85. data/spec/dummy/db/migrate/20110607160052_create_pages.rb +13 -0
  86. data/spec/dummy/db/schema.rb +41 -0
  87. data/spec/dummy/db/seeds.rb +15 -0
  88. data/spec/dummy/lib/tasks/.gitkeep +0 -0
  89. data/spec/dummy/lib/tasks/cucumber.rake +57 -0
  90. data/spec/dummy/public/404.html +26 -0
  91. data/spec/dummy/public/422.html +26 -0
  92. data/spec/dummy/public/500.html +26 -0
  93. data/spec/dummy/public/favicon.ico +0 -0
  94. data/spec/dummy/public/images/rails.png +0 -0
  95. data/spec/dummy/public/index.html +239 -0
  96. data/spec/dummy/public/javascripts/application.js +2 -0
  97. data/spec/dummy/public/javascripts/jquery-ui.js +11603 -0
  98. data/spec/dummy/public/javascripts/jquery-ui.min.js +406 -0
  99. data/spec/dummy/public/javascripts/jquery.js +8936 -0
  100. data/spec/dummy/public/javascripts/jquery.min.js +18 -0
  101. data/spec/dummy/public/javascripts/jquery_ujs.js +315 -0
  102. data/spec/dummy/public/javascripts/menu_items/index.js +40 -0
  103. data/spec/dummy/public/javascripts/rails.js +315 -0
  104. data/spec/dummy/public/robots.txt +5 -0
  105. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  106. data/spec/dummy/script/cucumber +10 -0
  107. data/spec/dummy/script/rails +6 -0
  108. data/spec/dummy/vendor/plugins/.gitkeep +0 -0
  109. data/spec/navi/helpers_spec.rb +5 -0
  110. data/spec/navi/navi_spec.rb +76 -0
  111. data/spec/navi/navigator_spec.rb +204 -0
  112. data/spec/navi/renderers/simple_navigation_spec.rb +49 -0
  113. data/spec/spec_helper.rb +125 -0
  114. metadata +683 -0
@@ -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