route_dog 2.0.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2010 Alvaro Gil, cuboxsa.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -4,10 +4,12 @@ RouteDog for Ruby on Rails
4
4
  RouteDog is a small collection of Rack middlewares to be used with your Ruby On Rails project as a helper to identify not tested routes.
5
5
 
6
6
  The way that RouteDog knows if you are testing a route is through the Watcher middleware which only runs in Test Environment
7
- and collects the routes that you've called from your Integrational Tests (See Note About Integrational Tests).
7
+ and collects the routes that you've called from your **Integrational Tests** (See Note About Integrational Tests).
8
8
 
9
9
  The way that RouteDog shows to you a warning is through a middleware called Notifier which only runs in Developement Enviroment.
10
10
 
11
+ Also it has a report task that give to you a resume about defined, implemented and tested routes of your application.
12
+
11
13
 
12
14
  For What This Is Useful?
13
15
  ------------------------
@@ -25,38 +27,62 @@ the coverage results but you want to live the experience using the application a
25
27
  Usage
26
28
  -----
27
29
 
28
- Fetch the gem
30
+ ### Instalation ###
29
31
 
30
32
  sudo gem install route_dog
31
33
 
32
- Create a file RAILS_ROOT/config/initializers/route_dog.rb and put the lines below (see notes)
34
+ If you are using Bundler
35
+
36
+ gem 'route_dog'
37
+
38
+ If you are not using Bundler
39
+
40
+ config.gem 'route_dog'
41
+
42
+
43
+ ### Get a report of defined, implemented and tested routes ###
44
+
45
+ Run your *Integrational Tests* and then call a report
46
+
47
+ rake route_dog:report
33
48
 
34
- Rails.application.config.middleware.use RouteDog::Middleware::Watcher if Rails.env.test?
49
+ ![Route Report Example](http://img.skitch.com/20101103-p79s1css147a6tymt1i6mcanm7.jpg "Route Report Example")
35
50
 
36
- Rails.application.config.middleware.use RouteDog::Middleware::Notifier if Rails.env.development?
37
51
 
38
- Run your Integrational Tests
52
+ ### Browsing your application in Development ###
53
+
54
+ This will be appended to your application response
55
+
56
+ ![Notifier Example](http://img.skitch.com/20101103-trxeweg66jh931qtpunh9u91gk.jpg "Notifier Example")
57
+
58
+
59
+ ### Clean collected tested routes ###
60
+
61
+ This is useful if you had a test passing and then you remove the test from your codebase,
62
+ very uncommon, but here is the command.
63
+
64
+ rake route_dog:clean
39
65
 
40
- Run your application in Development Mode
41
66
 
42
67
  TODO
43
68
  ----
44
69
 
45
70
  * Show Notifier warnings for other than regular html responses.
46
- * Rake task to show stadistics about routes defined, used and tested.
47
- * Blocker middleware to disallow not tested routes in Production Environment.
48
- * Blocker middleware also should remove from your page response links to not tested resources.
71
+ * Generator to extract route_dog.yml config file, so you can disable the middlewares you don't want.
49
72
 
50
73
  Notes
51
74
  -----
52
75
 
53
- * Watcher middleware don't work with Controller Tests, it only works with Integrational Tests except if you are running RSpec, because RSpec
54
- controller tests are an extension of Integrational Tests, but this will be not longer supported by RSpec.
76
+ * Watcher middleware don't work with Controller Tests, it only works with Integrational Tests.
77
+
78
+
79
+ Copyright
80
+ ---------
55
81
 
56
- * Watcher and Notifier middlewares may need be loaded after or before another middleware, that is the case if you are using Warden.
82
+ Copyright © 2010 Alvaro Gil. See LICENSE for details.
57
83
 
58
- `Rails.application.config.middleware.insert_before Warden::Manager, RouteDog::Middleware::Watcher if Rails.env.test?`
59
84
 
60
- `Rails.application.config.middleware.insert_before Warden::Manager, RouteDog::Middleware::Notifier if Rails.env.development?`
85
+ Thanks
86
+ ------
61
87
 
62
- * Be sure to call `rake route_dog:clean` once in a while to ensure that the tested route list remains updated.
88
+ dcadenas, foca and spastorino for beign responsive to my questions.
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
1
  require "rake/testtask"
2
+ import "lib/tasks/tasks.rake"
2
3
 
3
4
  begin
4
5
  require 'jeweler'
5
6
  Jeweler::Tasks.new do |gem|
6
7
  gem.name = "route_dog"
7
8
  gem.summary = %Q{Watch and Notify your not tested routes of a RoR Application}
8
- gem.description = %Q{Watch and Notify your not tested routes of a RoR Application}
9
+ gem.description = %Q{Watch and Notify your not tested routes of a RoR Application, it also has a simple report about Routes defines, used and tested}
10
+ gem.rubyforge_project = "routedog"
9
11
  gem.email = "zevarito@gmail.com"
10
12
  gem.homepage = "http://github.com/zevarito/route_dog"
11
13
  gem.authors = ["Alvaro Gil"]
@@ -22,15 +24,9 @@ end
22
24
  desc "Default: run tests"
23
25
  task :default => :test
24
26
 
25
- namespace :route_dog do
26
- desc "Clean Tested Routes File"
27
- task :clean do
28
- File.delete("test/mock_app/config/route_dog_routes.yml") if File.exists? "test/mock_app/config/route_dog_routes.yml"
29
- end
30
- end
27
+ task :test => "route_dog:clean"
31
28
 
32
29
  Rake::TestTask.new do |t|
33
- Rake::Task["route_dog:clean"].invoke
34
30
  t.libs << "lib" << "test"
35
31
  t.test_files = FileList["test/**/*_test.rb"]
36
32
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.2.0
@@ -3,7 +3,6 @@ module RouteDog
3
3
  class Notifier < RouteDog
4
4
  def initialize(app)
5
5
  @app = app
6
- super
7
6
  end
8
7
 
9
8
  def call(env)
@@ -11,11 +10,13 @@ module RouteDog
11
10
 
12
11
  status, headers, @response = @app.call(env)
13
12
 
14
- append_warning if !route_tested?
13
+ append_warning if !::RouteDog.route_tested?(identify_controller, identify_action, request_method)
15
14
 
16
15
  [status, headers, @response]
17
16
  end
18
17
 
18
+ private
19
+
19
20
  def append_warning
20
21
  @response.each do |part|
21
22
  part.gsub!("<body>", "<body>#{warning_html}")
@@ -3,19 +3,11 @@ require 'rack'
3
3
  module RouteDog
4
4
  module Middleware
5
5
  class RouteDog
6
- def initialize(app)
7
- require File.join(Rails.root, 'config/routes.rb')
8
- initialize_yaml_file
9
- end
10
6
 
11
- def self.config_file
12
- File.join(Rails.root, 'config', 'route_dog_routes.yml')
13
- end
7
+ include ::RouteDog
14
8
 
15
- def initialize_yaml_file
16
- @watched_routes = YAML.load_file(Watcher.config_file)
17
- rescue Errno::ENOENT
18
- @watched_routes = {}
9
+ def initialize(app)
10
+ load_watched_routes
19
11
  end
20
12
 
21
13
  def request_path
@@ -34,15 +26,6 @@ module RouteDog
34
26
  identify_path[:action]
35
27
  end
36
28
 
37
- def route_tested?
38
- initialize_yaml_file
39
- begin
40
- @watched_routes[identify_controller.to_s][identify_action.to_s].include?(request_method.to_s)
41
- rescue
42
- false
43
- end
44
- end
45
-
46
29
  def identify_path
47
30
  Rails.application.routes.recognize_path(request_path, :method => request_method)
48
31
  end
@@ -1,9 +1,12 @@
1
1
  module RouteDog
2
2
  module Middleware
3
3
  class Watcher < RouteDog
4
+
5
+ attr_accessor :watched_routes
6
+
4
7
  def initialize(app)
5
8
  @app = app
6
- super
9
+ @watched_routes = ::RouteDog.load_watched_routes
7
10
  end
8
11
 
9
12
  def call(env)
@@ -19,11 +22,11 @@ module RouteDog
19
22
  private
20
23
 
21
24
  def store_route
22
- @watched_routes[identify_controller] ||= {}
23
- @watched_routes[identify_controller][identify_action] ||= []
24
- @watched_routes[identify_controller][identify_action] << request_method.to_s
25
- @watched_routes[identify_controller][identify_action].uniq!
26
- File.open(Watcher.config_file, "w+") {|file| file.puts(@watched_routes.to_yaml) }
25
+ watched_routes[identify_controller] ||= {}
26
+ watched_routes[identify_controller][identify_action] ||= []
27
+ watched_routes[identify_controller][identify_action] << request_method.to_s
28
+ watched_routes[identify_controller][identify_action].uniq!
29
+ ::RouteDog.write_watched_routes(watched_routes)
27
30
  rescue ActionController::RoutingError
28
31
  false
29
32
  end
@@ -0,0 +1,3 @@
1
+ require File.join(File.dirname(__FILE__), 'middleware', 'route_dog.rb')
2
+ require File.join(File.dirname(__FILE__), 'middleware', 'watcher.rb')
3
+ require File.join(File.dirname(__FILE__), 'middleware', 'notifier.rb')
@@ -0,0 +1,27 @@
1
+ module RouteDog
2
+ class Railtie < Rails::Railtie
3
+ attr_reader :route_dog_config
4
+
5
+ rake_tasks do
6
+ load "tasks/tasks.rake"
7
+ end
8
+
9
+ initializer "route_dog.configure_rails_initialization" do |app|
10
+ load_route_dog_configuration
11
+ setup_middlewares(app)
12
+ end
13
+
14
+ private
15
+
16
+ def setup_middlewares(app)
17
+ app.config.middleware.use RouteDog::Middleware::Watcher if route_dog_config.has_key?("watcher") && route_dog_config["watcher"]["env"].include?(Rails.env)
18
+ app.config.middleware.use RouteDog::Middleware::Notifier if route_dog_config.has_key?("notifier") && route_dog_config["notifier"]["env"].include?(Rails.env)
19
+ end
20
+
21
+ def load_route_dog_configuration
22
+ @route_dog_config ||= YAML.load_file(File.join(Rails.root, 'config', 'route_dog.yml'))
23
+ rescue Errno::ENOENT
24
+ @route_dog_config = {"watcher" => {"env" => ["test"]}, "notifier" => {"env" => ["development"]}}
25
+ end
26
+ end
27
+ end
data/lib/route_dog.rb CHANGED
@@ -1,3 +1,30 @@
1
- require 'route_dog/middleware/route_dog'
2
- require 'route_dog/middleware/watcher'
3
- require 'route_dog/middleware/notifier'
1
+ require 'route_dog/middleware'
2
+ require 'route_dog/railtie' if defined?(Rails)
3
+
4
+ module RouteDog
5
+ def self.config_file
6
+ File.join(Rails.root, 'config', 'route_dog_routes.yml')
7
+ end
8
+
9
+ def self.load_watched_routes
10
+ YAML.load_file(config_file)
11
+ rescue Errno::ENOENT
12
+ {}
13
+ end
14
+
15
+ def self.write_watched_routes(routes)
16
+ File.open(config_file, "w+") {|file| file.puts(routes.to_yaml) }
17
+ end
18
+
19
+ def self.route_tested?(controller, action, method)
20
+ begin
21
+ load_watched_routes[controller.to_s.downcase][action.to_s.downcase].include?(method.to_s.downcase)
22
+ rescue
23
+ false
24
+ end
25
+ end
26
+
27
+ def self.constantize_controller_str(controller)
28
+ controller.split("/").map{|c| c.split("_").map{|cc| cc.capitalize}.join }.join("::").concat("Controller").constantize
29
+ end
30
+ end
@@ -0,0 +1,112 @@
1
+ require "launchy"
2
+
3
+ namespace :route_dog do
4
+ desc "Clean Tested Routes File"
5
+ task :clean do
6
+ File.delete("test/mock_app/config/route_dog_routes.yml") if File.exists? "test/mock_app/config/route_dog_routes.yml"
7
+ puts "\nRoute Dog tested routes definition file deleted."
8
+ end
9
+
10
+ desc "Create A Html Report Of The Routes Defined, Tested And Used"
11
+ task :report => :environment do
12
+ puts "\nCreate A Html Report Of The Routes Defined, Tested And Used\n"
13
+ @implemented_routes = []
14
+ @tested_routes = []
15
+ @defined_routes = Rails.application.routes.routes
16
+ @defined_routes.reject! { |r| r.path =~ %r{/rails/info/properties} } # Skip the route if it's internal info route
17
+ save_and_open_report_in_browser(ERB.new(report_template).result(binding))
18
+ end
19
+ end
20
+
21
+ def save_and_open_report_in_browser(html_report)
22
+ path = File.join(Rails.root, "tmp", Rails.application.class.to_s.gsub(":", "").concat("RoutesReport.html").underscore)
23
+ File.open(path, "w+") {|file| file.puts(html_report) }
24
+ Launchy::Browser.run(path)
25
+ end
26
+
27
+ def implemented_route?(route)
28
+ if find_or_instantiate_controller_for(route).respond_to?(route.requirements[:action])
29
+ @implemented_routes << route
30
+ true
31
+ else
32
+ false
33
+ end
34
+ end
35
+
36
+ def tested_route?(route)
37
+ requirements = route.requirements
38
+ if RouteDog.route_tested?(requirements[:controller], requirements[:action], route.verb)
39
+ @tested_routes << route
40
+ true
41
+ else
42
+ false
43
+ end
44
+ end
45
+
46
+ def find_or_instantiate_controller_for(route)
47
+ requirements = route.requirements
48
+ @instantiated_controllers ||= {}
49
+ if @instantiated_controllers.has_key?(requirements[:controller])
50
+ @instantiated_controllers[requirements[:controller]]
51
+ else
52
+ begin
53
+ @instantiated_controllers[requirements[:controller]] = RouteDog.constantize_controller_str(requirements[:controller]).new
54
+ rescue
55
+ false
56
+ end
57
+ end
58
+ end
59
+
60
+ def report_template
61
+ <<-EOT
62
+ <html>
63
+ <head>
64
+ <style type="text/css">
65
+ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
66
+ a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp,
67
+ small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset,
68
+ form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
69
+ margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent;}
70
+
71
+ body { margin: 0; padding: 0; font:15.34px helvetica,arial,freesans,clean,sans-serif; }
72
+ #header { background: red; color: #fff; display: block; height: 70px; }
73
+ h1 { font-size: 18px; padding: 10px 0 0 25px; }
74
+ table#routes { width: 100%; padding: 40px 25px 0; }
75
+ table#routes th, table#routes td { text-align: left; padding: 5px; }
76
+ table#routes tr:nth-child(odd) { background: #eee;}
77
+ div#route_stats {}
78
+ span.yes { color: green; font-weight: bold }
79
+ span.no { color: red; font-weight: bold }
80
+ div#route_stats { background: #444; color: #fff; height: 30px; position: absolute; top: 50px; width: 100%; border-bottom: solid 4px #666 }
81
+ div#route_stats p { padding: 10px 0 0 25px; }
82
+ div#route_stats span { margin: 0 50px 0 10px; color: #fff; font-weight: bold; }
83
+ div#route_stats span.zero_routes { background: #666; padding: 2px; 5px; }
84
+ </style>
85
+ </head>
86
+ <body>
87
+ <div id="header">
88
+ <h1>Route Dog - <%= Rails.application.class.to_s.gsub(/::/, ' ') %> - Routes Report</h1>
89
+ </div>
90
+ <table id="routes">
91
+ <tr><th>Method</th><th>Path</th><th>Action</th><th>Implemented</th><th>Tested</th></tr>
92
+ <% @defined_routes.each do |route| %>
93
+ <tr>
94
+ <td><%= route.verb %></td>
95
+ <td><%= route.path %></td>
96
+ <td><%= route.requirements[:controller] + '#' + route.requirements[:action] %></td>
97
+ <td><%= implemented_route?(route) ? "<span class='yes'>YES</span>" : "<span class='no'>NO</span>" %></td>
98
+ <td><%= tested_route?(route) ? "<span class='yes'>YES</span>" : "<span class='no'>NO</span>" %></td>
99
+ <% end %>
100
+ </table>
101
+ <div id="route_stats">
102
+ <p>
103
+ <strong>Defined:</strong> <span class="value"><%= @defined_routes.size %></span>
104
+ <strong>Implemented:</strong> <span class="value"><%= @implemented_routes.size %></span>
105
+ <strong>Tested:</strong> <span class="value"><%= @tested_routes.size %></span>
106
+ <% if @tested_routes.size == 0 %><span class="zero_routes">You have 0 routes tested, may be you should run your Integrational Tests First!</span><% end %>
107
+ <p>
108
+ </div>
109
+ </body>
110
+ </html>
111
+ EOT
112
+ end
data/route_dog.gemspec CHANGED
@@ -5,36 +5,45 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{route_dog}
8
- s.version = "2.0.1"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alvaro Gil"]
12
- s.date = %q{2010-10-23}
13
- s.description = %q{Watch and Notify your not tested routes of a RoR Application}
12
+ s.date = %q{2010-11-03}
13
+ s.description = %q{Watch and Notify your not tested routes of a RoR Application, it also has a simple report about Routes defines, used and tested}
14
14
  s.email = %q{zevarito@gmail.com}
15
15
  s.extra_rdoc_files = [
16
- "README.md"
16
+ "LICENSE",
17
+ "README.md"
17
18
  ]
18
19
  s.files = [
19
20
  ".gitignore",
21
+ "LICENSE",
20
22
  "README.md",
21
23
  "Rakefile",
22
24
  "VERSION",
23
25
  "lib/route_dog.rb",
26
+ "lib/route_dog/middleware.rb",
24
27
  "lib/route_dog/middleware/notifier.rb",
25
28
  "lib/route_dog/middleware/route_dog.rb",
26
29
  "lib/route_dog/middleware/watcher.rb",
30
+ "lib/route_dog/railtie.rb",
31
+ "lib/tasks/tasks.rake",
27
32
  "route_dog.gemspec",
28
33
  "test/integration/products_controller_test.rb",
29
- "test/integration/sessions_controller.rb",
34
+ "test/integration/sessions_controller_test.rb",
30
35
  "test/integration/users_controller_test.rb",
31
36
  "test/mock_app/.gitignore",
32
37
  "test/mock_app/Gemfile",
33
38
  "test/mock_app/Gemfile.lock",
34
39
  "test/mock_app/Rakefile",
40
+ "test/mock_app/app/controllers/admin/blogs/posts_controller.rb",
41
+ "test/mock_app/app/controllers/admin/project_settings_controller.rb",
42
+ "test/mock_app/app/controllers/admin/users_controller.rb",
35
43
  "test/mock_app/app/controllers/application_controller.rb",
36
44
  "test/mock_app/app/controllers/products_controller.rb",
37
- "test/mock_app/app/controllers/sessions_controller_test.rb",
45
+ "test/mock_app/app/controllers/project_settings_controller.rb",
46
+ "test/mock_app/app/controllers/sessions_controller.rb",
38
47
  "test/mock_app/app/controllers/users_controller.rb",
39
48
  "test/mock_app/app/helpers/application_helper.rb",
40
49
  "test/mock_app/app/views/layouts/application.html.erb",
@@ -50,10 +59,10 @@ Gem::Specification.new do |s|
50
59
  "test/mock_app/config/initializers/backtrace_silencers.rb",
51
60
  "test/mock_app/config/initializers/inflections.rb",
52
61
  "test/mock_app/config/initializers/mime_types.rb",
53
- "test/mock_app/config/initializers/route_dog.rb",
54
62
  "test/mock_app/config/initializers/secret_token.rb",
55
63
  "test/mock_app/config/initializers/session_store.rb",
56
64
  "test/mock_app/config/locales/en.yml",
65
+ "test/mock_app/config/route_dog.yml",
57
66
  "test/mock_app/config/routes.rb",
58
67
  "test/mock_app/db/seeds.rb",
59
68
  "test/mock_app/public/404.html",
@@ -70,21 +79,28 @@ Gem::Specification.new do |s|
70
79
  "test/mock_app/public/javascripts/rails.js",
71
80
  "test/mock_app/public/robots.txt",
72
81
  "test/mock_app/public/stylesheets/.gitkeep",
82
+ "test/mock_app/tmp/.gitignore",
73
83
  "test/support/assertions.rb",
74
- "test/test_helper.rb"
84
+ "test/test_helper.rb",
85
+ "test/unit/route_dog_test.rb"
75
86
  ]
76
87
  s.homepage = %q{http://github.com/zevarito/route_dog}
77
88
  s.rdoc_options = ["--charset=UTF-8"]
78
89
  s.require_paths = ["lib"]
90
+ s.rubyforge_project = %q{routedog}
79
91
  s.rubygems_version = %q{1.3.7}
80
92
  s.summary = %q{Watch and Notify your not tested routes of a RoR Application}
81
93
  s.test_files = [
82
94
  "test/integration/products_controller_test.rb",
83
- "test/integration/sessions_controller.rb",
95
+ "test/integration/sessions_controller_test.rb",
84
96
  "test/integration/users_controller_test.rb",
97
+ "test/mock_app/app/controllers/admin/blogs/posts_controller.rb",
98
+ "test/mock_app/app/controllers/admin/project_settings_controller.rb",
99
+ "test/mock_app/app/controllers/admin/users_controller.rb",
85
100
  "test/mock_app/app/controllers/application_controller.rb",
86
101
  "test/mock_app/app/controllers/products_controller.rb",
87
- "test/mock_app/app/controllers/sessions_controller_test.rb",
102
+ "test/mock_app/app/controllers/project_settings_controller.rb",
103
+ "test/mock_app/app/controllers/sessions_controller.rb",
88
104
  "test/mock_app/app/controllers/users_controller.rb",
89
105
  "test/mock_app/app/helpers/application_helper.rb",
90
106
  "test/mock_app/config/application.rb",
@@ -96,13 +112,13 @@ Gem::Specification.new do |s|
96
112
  "test/mock_app/config/initializers/backtrace_silencers.rb",
97
113
  "test/mock_app/config/initializers/inflections.rb",
98
114
  "test/mock_app/config/initializers/mime_types.rb",
99
- "test/mock_app/config/initializers/route_dog.rb",
100
115
  "test/mock_app/config/initializers/secret_token.rb",
101
116
  "test/mock_app/config/initializers/session_store.rb",
102
117
  "test/mock_app/config/routes.rb",
103
118
  "test/mock_app/db/seeds.rb",
104
119
  "test/support/assertions.rb",
105
- "test/test_helper.rb"
120
+ "test/test_helper.rb",
121
+ "test/unit/route_dog_test.rb"
106
122
  ]
107
123
 
108
124
  if s.respond_to? :specification_version then
@@ -11,7 +11,7 @@ class SessionsControllerTest < ActionController::IntegrationTest
11
11
  get "/sessions/1/logout"
12
12
  delete "/sessions/1/logout"
13
13
 
14
- assert_watched_routes_include(:sessions, :logout, :delete)
14
+ assert_watched_routes_include(:sessions, :logout, :get)
15
15
  assert_watched_routes_include(:sessions, :logout, :delete)
16
16
  end
17
17
  end
@@ -14,7 +14,7 @@ gem 'sqlite3-ruby', :require => 'sqlite3'
14
14
  # gem 'capistrano'
15
15
 
16
16
  # To use debugger
17
- # gem 'ruby-debug'
17
+ gem 'ruby-debug'
18
18
 
19
19
  # Bundle the extra gems:
20
20
  # gem 'bj'
@@ -28,3 +28,6 @@ gem 'sqlite3-ruby', :require => 'sqlite3'
28
28
  # group :development, :test do
29
29
  # gem 'webrat'
30
30
  # end
31
+
32
+ gem 'route_dog', :path => File.join(File.dirname(__FILE__), "..", "..")
33
+ gem 'launchy'
@@ -1,3 +1,10 @@
1
+ PATH
2
+ remote: /Users/zevarito/Sources/zevarito/route_dog
3
+ specs:
4
+ route_dog (2.1.1)
5
+ rack
6
+ rails (>= 2.3.8)
7
+
1
8
  GEM
2
9
  remote: http://rubygems.org/
3
10
  specs:
@@ -31,9 +38,15 @@ GEM
31
38
  arel (1.0.1)
32
39
  activesupport (~> 3.0.0)
33
40
  builder (2.1.2)
41
+ columnize (0.3.1)
42
+ configuration (1.1.0)
34
43
  erubis (2.6.6)
35
44
  abstract (>= 1.0.0)
36
45
  i18n (0.4.1)
46
+ launchy (0.3.7)
47
+ configuration (>= 0.0.5)
48
+ rake (>= 0.8.1)
49
+ linecache (0.43)
37
50
  mail (2.2.7)
38
51
  activesupport (>= 2.3.6)
39
52
  mime-types
@@ -59,6 +72,11 @@ GEM
59
72
  rake (>= 0.8.4)
60
73
  thor (~> 0.14.0)
61
74
  rake (0.8.7)
75
+ ruby-debug (0.10.3)
76
+ columnize (>= 0.1)
77
+ ruby-debug-base (~> 0.10.3.0)
78
+ ruby-debug-base (0.10.3)
79
+ linecache (>= 0.3)
62
80
  sqlite3-ruby (1.3.1)
63
81
  thor (0.14.3)
64
82
  treetop (1.4.8)
@@ -69,5 +87,8 @@ PLATFORMS
69
87
  ruby
70
88
 
71
89
  DEPENDENCIES
90
+ launchy
72
91
  rails (= 3.0.1)
92
+ route_dog!
93
+ ruby-debug
73
94
  sqlite3-ruby
@@ -0,0 +1,2 @@
1
+ class Admin::Blogs::PostsController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Admin::ProjectSettingsController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Admin::UsersController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ class ProjectSettingsController < ApplicationController
2
+ end
@@ -0,0 +1,8 @@
1
+ ---
2
+ watcher:
3
+ env:
4
+ - test
5
+ notifier:
6
+ env:
7
+ - test
8
+ - development
@@ -0,0 +1 @@
1
+ *.html
@@ -1,6 +1,6 @@
1
1
  def assert_watched_routes_include(controller, action, method)
2
2
  begin
3
- routes = YAML.load_file(RouteDog::Middleware::RouteDog.config_file)
3
+ routes = YAML.load_file(RouteDog.config_file)
4
4
  raise if !routes[controller.to_s][action.to_s].include?(method.to_s)
5
5
  raise if routes[controller.to_s][action.to_s].reject {|e| e != method.to_s}.size != 1
6
6
  rescue
@@ -0,0 +1,25 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper.rb')
2
+
3
+ class RouteDogTest < Test::Unit::TestCase
4
+ context "Constantize controllers as it comes from routes" do
5
+ test "simples" do
6
+ assert_equal UsersController, RouteDog.constantize_controller_str("users")
7
+ end
8
+
9
+ test "with composite names" do
10
+ assert_equal ProjectSettingsController, RouteDog.constantize_controller_str("project_settings")
11
+ end
12
+
13
+ test "named spaced simples" do
14
+ assert_equal Admin::UsersController, RouteDog.constantize_controller_str("admin/users")
15
+ end
16
+
17
+ test "named spaced with composite names" do
18
+ assert_equal Admin::ProjectSettingsController, RouteDog.constantize_controller_str("admin/project_settings")
19
+ end
20
+
21
+ test "named spaced deeply" do
22
+ assert_equal Admin::Blogs::PostsController, RouteDog.constantize_controller_str("admin/blogs/posts")
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: route_dog
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
+ - 2
8
9
  - 0
9
- - 1
10
- version: 2.0.1
10
+ version: 2.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alvaro Gil
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-23 00:00:00 -02:00
18
+ date: 2010-11-03 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -81,34 +81,43 @@ dependencies:
81
81
  version: 1.4.3.1
82
82
  type: :development
83
83
  version_requirements: *id004
84
- description: Watch and Notify your not tested routes of a RoR Application
84
+ description: Watch and Notify your not tested routes of a RoR Application, it also has a simple report about Routes defines, used and tested
85
85
  email: zevarito@gmail.com
86
86
  executables: []
87
87
 
88
88
  extensions: []
89
89
 
90
90
  extra_rdoc_files:
91
+ - LICENSE
91
92
  - README.md
92
93
  files:
93
94
  - .gitignore
95
+ - LICENSE
94
96
  - README.md
95
97
  - Rakefile
96
98
  - VERSION
97
99
  - lib/route_dog.rb
100
+ - lib/route_dog/middleware.rb
98
101
  - lib/route_dog/middleware/notifier.rb
99
102
  - lib/route_dog/middleware/route_dog.rb
100
103
  - lib/route_dog/middleware/watcher.rb
104
+ - lib/route_dog/railtie.rb
105
+ - lib/tasks/tasks.rake
101
106
  - route_dog.gemspec
102
107
  - test/integration/products_controller_test.rb
103
- - test/integration/sessions_controller.rb
108
+ - test/integration/sessions_controller_test.rb
104
109
  - test/integration/users_controller_test.rb
105
110
  - test/mock_app/.gitignore
106
111
  - test/mock_app/Gemfile
107
112
  - test/mock_app/Gemfile.lock
108
113
  - test/mock_app/Rakefile
114
+ - test/mock_app/app/controllers/admin/blogs/posts_controller.rb
115
+ - test/mock_app/app/controllers/admin/project_settings_controller.rb
116
+ - test/mock_app/app/controllers/admin/users_controller.rb
109
117
  - test/mock_app/app/controllers/application_controller.rb
110
118
  - test/mock_app/app/controllers/products_controller.rb
111
- - test/mock_app/app/controllers/sessions_controller_test.rb
119
+ - test/mock_app/app/controllers/project_settings_controller.rb
120
+ - test/mock_app/app/controllers/sessions_controller.rb
112
121
  - test/mock_app/app/controllers/users_controller.rb
113
122
  - test/mock_app/app/helpers/application_helper.rb
114
123
  - test/mock_app/app/views/layouts/application.html.erb
@@ -124,10 +133,10 @@ files:
124
133
  - test/mock_app/config/initializers/backtrace_silencers.rb
125
134
  - test/mock_app/config/initializers/inflections.rb
126
135
  - test/mock_app/config/initializers/mime_types.rb
127
- - test/mock_app/config/initializers/route_dog.rb
128
136
  - test/mock_app/config/initializers/secret_token.rb
129
137
  - test/mock_app/config/initializers/session_store.rb
130
138
  - test/mock_app/config/locales/en.yml
139
+ - test/mock_app/config/route_dog.yml
131
140
  - test/mock_app/config/routes.rb
132
141
  - test/mock_app/db/seeds.rb
133
142
  - test/mock_app/public/404.html
@@ -144,8 +153,10 @@ files:
144
153
  - test/mock_app/public/javascripts/rails.js
145
154
  - test/mock_app/public/robots.txt
146
155
  - test/mock_app/public/stylesheets/.gitkeep
156
+ - test/mock_app/tmp/.gitignore
147
157
  - test/support/assertions.rb
148
158
  - test/test_helper.rb
159
+ - test/unit/route_dog_test.rb
149
160
  has_rdoc: true
150
161
  homepage: http://github.com/zevarito/route_dog
151
162
  licenses: []
@@ -175,18 +186,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
186
  version: "0"
176
187
  requirements: []
177
188
 
178
- rubyforge_project:
189
+ rubyforge_project: routedog
179
190
  rubygems_version: 1.3.7
180
191
  signing_key:
181
192
  specification_version: 3
182
193
  summary: Watch and Notify your not tested routes of a RoR Application
183
194
  test_files:
184
195
  - test/integration/products_controller_test.rb
185
- - test/integration/sessions_controller.rb
196
+ - test/integration/sessions_controller_test.rb
186
197
  - test/integration/users_controller_test.rb
198
+ - test/mock_app/app/controllers/admin/blogs/posts_controller.rb
199
+ - test/mock_app/app/controllers/admin/project_settings_controller.rb
200
+ - test/mock_app/app/controllers/admin/users_controller.rb
187
201
  - test/mock_app/app/controllers/application_controller.rb
188
202
  - test/mock_app/app/controllers/products_controller.rb
189
- - test/mock_app/app/controllers/sessions_controller_test.rb
203
+ - test/mock_app/app/controllers/project_settings_controller.rb
204
+ - test/mock_app/app/controllers/sessions_controller.rb
190
205
  - test/mock_app/app/controllers/users_controller.rb
191
206
  - test/mock_app/app/helpers/application_helper.rb
192
207
  - test/mock_app/config/application.rb
@@ -198,10 +213,10 @@ test_files:
198
213
  - test/mock_app/config/initializers/backtrace_silencers.rb
199
214
  - test/mock_app/config/initializers/inflections.rb
200
215
  - test/mock_app/config/initializers/mime_types.rb
201
- - test/mock_app/config/initializers/route_dog.rb
202
216
  - test/mock_app/config/initializers/secret_token.rb
203
217
  - test/mock_app/config/initializers/session_store.rb
204
218
  - test/mock_app/config/routes.rb
205
219
  - test/mock_app/db/seeds.rb
206
220
  - test/support/assertions.rb
207
221
  - test/test_helper.rb
222
+ - test/unit/route_dog_test.rb
@@ -1,6 +0,0 @@
1
- # Insert this middleware to know from tests what routes aren't tested
2
- Rails.application.config.middleware.use RouteDog::Middleware::Watcher if Rails.env.test?
3
-
4
- # Insert this middleware in development to append html to let the user know if the route is not tested
5
- # Also we add this middleware to test env so that way we can test the whole thing :D
6
- Rails.application.config.middleware.use RouteDog::Middleware::Notifier if Rails.env.test? || Rails.env.development?