route_dog 2.3.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -18
- data/Rakefile +5 -1
- data/VERSION +1 -1
- data/lib/route_dog/middleware/notifier.rb +5 -10
- data/lib/route_dog/railtie.rb +10 -7
- data/lib/route_dog/report.rb +89 -0
- data/lib/route_dog/templates/report.html.erb +51 -0
- data/lib/route_dog/templates/warning.html.erb +8 -0
- data/lib/route_dog.rb +12 -2
- data/lib/tasks/tasks.rake +2 -99
- data/route_dog.gemspec +102 -98
- data/test/integration/pages_controller_test.rb +14 -0
- data/test/mock_app/app/controllers/pages_controller.rb +9 -0
- data/test/mock_app/config/{route_dog.yml → middlewares_route_dog.yml} +0 -0
- data/test/mock_app/config/routes.rb +2 -0
- data/test/support/assertions.rb +1 -0
- data/test/unit/route_dog_test.rb +2 -2
- metadata +13 -6
data/README.md
CHANGED
@@ -3,23 +3,20 @@ RouteDog for Ruby on Rails
|
|
3
3
|
|
4
4
|
**It only works in Rails 3 for now, Rails 2.3 support is comming.**
|
5
5
|
|
6
|
-
RouteDog
|
6
|
+
RouteDog does the following things for you:
|
7
7
|
|
8
|
-
|
9
|
-
and collects the routes that you've called from your **Integration Tests** (See Note About Integration Tests).
|
8
|
+
* Identify routes that has been defined in config/routes.rb but hasn't been implemented.
|
10
9
|
|
11
|
-
|
10
|
+
* Identify which routes of your application were never hitted by a Integration Test.
|
12
11
|
|
13
|
-
|
12
|
+
* Notify you which actions hasn't been tested while you are using your application by injecting html on the top of the page.
|
14
13
|
|
15
14
|
|
16
15
|
For What This Is Useful?
|
17
16
|
------------------------
|
18
17
|
|
19
|
-
* It is useful to me :)
|
20
|
-
|
21
18
|
* Suppose that you get a contract to work in a project but that was not started by you, you know that it has some tests, also you have seen
|
22
|
-
the coverage results but you want to live the experience using the application and seeing
|
19
|
+
the coverage results but you want to live the experience using the application and seeing which route is actually tested and which route don't.
|
23
20
|
|
24
21
|
* You were a Rumble Guy that thought that tests were not necessary? ok, may be this is for you if you don't want to drop all your code.
|
25
22
|
|
@@ -42,7 +39,7 @@ If you are not using Bundler
|
|
42
39
|
|
43
40
|
### Get a report of defined, implemented and tested routes ###
|
44
41
|
|
45
|
-
Run your
|
42
|
+
Run your **Integration Tests** and then ask for a report
|
46
43
|
|
47
44
|
rake route_dog:report
|
48
45
|
|
@@ -51,6 +48,18 @@ Run your *Integration Tests* and then call a report
|
|
51
48
|
|
52
49
|
### Browsing your application in Development ###
|
53
50
|
|
51
|
+
Create a file called route_dog.yml under your config directory.
|
52
|
+
|
53
|
+
---
|
54
|
+
watcher:
|
55
|
+
env:
|
56
|
+
- test
|
57
|
+
notifier:
|
58
|
+
env:
|
59
|
+
- test
|
60
|
+
- development
|
61
|
+
|
62
|
+
|
54
63
|
This will be appended to your application response
|
55
64
|
|
56
65
|
![Notifier Example](http://img.skitch.com/20101103-trxeweg66jh931qtpunh9u91gk.jpg "Notifier Example")
|
@@ -59,24 +68,17 @@ This will be appended to your application response
|
|
59
68
|
### Clean collected tested routes ###
|
60
69
|
|
61
70
|
This is useful if you had a test passing and then you remove the test from your codebase,
|
62
|
-
very uncommon,
|
71
|
+
*very uncommon*, and it should not be treated as a passing test anymore, here is the command.
|
63
72
|
|
64
73
|
rake route_dog:clean
|
65
74
|
|
66
75
|
|
67
|
-
TODO
|
68
|
-
----
|
69
|
-
|
70
|
-
* Rails 2.3 support.
|
71
|
-
* Show Notifier warnings for other than regular html responses.
|
72
|
-
* Generator to extract route_dog.yml config file, so you can disable the middlewares you don't want.
|
73
|
-
|
74
76
|
Notes
|
75
77
|
-----
|
76
78
|
|
77
79
|
* Watcher middleware don't work with Controller Tests, it only works with Integration Tests.
|
78
80
|
|
79
|
-
|
81
|
+
Development
|
80
82
|
-----------
|
81
83
|
|
82
84
|
If you are planning to contribute to this gem, please read the following advice.
|
data/Rakefile
CHANGED
@@ -22,10 +22,14 @@ rescue LoadError
|
|
22
22
|
end
|
23
23
|
|
24
24
|
desc "Default: run tests"
|
25
|
-
task :default => :test
|
25
|
+
task :default => [:test, :report]
|
26
26
|
|
27
27
|
task :test => "route_dog:clean"
|
28
28
|
|
29
|
+
task :report do
|
30
|
+
`cd test/mock_app && rake route_dog:report`
|
31
|
+
end
|
32
|
+
|
29
33
|
Rake::TestTask.new do |t|
|
30
34
|
t.libs << "lib" << "test"
|
31
35
|
t.test_files = FileList["test/**/*_test.rb"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.2
|
@@ -10,7 +10,7 @@ module RouteDog
|
|
10
10
|
|
11
11
|
status, headers, @response = @app.call(env)
|
12
12
|
|
13
|
-
append_warning if !::RouteDog.
|
13
|
+
append_warning if !::RouteDog.route_tested_with_requirements?(identify_controller, identify_action, request_method)
|
14
14
|
|
15
15
|
[status, headers, @response]
|
16
16
|
end
|
@@ -19,21 +19,16 @@ module RouteDog
|
|
19
19
|
|
20
20
|
def append_warning
|
21
21
|
@response.each do |part|
|
22
|
-
part.gsub!("<body>", "<body>#{
|
22
|
+
part.gsub!("<body>", "<body>#{warning_template}")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def no_test_message
|
27
|
-
"The Route #{request_method.to_s.upcase} #{identify_controller.to_s}##{identify_action.to_s} -- Has Not
|
27
|
+
"The Route #{request_method.to_s.upcase} #{identify_controller.to_s}##{identify_action.to_s} -- Has Not Integration Tests!"
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
|
32
|
-
<div style="display: block; height:70px;"></div>
|
33
|
-
<div id="route_dog_warning" style="display: block; width: 100%; height: 70px; text-align: center; margin:0; position:absolute; top:0; background: red; font-size: 18px; font-weight: bold">
|
34
|
-
<h1 style="color: #fff; font-size: 20px; margin: 20px 0 35px">#{no_test_message}</h1>
|
35
|
-
</div>
|
36
|
-
EOT
|
30
|
+
def warning_template
|
31
|
+
ERB.new(File.open(File.join(File.dirname(__FILE__), "..", "templates", "warning.html.erb")).read).result(binding)
|
37
32
|
end
|
38
33
|
end
|
39
34
|
end
|
data/lib/route_dog/railtie.rb
CHANGED
@@ -1,27 +1,30 @@
|
|
1
1
|
module RouteDog
|
2
2
|
class Railtie < Rails::Railtie
|
3
|
-
attr_reader :route_dog_config
|
4
3
|
|
5
4
|
rake_tasks do
|
6
5
|
load "tasks/tasks.rake"
|
7
6
|
end
|
8
7
|
|
9
8
|
initializer "route_dog.configure_rails_initialization" do |app|
|
10
|
-
load_route_dog_configuration
|
11
9
|
setup_middlewares(app)
|
12
10
|
end
|
13
11
|
|
14
12
|
private
|
15
13
|
|
16
14
|
def setup_middlewares(app)
|
17
|
-
|
18
|
-
|
15
|
+
if route_dog_configuration.fetch("watcher", {}).fetch("env", []).include?(Rails.env)
|
16
|
+
app.config.middleware.use RouteDog::Middleware::Watcher
|
17
|
+
end
|
18
|
+
|
19
|
+
if route_dog_configuration.fetch("notifier", {}).fetch("env", []).include?(Rails.env)
|
20
|
+
app.config.middleware.use RouteDog::Middleware::Notifier
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
|
-
def
|
22
|
-
|
24
|
+
def route_dog_configuration
|
25
|
+
YAML.load_file(File.join(Rails.root, 'config', 'middlewares_route_dog.yml'))
|
23
26
|
rescue Errno::ENOENT
|
24
|
-
|
27
|
+
{"watcher" => {"env" => ["test"]}, "notifier" => {"env" => ["development"]}}
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module RouteDog
|
4
|
+
|
5
|
+
class Report
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@defined_routes = Rails.application.routes.routes
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate
|
12
|
+
remove_not_user_routes!
|
13
|
+
map_routes_as_structs!
|
14
|
+
calculate_totals
|
15
|
+
save_report(template.result(binding))
|
16
|
+
open_report_in_browser
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.generate
|
20
|
+
self.new.generate
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def remove_not_user_routes!
|
26
|
+
@defined_routes.reject! { |r| r.path =~ %r{/rails/info/properties} } # Skip the route if it's internal info route
|
27
|
+
end
|
28
|
+
|
29
|
+
def template
|
30
|
+
ERB.new(File.open(File.join(File.dirname(__FILE__), "templates", "report.html.erb")).read)
|
31
|
+
end
|
32
|
+
|
33
|
+
def map_routes_as_structs!
|
34
|
+
@defined_routes.map! do |route|
|
35
|
+
r = OpenStruct.new
|
36
|
+
r.verb = route.verb
|
37
|
+
r.path = route.path
|
38
|
+
r.action = RouteDog.action_string_for_route(route)
|
39
|
+
r.tested = RouteDog.route_tested?(route)
|
40
|
+
r.implemented = implemented_route?(route)
|
41
|
+
r
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def calculate_totals
|
46
|
+
@implemented_routes_count = @defined_routes.select {|route| route.implemented }.size
|
47
|
+
@tested_routes_count = @defined_routes.select {|route| route.tested }.size
|
48
|
+
end
|
49
|
+
|
50
|
+
def save_report(html_report)
|
51
|
+
File.open(report_file, "w+") do |file|
|
52
|
+
file.puts(html_report)
|
53
|
+
end
|
54
|
+
|
55
|
+
puts("The report was saved in: #{report_file}")
|
56
|
+
end
|
57
|
+
|
58
|
+
def open_report_in_browser
|
59
|
+
Launchy::Browser.run(report_file) if defined?(Launchy)
|
60
|
+
end
|
61
|
+
|
62
|
+
def report_file
|
63
|
+
File.join(Rails.root, "tmp", Rails.application.class.to_s.gsub(":", "").concat("RoutesReport.html").underscore)
|
64
|
+
end
|
65
|
+
|
66
|
+
def implemented_route?(route)
|
67
|
+
controller = find_or_instantiate_controller_for(route)
|
68
|
+
if route.requirements.has_key?(:action)
|
69
|
+
controller.respond_to?(route.requirements[:action])
|
70
|
+
else
|
71
|
+
controller.class.instance_methods(false).any?
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def find_or_instantiate_controller_for(route)
|
76
|
+
requirements = route.requirements
|
77
|
+
@instantiated_controllers ||= {}
|
78
|
+
if @instantiated_controllers.has_key?(requirements[:controller])
|
79
|
+
@instantiated_controllers[requirements[:controller]]
|
80
|
+
else
|
81
|
+
begin
|
82
|
+
@instantiated_controllers[requirements[:controller]] = RouteDog.constantize_controller_str(requirements[:controller]).new
|
83
|
+
rescue
|
84
|
+
false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<style type="text/css">
|
4
|
+
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
5
|
+
a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp,
|
6
|
+
small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset,
|
7
|
+
form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
|
8
|
+
margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent;}
|
9
|
+
|
10
|
+
body { margin: 0; padding: 0; font:15.34px helvetica,arial,freesans,clean,sans-serif; }
|
11
|
+
#header { background: red; color: #fff; display: block; height: 70px; }
|
12
|
+
h1 { font-size: 18px; padding: 10px 0 0 25px; }
|
13
|
+
table#routes { width: 100%; padding: 40px 25px 0; }
|
14
|
+
table#routes th, table#routes td { text-align: left; padding: 5px; }
|
15
|
+
table#routes tr:nth-child(odd) { background: #eee;}
|
16
|
+
div#route_stats {}
|
17
|
+
span.yes { color: green; font-weight: bold }
|
18
|
+
span.no { color: red; font-weight: bold }
|
19
|
+
div#route_stats { background: #444; color: #fff; height: 30px; position: absolute; top: 50px; width: 100%; border-bottom: solid 4px #666 }
|
20
|
+
div#route_stats p { padding: 10px 0 0 25px; }
|
21
|
+
div#route_stats span { margin: 0 50px 0 10px; color: #fff; font-weight: bold; }
|
22
|
+
div#route_stats span.zero_routes { background: #666; padding: 2px; 5px; }
|
23
|
+
</style>
|
24
|
+
</head>
|
25
|
+
<body>
|
26
|
+
<div id="header">
|
27
|
+
<h1>Route Dog - <%= Rails.application.class.to_s.gsub(/::/, ' ') %> - Routes Report</h1>
|
28
|
+
</div>
|
29
|
+
<table id="routes">
|
30
|
+
<tr><th>Method</th><th>Path</th><th>Action</th><th>Implemented</th><th>Tested</th></tr>
|
31
|
+
<% @defined_routes.each do |route| %>
|
32
|
+
<tr>
|
33
|
+
<td><%= route.verb %></td>
|
34
|
+
<td><%= route.path %></td>
|
35
|
+
<td><%= route.action %></td>
|
36
|
+
<td><%= route.implemented ? "<span class='yes'>YES</span>" : "<span class='no'>NO</span>" %></td>
|
37
|
+
<td><%= route.tested ? "<span class='yes'>YES</span>" : "<span class='no'>NO</span>" %></td>
|
38
|
+
<% end %>
|
39
|
+
</table>
|
40
|
+
<div id="route_stats">
|
41
|
+
<p>
|
42
|
+
<strong>Defined:</strong> <span class="value"><%= @defined_routes.size %></span>
|
43
|
+
<strong>Implemented:</strong> <span class="value"><%= @implemented_routes_count %></span>
|
44
|
+
<strong>Tested:</strong> <span class="value"><%= @tested_routes_count %></span>
|
45
|
+
<% if @tested_routes_count == 0 %>
|
46
|
+
<span class="zero_routes">You have 0 routes tested, may be you should run your Integrational Tests First!</span>
|
47
|
+
<% end %>
|
48
|
+
<p>
|
49
|
+
</div>
|
50
|
+
</body>
|
51
|
+
</html>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<div style="display: block; height:70px;"></div>
|
2
|
+
<div id="route_dog_warning"
|
3
|
+
style="display: block; width: 100%; height: 70px;
|
4
|
+
text-align: center; margin:0; position:absolute;
|
5
|
+
top:0; background: red; font-size: 18px;
|
6
|
+
font-weight: bold">
|
7
|
+
<div style="display:block; color: #fff; font-size: 20px; margin: 20px 0 35px"><%= no_test_message %></div>
|
8
|
+
</div>
|
data/lib/route_dog.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'route_dog/middleware'
|
2
|
+
require 'route_dog/report'
|
2
3
|
require 'route_dog/railtie' if defined?(Rails)
|
3
4
|
|
4
5
|
module RouteDog
|
5
6
|
def self.config_file
|
6
|
-
File.join(Rails.root, '
|
7
|
+
File.join(Rails.root, 'tmp', 'route_dog_routes.yml')
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.load_watched_routes
|
@@ -17,7 +18,7 @@ module RouteDog
|
|
17
18
|
end
|
18
19
|
|
19
20
|
# When method.nil? it respond to all methods.
|
20
|
-
def self.
|
21
|
+
def self.route_tested_with_requirements?(controller, action, method)
|
21
22
|
begin
|
22
23
|
available_methods = load_watched_routes[controller.to_s.downcase][action.to_s.downcase]
|
23
24
|
method.nil? ? available_methods.any? : available_methods.include?(method.to_s.downcase)
|
@@ -26,7 +27,16 @@ module RouteDog
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
30
|
+
def self.route_tested?(route)
|
31
|
+
requirements = route.requirements
|
32
|
+
route_tested_with_requirements?(requirements[:controller], requirements[:action], route.verb)
|
33
|
+
end
|
34
|
+
|
29
35
|
def self.constantize_controller_str(controller)
|
30
36
|
controller.split("/").map{|c| c.split("_").map{|cc| cc.capitalize}.join }.join("::").concat("Controller").constantize
|
31
37
|
end
|
38
|
+
|
39
|
+
def self.action_string_for_route(route)
|
40
|
+
"#{route.requirements[:controller]}##{route.requirements[:action]}"
|
41
|
+
end
|
32
42
|
end
|
data/lib/tasks/tasks.rake
CHANGED
@@ -7,110 +7,13 @@ end
|
|
7
7
|
namespace :route_dog do
|
8
8
|
desc "Clean Tested Routes File"
|
9
9
|
task :clean do
|
10
|
-
File.delete("test/mock_app/
|
10
|
+
File.delete("test/mock_app/tmp/route_dog_routes.yml") if File.exists? "test/mock_app/tmp/route_dog_routes.yml"
|
11
11
|
puts "\nRoute Dog tested routes definition file deleted."
|
12
12
|
end
|
13
13
|
|
14
14
|
desc "Create A Html Report Of The Routes Defined, Tested And Used"
|
15
15
|
task :report => :environment do
|
16
16
|
puts "\nCreate A Html Report Of The Routes Defined, Tested And Used\n"
|
17
|
-
|
18
|
-
@tested_routes = []
|
19
|
-
@defined_routes = Rails.application.routes.routes
|
20
|
-
@defined_routes.reject! { |r| r.path =~ %r{/rails/info/properties} } # Skip the route if it's internal info route
|
21
|
-
save_and_open_report_in_browser(ERB.new(report_template).result(binding))
|
17
|
+
RouteDog::Report.generate
|
22
18
|
end
|
23
19
|
end
|
24
|
-
|
25
|
-
def save_and_open_report_in_browser(html_report)
|
26
|
-
path = File.join(Rails.root, "tmp", Rails.application.class.to_s.gsub(":", "").concat("RoutesReport.html").underscore)
|
27
|
-
File.open(path, "w+") {|file| file.puts(html_report) }
|
28
|
-
defined?(Launchy) ? Launchy::Browser.run(path) : puts("The report was saved in: #{path}")
|
29
|
-
end
|
30
|
-
|
31
|
-
def implemented_route?(route)
|
32
|
-
if find_or_instantiate_controller_for(route).respond_to?(route.requirements[:action])
|
33
|
-
@implemented_routes << route
|
34
|
-
true
|
35
|
-
else
|
36
|
-
false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def tested_route?(route)
|
41
|
-
requirements = route.requirements
|
42
|
-
if RouteDog.route_tested?(requirements[:controller], requirements[:action], route.verb)
|
43
|
-
@tested_routes << route
|
44
|
-
true
|
45
|
-
else
|
46
|
-
false
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def find_or_instantiate_controller_for(route)
|
51
|
-
requirements = route.requirements
|
52
|
-
@instantiated_controllers ||= {}
|
53
|
-
if @instantiated_controllers.has_key?(requirements[:controller])
|
54
|
-
@instantiated_controllers[requirements[:controller]]
|
55
|
-
else
|
56
|
-
begin
|
57
|
-
@instantiated_controllers[requirements[:controller]] = RouteDog.constantize_controller_str(requirements[:controller]).new
|
58
|
-
rescue
|
59
|
-
false
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def report_template
|
65
|
-
<<-EOT
|
66
|
-
<html>
|
67
|
-
<head>
|
68
|
-
<style type="text/css">
|
69
|
-
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
70
|
-
a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp,
|
71
|
-
small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset,
|
72
|
-
form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
|
73
|
-
margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent;}
|
74
|
-
|
75
|
-
body { margin: 0; padding: 0; font:15.34px helvetica,arial,freesans,clean,sans-serif; }
|
76
|
-
#header { background: red; color: #fff; display: block; height: 70px; }
|
77
|
-
h1 { font-size: 18px; padding: 10px 0 0 25px; }
|
78
|
-
table#routes { width: 100%; padding: 40px 25px 0; }
|
79
|
-
table#routes th, table#routes td { text-align: left; padding: 5px; }
|
80
|
-
table#routes tr:nth-child(odd) { background: #eee;}
|
81
|
-
div#route_stats {}
|
82
|
-
span.yes { color: green; font-weight: bold }
|
83
|
-
span.no { color: red; font-weight: bold }
|
84
|
-
div#route_stats { background: #444; color: #fff; height: 30px; position: absolute; top: 50px; width: 100%; border-bottom: solid 4px #666 }
|
85
|
-
div#route_stats p { padding: 10px 0 0 25px; }
|
86
|
-
div#route_stats span { margin: 0 50px 0 10px; color: #fff; font-weight: bold; }
|
87
|
-
div#route_stats span.zero_routes { background: #666; padding: 2px; 5px; }
|
88
|
-
</style>
|
89
|
-
</head>
|
90
|
-
<body>
|
91
|
-
<div id="header">
|
92
|
-
<h1>Route Dog - <%= Rails.application.class.to_s.gsub(/::/, ' ') %> - Routes Report</h1>
|
93
|
-
</div>
|
94
|
-
<table id="routes">
|
95
|
-
<tr><th>Method</th><th>Path</th><th>Action</th><th>Implemented</th><th>Tested</th></tr>
|
96
|
-
<% @defined_routes.each do |route| %>
|
97
|
-
<tr>
|
98
|
-
<td><%= route.verb %></td>
|
99
|
-
<td><%= route.path %></td>
|
100
|
-
<td><%= route.requirements[:controller] + '#' + route.requirements[:action] %></td>
|
101
|
-
<td><%= implemented_route?(route) ? "<span class='yes'>YES</span>" : "<span class='no'>NO</span>" %></td>
|
102
|
-
<td><%= tested_route?(route) ? "<span class='yes'>YES</span>" : "<span class='no'>NO</span>" %></td>
|
103
|
-
<% end %>
|
104
|
-
</table>
|
105
|
-
<div id="route_stats">
|
106
|
-
<p>
|
107
|
-
<strong>Defined:</strong> <span class="value"><%= @defined_routes.size %></span>
|
108
|
-
<strong>Implemented:</strong> <span class="value"><%= @implemented_routes.size %></span>
|
109
|
-
<strong>Tested:</strong> <span class="value"><%= @tested_routes.size %></span>
|
110
|
-
<% 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 %>
|
111
|
-
<p>
|
112
|
-
</div>
|
113
|
-
</body>
|
114
|
-
</html>
|
115
|
-
EOT
|
116
|
-
end
|
data/route_dog.gemspec
CHANGED
@@ -1,124 +1,128 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{route_dog}
|
8
|
-
s.version = "2.2
|
8
|
+
s.version = "2.4.2"
|
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{
|
12
|
+
s.date = %q{2011-04-14}
|
13
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
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
20
|
+
"LICENSE",
|
21
|
+
"README.md",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/route_dog.rb",
|
25
|
+
"lib/route_dog/middleware.rb",
|
26
|
+
"lib/route_dog/middleware/notifier.rb",
|
27
|
+
"lib/route_dog/middleware/route_dog.rb",
|
28
|
+
"lib/route_dog/middleware/watcher.rb",
|
29
|
+
"lib/route_dog/railtie.rb",
|
30
|
+
"lib/route_dog/report.rb",
|
31
|
+
"lib/route_dog/templates/report.html.erb",
|
32
|
+
"lib/route_dog/templates/warning.html.erb",
|
33
|
+
"lib/tasks/tasks.rake",
|
34
|
+
"route_dog.gemspec",
|
35
|
+
"test/integration/pages_controller_test.rb",
|
36
|
+
"test/integration/products_controller_test.rb",
|
37
|
+
"test/integration/sessions_controller_test.rb",
|
38
|
+
"test/integration/users_controller_test.rb",
|
39
|
+
"test/mock_app/.gitignore",
|
40
|
+
"test/mock_app/Gemfile",
|
41
|
+
"test/mock_app/Rakefile",
|
42
|
+
"test/mock_app/app/controllers/admin/blogs/posts_controller.rb",
|
43
|
+
"test/mock_app/app/controllers/admin/project_settings_controller.rb",
|
44
|
+
"test/mock_app/app/controllers/admin/users_controller.rb",
|
45
|
+
"test/mock_app/app/controllers/application_controller.rb",
|
46
|
+
"test/mock_app/app/controllers/pages_controller.rb",
|
47
|
+
"test/mock_app/app/controllers/products_controller.rb",
|
48
|
+
"test/mock_app/app/controllers/project_settings_controller.rb",
|
49
|
+
"test/mock_app/app/controllers/sessions_controller.rb",
|
50
|
+
"test/mock_app/app/controllers/users_controller.rb",
|
51
|
+
"test/mock_app/app/helpers/application_helper.rb",
|
52
|
+
"test/mock_app/app/views/layouts/application.html.erb",
|
53
|
+
"test/mock_app/app/views/users/index.html.erb",
|
54
|
+
"test/mock_app/config.ru",
|
55
|
+
"test/mock_app/config/application.rb",
|
56
|
+
"test/mock_app/config/boot.rb",
|
57
|
+
"test/mock_app/config/database.yml",
|
58
|
+
"test/mock_app/config/environment.rb",
|
59
|
+
"test/mock_app/config/environments/development.rb",
|
60
|
+
"test/mock_app/config/environments/production.rb",
|
61
|
+
"test/mock_app/config/environments/test.rb",
|
62
|
+
"test/mock_app/config/initializers/backtrace_silencers.rb",
|
63
|
+
"test/mock_app/config/initializers/inflections.rb",
|
64
|
+
"test/mock_app/config/initializers/mime_types.rb",
|
65
|
+
"test/mock_app/config/initializers/secret_token.rb",
|
66
|
+
"test/mock_app/config/initializers/session_store.rb",
|
67
|
+
"test/mock_app/config/locales/en.yml",
|
68
|
+
"test/mock_app/config/middlewares_route_dog.yml",
|
69
|
+
"test/mock_app/config/routes.rb",
|
70
|
+
"test/mock_app/db/seeds.rb",
|
71
|
+
"test/mock_app/public/404.html",
|
72
|
+
"test/mock_app/public/422.html",
|
73
|
+
"test/mock_app/public/500.html",
|
74
|
+
"test/mock_app/public/favicon.ico",
|
75
|
+
"test/mock_app/public/images/rails.png",
|
76
|
+
"test/mock_app/public/index.html",
|
77
|
+
"test/mock_app/public/javascripts/application.js",
|
78
|
+
"test/mock_app/public/javascripts/controls.js",
|
79
|
+
"test/mock_app/public/javascripts/dragdrop.js",
|
80
|
+
"test/mock_app/public/javascripts/effects.js",
|
81
|
+
"test/mock_app/public/javascripts/prototype.js",
|
82
|
+
"test/mock_app/public/javascripts/rails.js",
|
83
|
+
"test/mock_app/public/robots.txt",
|
84
|
+
"test/mock_app/public/stylesheets/.gitkeep",
|
85
|
+
"test/mock_app/tmp/.gitignore",
|
86
|
+
"test/support/assertions.rb",
|
87
|
+
"test/test_helper.rb",
|
88
|
+
"test/unit/route_dog_test.rb"
|
86
89
|
]
|
87
90
|
s.homepage = %q{http://github.com/zevarito/route_dog}
|
88
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
89
91
|
s.require_paths = ["lib"]
|
90
92
|
s.rubyforge_project = %q{routedog}
|
91
93
|
s.rubygems_version = %q{1.3.7}
|
92
94
|
s.summary = %q{Watch and Notify your not tested routes of a RoR Application}
|
93
95
|
s.test_files = [
|
96
|
+
"test/integration/pages_controller_test.rb",
|
94
97
|
"test/integration/products_controller_test.rb",
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
98
|
+
"test/integration/sessions_controller_test.rb",
|
99
|
+
"test/integration/users_controller_test.rb",
|
100
|
+
"test/mock_app/app/controllers/admin/blogs/posts_controller.rb",
|
101
|
+
"test/mock_app/app/controllers/admin/project_settings_controller.rb",
|
102
|
+
"test/mock_app/app/controllers/admin/users_controller.rb",
|
103
|
+
"test/mock_app/app/controllers/application_controller.rb",
|
104
|
+
"test/mock_app/app/controllers/pages_controller.rb",
|
105
|
+
"test/mock_app/app/controllers/products_controller.rb",
|
106
|
+
"test/mock_app/app/controllers/project_settings_controller.rb",
|
107
|
+
"test/mock_app/app/controllers/sessions_controller.rb",
|
108
|
+
"test/mock_app/app/controllers/users_controller.rb",
|
109
|
+
"test/mock_app/app/helpers/application_helper.rb",
|
110
|
+
"test/mock_app/config/application.rb",
|
111
|
+
"test/mock_app/config/boot.rb",
|
112
|
+
"test/mock_app/config/environment.rb",
|
113
|
+
"test/mock_app/config/environments/development.rb",
|
114
|
+
"test/mock_app/config/environments/production.rb",
|
115
|
+
"test/mock_app/config/environments/test.rb",
|
116
|
+
"test/mock_app/config/initializers/backtrace_silencers.rb",
|
117
|
+
"test/mock_app/config/initializers/inflections.rb",
|
118
|
+
"test/mock_app/config/initializers/mime_types.rb",
|
119
|
+
"test/mock_app/config/initializers/secret_token.rb",
|
120
|
+
"test/mock_app/config/initializers/session_store.rb",
|
121
|
+
"test/mock_app/config/routes.rb",
|
122
|
+
"test/mock_app/db/seeds.rb",
|
123
|
+
"test/support/assertions.rb",
|
124
|
+
"test/test_helper.rb",
|
125
|
+
"test/unit/route_dog_test.rb"
|
122
126
|
]
|
123
127
|
|
124
128
|
if s.respond_to? :specification_version then
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper.rb')
|
2
|
+
|
3
|
+
class PagesControllerTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@controller = PagesController.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Hiting routes" do
|
10
|
+
test "Hit a route with an unespecified action" do
|
11
|
+
get "/pages/home"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
File without changes
|
data/test/support/assertions.rb
CHANGED
@@ -22,6 +22,7 @@ end
|
|
22
22
|
|
23
23
|
def assert_notify_for(controller, action, method = :get)
|
24
24
|
html_notification = Nokogiri::HTML(response.body).search('div#route_dog_warning')
|
25
|
+
assert html_notification.text =~ /Has Not Integration Tests/
|
25
26
|
assert html_notification.any?, "Expected {:controller => :#{controller}, :action => :#{action}, :method => :#{method}} Notify That The Route Has Not Tests"
|
26
27
|
end
|
27
28
|
|
data/test/unit/route_dog_test.rb
CHANGED
@@ -31,12 +31,12 @@ class RouteDogTest < Test::Unit::TestCase
|
|
31
31
|
|
32
32
|
test "identify routes that respond to get method" do
|
33
33
|
write_tested_routes_yaml("products" => {"index" => ["get"]})
|
34
|
-
assert_equal true, RouteDog.
|
34
|
+
assert_equal true, RouteDog.route_tested_with_requirements?(:products, :index, :get)
|
35
35
|
end
|
36
36
|
|
37
37
|
test "identify routes that respond to any method" do
|
38
38
|
write_tested_routes_yaml("products" => {"index" => ["get"]})
|
39
|
-
assert_equal true, RouteDog.
|
39
|
+
assert_equal true, RouteDog.route_tested_with_requirements?(:products, :index, nil)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 4
|
9
|
+
- 2
|
10
|
+
version: 2.4.2
|
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: 2011-04-
|
18
|
+
date: 2011-04-14 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -101,8 +101,12 @@ files:
|
|
101
101
|
- lib/route_dog/middleware/route_dog.rb
|
102
102
|
- lib/route_dog/middleware/watcher.rb
|
103
103
|
- lib/route_dog/railtie.rb
|
104
|
+
- lib/route_dog/report.rb
|
105
|
+
- lib/route_dog/templates/report.html.erb
|
106
|
+
- lib/route_dog/templates/warning.html.erb
|
104
107
|
- lib/tasks/tasks.rake
|
105
108
|
- route_dog.gemspec
|
109
|
+
- test/integration/pages_controller_test.rb
|
106
110
|
- test/integration/products_controller_test.rb
|
107
111
|
- test/integration/sessions_controller_test.rb
|
108
112
|
- test/integration/users_controller_test.rb
|
@@ -113,6 +117,7 @@ files:
|
|
113
117
|
- test/mock_app/app/controllers/admin/project_settings_controller.rb
|
114
118
|
- test/mock_app/app/controllers/admin/users_controller.rb
|
115
119
|
- test/mock_app/app/controllers/application_controller.rb
|
120
|
+
- test/mock_app/app/controllers/pages_controller.rb
|
116
121
|
- test/mock_app/app/controllers/products_controller.rb
|
117
122
|
- test/mock_app/app/controllers/project_settings_controller.rb
|
118
123
|
- test/mock_app/app/controllers/sessions_controller.rb
|
@@ -134,7 +139,7 @@ files:
|
|
134
139
|
- test/mock_app/config/initializers/secret_token.rb
|
135
140
|
- test/mock_app/config/initializers/session_store.rb
|
136
141
|
- test/mock_app/config/locales/en.yml
|
137
|
-
- test/mock_app/config/
|
142
|
+
- test/mock_app/config/middlewares_route_dog.yml
|
138
143
|
- test/mock_app/config/routes.rb
|
139
144
|
- test/mock_app/db/seeds.rb
|
140
145
|
- test/mock_app/public/404.html
|
@@ -190,6 +195,7 @@ signing_key:
|
|
190
195
|
specification_version: 3
|
191
196
|
summary: Watch and Notify your not tested routes of a RoR Application
|
192
197
|
test_files:
|
198
|
+
- test/integration/pages_controller_test.rb
|
193
199
|
- test/integration/products_controller_test.rb
|
194
200
|
- test/integration/sessions_controller_test.rb
|
195
201
|
- test/integration/users_controller_test.rb
|
@@ -197,6 +203,7 @@ test_files:
|
|
197
203
|
- test/mock_app/app/controllers/admin/project_settings_controller.rb
|
198
204
|
- test/mock_app/app/controllers/admin/users_controller.rb
|
199
205
|
- test/mock_app/app/controllers/application_controller.rb
|
206
|
+
- test/mock_app/app/controllers/pages_controller.rb
|
200
207
|
- test/mock_app/app/controllers/products_controller.rb
|
201
208
|
- test/mock_app/app/controllers/project_settings_controller.rb
|
202
209
|
- test/mock_app/app/controllers/sessions_controller.rb
|