route_dog 2.0.1
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/.gitignore +1 -0
- data/README.md +62 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/lib/route_dog/middleware/notifier.rb +39 -0
- data/lib/route_dog/middleware/route_dog.rb +51 -0
- data/lib/route_dog/middleware/watcher.rb +32 -0
- data/lib/route_dog.rb +3 -0
- data/route_dog.gemspec +130 -0
- data/test/integration/products_controller_test.rb +41 -0
- data/test/integration/sessions_controller.rb +18 -0
- data/test/integration/users_controller_test.rb +85 -0
- data/test/mock_app/.gitignore +4 -0
- data/test/mock_app/Gemfile +30 -0
- data/test/mock_app/Gemfile.lock +73 -0
- data/test/mock_app/Rakefile +7 -0
- data/test/mock_app/app/controllers/application_controller.rb +3 -0
- data/test/mock_app/app/controllers/products_controller.rb +21 -0
- data/test/mock_app/app/controllers/sessions_controller_test.rb +5 -0
- data/test/mock_app/app/controllers/users_controller.rb +29 -0
- data/test/mock_app/app/helpers/application_helper.rb +2 -0
- data/test/mock_app/app/views/layouts/application.html.erb +14 -0
- data/test/mock_app/app/views/users/index.html.erb +0 -0
- data/test/mock_app/config/application.rb +42 -0
- data/test/mock_app/config/boot.rb +13 -0
- data/test/mock_app/config/database.yml +22 -0
- data/test/mock_app/config/environment.rb +5 -0
- data/test/mock_app/config/environments/development.rb +26 -0
- data/test/mock_app/config/environments/production.rb +49 -0
- data/test/mock_app/config/environments/test.rb +35 -0
- data/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/mock_app/config/initializers/inflections.rb +10 -0
- data/test/mock_app/config/initializers/mime_types.rb +5 -0
- data/test/mock_app/config/initializers/route_dog.rb +6 -0
- data/test/mock_app/config/initializers/secret_token.rb +7 -0
- data/test/mock_app/config/initializers/session_store.rb +8 -0
- data/test/mock_app/config/locales/en.yml +5 -0
- data/test/mock_app/config/routes.rb +67 -0
- data/test/mock_app/config.ru +4 -0
- data/test/mock_app/db/seeds.rb +7 -0
- data/test/mock_app/public/404.html +26 -0
- data/test/mock_app/public/422.html +26 -0
- data/test/mock_app/public/500.html +26 -0
- data/test/mock_app/public/favicon.ico +0 -0
- data/test/mock_app/public/images/rails.png +0 -0
- data/test/mock_app/public/index.html +239 -0
- data/test/mock_app/public/javascripts/application.js +2 -0
- data/test/mock_app/public/javascripts/controls.js +965 -0
- data/test/mock_app/public/javascripts/dragdrop.js +974 -0
- data/test/mock_app/public/javascripts/effects.js +1123 -0
- data/test/mock_app/public/javascripts/prototype.js +6001 -0
- data/test/mock_app/public/javascripts/rails.js +175 -0
- data/test/mock_app/public/robots.txt +5 -0
- data/test/mock_app/public/stylesheets/.gitkeep +0 -0
- data/test/support/assertions.rb +31 -0
- data/test/test_helper.rb +12 -0
- metadata +207 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
test/mock_app/config/route_dog_routes.yml
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
RouteDog for Ruby on Rails
|
2
|
+
==========================
|
3
|
+
|
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
|
+
|
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).
|
8
|
+
|
9
|
+
The way that RouteDog shows to you a warning is through a middleware called Notifier which only runs in Developement Enviroment.
|
10
|
+
|
11
|
+
|
12
|
+
For What This Is Useful?
|
13
|
+
------------------------
|
14
|
+
|
15
|
+
* It is useful to me :)
|
16
|
+
|
17
|
+
* 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
|
18
|
+
the coverage results but you want to live the experience using the application and seeing what route is actually tested and what not.
|
19
|
+
|
20
|
+
* 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.
|
21
|
+
|
22
|
+
* Even if you are not planning to write Integrational Tests you can take advantage of the route defined, tested and used report.
|
23
|
+
|
24
|
+
|
25
|
+
Usage
|
26
|
+
-----
|
27
|
+
|
28
|
+
Fetch the gem
|
29
|
+
|
30
|
+
sudo gem install route_dog
|
31
|
+
|
32
|
+
Create a file RAILS_ROOT/config/initializers/route_dog.rb and put the lines below (see notes)
|
33
|
+
|
34
|
+
Rails.application.config.middleware.use RouteDog::Middleware::Watcher if Rails.env.test?
|
35
|
+
|
36
|
+
Rails.application.config.middleware.use RouteDog::Middleware::Notifier if Rails.env.development?
|
37
|
+
|
38
|
+
Run your Integrational Tests
|
39
|
+
|
40
|
+
Run your application in Development Mode
|
41
|
+
|
42
|
+
TODO
|
43
|
+
----
|
44
|
+
|
45
|
+
* 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.
|
49
|
+
|
50
|
+
Notes
|
51
|
+
-----
|
52
|
+
|
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.
|
55
|
+
|
56
|
+
* Watcher and Notifier middlewares may need be loaded after or before another middleware, that is the case if you are using Warden.
|
57
|
+
|
58
|
+
`Rails.application.config.middleware.insert_before Warden::Manager, RouteDog::Middleware::Watcher if Rails.env.test?`
|
59
|
+
|
60
|
+
`Rails.application.config.middleware.insert_before Warden::Manager, RouteDog::Middleware::Notifier if Rails.env.development?`
|
61
|
+
|
62
|
+
* Be sure to call `rake route_dog:clean` once in a while to ensure that the tested route list remains updated.
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "rake/testtask"
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |gem|
|
6
|
+
gem.name = "route_dog"
|
7
|
+
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.email = "zevarito@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/zevarito/route_dog"
|
11
|
+
gem.authors = ["Alvaro Gil"]
|
12
|
+
gem.add_dependency 'rack'
|
13
|
+
gem.add_dependency 'rails', '>=2.3.8'
|
14
|
+
gem.add_development_dependency "contest", "=0.1.2"
|
15
|
+
gem.add_development_dependency "nokogiri", "=1.4.3.1"
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Default: run tests"
|
23
|
+
task :default => :test
|
24
|
+
|
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
|
31
|
+
|
32
|
+
Rake::TestTask.new do |t|
|
33
|
+
Rake::Task["route_dog:clean"].invoke
|
34
|
+
t.libs << "lib" << "test"
|
35
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
36
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.1
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module RouteDog
|
2
|
+
module Middleware
|
3
|
+
class Notifier < RouteDog
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
@env = env
|
11
|
+
|
12
|
+
status, headers, @response = @app.call(env)
|
13
|
+
|
14
|
+
append_warning if !route_tested?
|
15
|
+
|
16
|
+
[status, headers, @response]
|
17
|
+
end
|
18
|
+
|
19
|
+
def append_warning
|
20
|
+
@response.each do |part|
|
21
|
+
part.gsub!("<body>", "<body>#{warning_html}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def no_test_message
|
26
|
+
"The Route #{request_method.to_s.upcase} #{identify_controller.to_s}##{identify_action.to_s} -- Has Not Integrational Tests!"
|
27
|
+
end
|
28
|
+
|
29
|
+
def warning_html
|
30
|
+
<<-EOT
|
31
|
+
<div style="display: block; height:70px;"></div>
|
32
|
+
<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">
|
33
|
+
<h1 style="color: #fff; font-size: 20px; margin: 20px 0 35px">#{no_test_message}</h1>
|
34
|
+
</div>
|
35
|
+
EOT
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
3
|
+
module RouteDog
|
4
|
+
module Middleware
|
5
|
+
class RouteDog
|
6
|
+
def initialize(app)
|
7
|
+
require File.join(Rails.root, 'config/routes.rb')
|
8
|
+
initialize_yaml_file
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Rails.root, 'config', 'route_dog_routes.yml')
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize_yaml_file
|
16
|
+
@watched_routes = YAML.load_file(Watcher.config_file)
|
17
|
+
rescue Errno::ENOENT
|
18
|
+
@watched_routes = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def request_path
|
22
|
+
@env['PATH_INFO']
|
23
|
+
end
|
24
|
+
|
25
|
+
def request_method
|
26
|
+
@env['REQUEST_METHOD'].downcase.to_sym
|
27
|
+
end
|
28
|
+
|
29
|
+
def identify_controller
|
30
|
+
identify_path[:controller]
|
31
|
+
end
|
32
|
+
|
33
|
+
def identify_action
|
34
|
+
identify_path[:action]
|
35
|
+
end
|
36
|
+
|
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
|
+
def identify_path
|
47
|
+
Rails.application.routes.recognize_path(request_path, :method => request_method)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RouteDog
|
2
|
+
module Middleware
|
3
|
+
class Watcher < RouteDog
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
@env = env
|
11
|
+
|
12
|
+
status, headers, response = @app.call(env)
|
13
|
+
|
14
|
+
store_route if status.to_i < 400
|
15
|
+
|
16
|
+
[status, headers, response]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
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) }
|
27
|
+
rescue ActionController::RoutingError
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/route_dog.rb
ADDED
data/route_dog.gemspec
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{route_dog}
|
8
|
+
s.version = "2.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
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}
|
14
|
+
s.email = %q{zevarito@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"lib/route_dog.rb",
|
24
|
+
"lib/route_dog/middleware/notifier.rb",
|
25
|
+
"lib/route_dog/middleware/route_dog.rb",
|
26
|
+
"lib/route_dog/middleware/watcher.rb",
|
27
|
+
"route_dog.gemspec",
|
28
|
+
"test/integration/products_controller_test.rb",
|
29
|
+
"test/integration/sessions_controller.rb",
|
30
|
+
"test/integration/users_controller_test.rb",
|
31
|
+
"test/mock_app/.gitignore",
|
32
|
+
"test/mock_app/Gemfile",
|
33
|
+
"test/mock_app/Gemfile.lock",
|
34
|
+
"test/mock_app/Rakefile",
|
35
|
+
"test/mock_app/app/controllers/application_controller.rb",
|
36
|
+
"test/mock_app/app/controllers/products_controller.rb",
|
37
|
+
"test/mock_app/app/controllers/sessions_controller_test.rb",
|
38
|
+
"test/mock_app/app/controllers/users_controller.rb",
|
39
|
+
"test/mock_app/app/helpers/application_helper.rb",
|
40
|
+
"test/mock_app/app/views/layouts/application.html.erb",
|
41
|
+
"test/mock_app/app/views/users/index.html.erb",
|
42
|
+
"test/mock_app/config.ru",
|
43
|
+
"test/mock_app/config/application.rb",
|
44
|
+
"test/mock_app/config/boot.rb",
|
45
|
+
"test/mock_app/config/database.yml",
|
46
|
+
"test/mock_app/config/environment.rb",
|
47
|
+
"test/mock_app/config/environments/development.rb",
|
48
|
+
"test/mock_app/config/environments/production.rb",
|
49
|
+
"test/mock_app/config/environments/test.rb",
|
50
|
+
"test/mock_app/config/initializers/backtrace_silencers.rb",
|
51
|
+
"test/mock_app/config/initializers/inflections.rb",
|
52
|
+
"test/mock_app/config/initializers/mime_types.rb",
|
53
|
+
"test/mock_app/config/initializers/route_dog.rb",
|
54
|
+
"test/mock_app/config/initializers/secret_token.rb",
|
55
|
+
"test/mock_app/config/initializers/session_store.rb",
|
56
|
+
"test/mock_app/config/locales/en.yml",
|
57
|
+
"test/mock_app/config/routes.rb",
|
58
|
+
"test/mock_app/db/seeds.rb",
|
59
|
+
"test/mock_app/public/404.html",
|
60
|
+
"test/mock_app/public/422.html",
|
61
|
+
"test/mock_app/public/500.html",
|
62
|
+
"test/mock_app/public/favicon.ico",
|
63
|
+
"test/mock_app/public/images/rails.png",
|
64
|
+
"test/mock_app/public/index.html",
|
65
|
+
"test/mock_app/public/javascripts/application.js",
|
66
|
+
"test/mock_app/public/javascripts/controls.js",
|
67
|
+
"test/mock_app/public/javascripts/dragdrop.js",
|
68
|
+
"test/mock_app/public/javascripts/effects.js",
|
69
|
+
"test/mock_app/public/javascripts/prototype.js",
|
70
|
+
"test/mock_app/public/javascripts/rails.js",
|
71
|
+
"test/mock_app/public/robots.txt",
|
72
|
+
"test/mock_app/public/stylesheets/.gitkeep",
|
73
|
+
"test/support/assertions.rb",
|
74
|
+
"test/test_helper.rb"
|
75
|
+
]
|
76
|
+
s.homepage = %q{http://github.com/zevarito/route_dog}
|
77
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
78
|
+
s.require_paths = ["lib"]
|
79
|
+
s.rubygems_version = %q{1.3.7}
|
80
|
+
s.summary = %q{Watch and Notify your not tested routes of a RoR Application}
|
81
|
+
s.test_files = [
|
82
|
+
"test/integration/products_controller_test.rb",
|
83
|
+
"test/integration/sessions_controller.rb",
|
84
|
+
"test/integration/users_controller_test.rb",
|
85
|
+
"test/mock_app/app/controllers/application_controller.rb",
|
86
|
+
"test/mock_app/app/controllers/products_controller.rb",
|
87
|
+
"test/mock_app/app/controllers/sessions_controller_test.rb",
|
88
|
+
"test/mock_app/app/controllers/users_controller.rb",
|
89
|
+
"test/mock_app/app/helpers/application_helper.rb",
|
90
|
+
"test/mock_app/config/application.rb",
|
91
|
+
"test/mock_app/config/boot.rb",
|
92
|
+
"test/mock_app/config/environment.rb",
|
93
|
+
"test/mock_app/config/environments/development.rb",
|
94
|
+
"test/mock_app/config/environments/production.rb",
|
95
|
+
"test/mock_app/config/environments/test.rb",
|
96
|
+
"test/mock_app/config/initializers/backtrace_silencers.rb",
|
97
|
+
"test/mock_app/config/initializers/inflections.rb",
|
98
|
+
"test/mock_app/config/initializers/mime_types.rb",
|
99
|
+
"test/mock_app/config/initializers/route_dog.rb",
|
100
|
+
"test/mock_app/config/initializers/secret_token.rb",
|
101
|
+
"test/mock_app/config/initializers/session_store.rb",
|
102
|
+
"test/mock_app/config/routes.rb",
|
103
|
+
"test/mock_app/db/seeds.rb",
|
104
|
+
"test/support/assertions.rb",
|
105
|
+
"test/test_helper.rb"
|
106
|
+
]
|
107
|
+
|
108
|
+
if s.respond_to? :specification_version then
|
109
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
110
|
+
s.specification_version = 3
|
111
|
+
|
112
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
113
|
+
s.add_runtime_dependency(%q<rack>, [">= 0"])
|
114
|
+
s.add_runtime_dependency(%q<rails>, [">= 2.3.8"])
|
115
|
+
s.add_development_dependency(%q<contest>, ["= 0.1.2"])
|
116
|
+
s.add_development_dependency(%q<nokogiri>, ["= 1.4.3.1"])
|
117
|
+
else
|
118
|
+
s.add_dependency(%q<rack>, [">= 0"])
|
119
|
+
s.add_dependency(%q<rails>, [">= 2.3.8"])
|
120
|
+
s.add_dependency(%q<contest>, ["= 0.1.2"])
|
121
|
+
s.add_dependency(%q<nokogiri>, ["= 1.4.3.1"])
|
122
|
+
end
|
123
|
+
else
|
124
|
+
s.add_dependency(%q<rack>, [">= 0"])
|
125
|
+
s.add_dependency(%q<rails>, [">= 2.3.8"])
|
126
|
+
s.add_dependency(%q<contest>, ["= 0.1.2"])
|
127
|
+
s.add_dependency(%q<nokogiri>, ["= 1.4.3.1"])
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper.rb')
|
2
|
+
|
3
|
+
class ProductsControllerTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@controller = ProductsController.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Notifier Middleware" do
|
10
|
+
test "Show notification of a not tested GET request" do
|
11
|
+
get "/products/new"
|
12
|
+
|
13
|
+
assert_notify_for(:products, :new, :get)
|
14
|
+
end
|
15
|
+
|
16
|
+
test "Show notification of a not tested POST request" do
|
17
|
+
post "/products"
|
18
|
+
|
19
|
+
assert_notify_for(:products, :create, :post)
|
20
|
+
end
|
21
|
+
|
22
|
+
test "Show notification of a not tested DELETE request" do
|
23
|
+
delete "/products/1"
|
24
|
+
|
25
|
+
assert_notify_for(:products, :destroy, :delete)
|
26
|
+
end
|
27
|
+
|
28
|
+
test "Show notification of a not tested PUT request" do
|
29
|
+
put "/products/1"
|
30
|
+
|
31
|
+
assert_notify_for(:products, :update, :put)
|
32
|
+
end
|
33
|
+
|
34
|
+
test "Not show notifications for tested routes" do
|
35
|
+
get "/products"
|
36
|
+
assert_watched_routes_include(:products, :index, :get)
|
37
|
+
get "/products"
|
38
|
+
assert_not_notify_for(:products, :index, :get)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper.rb')
|
2
|
+
|
3
|
+
class SessionsControllerTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@controller = SessionsController.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Watcher Middleware" do
|
10
|
+
test "Identifying routes of actions that respond to more than one method" do
|
11
|
+
get "/sessions/1/logout"
|
12
|
+
delete "/sessions/1/logout"
|
13
|
+
|
14
|
+
assert_watched_routes_include(:sessions, :logout, :delete)
|
15
|
+
assert_watched_routes_include(:sessions, :logout, :delete)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper.rb')
|
2
|
+
|
3
|
+
class UsersControllerTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@controller = UsersController.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Watcher Middleware" do
|
10
|
+
context "Not Tested Routes" do
|
11
|
+
test "users#index" do
|
12
|
+
assert_watched_routes_not_include(:users, :index, :get)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "users#new" do
|
16
|
+
assert_watched_routes_not_include(:users, :new, :get)
|
17
|
+
end
|
18
|
+
|
19
|
+
test "users#create" do
|
20
|
+
assert_watched_routes_not_include(:users, :create, :post)
|
21
|
+
end
|
22
|
+
|
23
|
+
test "users#show" do
|
24
|
+
assert_watched_routes_not_include(:users, :show, :get)
|
25
|
+
end
|
26
|
+
|
27
|
+
test "users#edit" do
|
28
|
+
assert_watched_routes_not_include(:users, :edit, :get)
|
29
|
+
end
|
30
|
+
|
31
|
+
test "users#update" do
|
32
|
+
assert_watched_routes_not_include(:users, :update, :put)
|
33
|
+
end
|
34
|
+
|
35
|
+
test "users#destroy" do
|
36
|
+
assert_watched_routes_not_include(:users, :destroy, :delete)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "Tested Routes" do
|
41
|
+
test "users#index" do
|
42
|
+
get '/users'
|
43
|
+
assert_watched_routes_include(:users, :index, :get)
|
44
|
+
end
|
45
|
+
|
46
|
+
test "users#new" do
|
47
|
+
get '/users/new'
|
48
|
+
assert_watched_routes_include(:users, :new, :get)
|
49
|
+
end
|
50
|
+
|
51
|
+
test "users#create" do
|
52
|
+
post '/users'
|
53
|
+
assert_watched_routes_include(:users, :create, :post)
|
54
|
+
end
|
55
|
+
|
56
|
+
test "users#show" do
|
57
|
+
get '/users/1'
|
58
|
+
assert_watched_routes_include(:users, :show, :get)
|
59
|
+
end
|
60
|
+
|
61
|
+
test "users#edit" do
|
62
|
+
get '/users/1/edit'
|
63
|
+
assert_watched_routes_include(:users, :edit, :get)
|
64
|
+
end
|
65
|
+
|
66
|
+
test "users#update" do
|
67
|
+
put '/users/1'
|
68
|
+
assert_watched_routes_include(:users, :update, :put)
|
69
|
+
end
|
70
|
+
|
71
|
+
test "users#destroy" do
|
72
|
+
delete '/users/1'
|
73
|
+
assert_watched_routes_include(:users, :destroy, :delete)
|
74
|
+
end
|
75
|
+
|
76
|
+
context "Duplicated Routes" do
|
77
|
+
test "routes should not be duplicated in the watched list" do
|
78
|
+
get '/users/1/edit'
|
79
|
+
get '/users/1/edit'
|
80
|
+
assert_watched_routes_include(:users, :destroy, :delete)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.0.1'
|
4
|
+
|
5
|
+
# Bundle edge Rails instead:
|
6
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
+
|
8
|
+
gem 'sqlite3-ruby', :require => 'sqlite3'
|
9
|
+
|
10
|
+
# Use unicorn as the web server
|
11
|
+
# gem 'unicorn'
|
12
|
+
|
13
|
+
# Deploy with Capistrano
|
14
|
+
# gem 'capistrano'
|
15
|
+
|
16
|
+
# To use debugger
|
17
|
+
# gem 'ruby-debug'
|
18
|
+
|
19
|
+
# Bundle the extra gems:
|
20
|
+
# gem 'bj'
|
21
|
+
# gem 'nokogiri'
|
22
|
+
# gem 'sqlite3-ruby', :require => 'sqlite3'
|
23
|
+
# gem 'aws-s3', :require => 'aws/s3'
|
24
|
+
|
25
|
+
# Bundle gems for the local environment. Make sure to
|
26
|
+
# put test-only gems in this group so their generators
|
27
|
+
# and rake tasks are available in development mode:
|
28
|
+
# group :development, :test do
|
29
|
+
# gem 'webrat'
|
30
|
+
# end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.1)
|
6
|
+
actionpack (= 3.0.1)
|
7
|
+
mail (~> 2.2.5)
|
8
|
+
actionpack (3.0.1)
|
9
|
+
activemodel (= 3.0.1)
|
10
|
+
activesupport (= 3.0.1)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4.1)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.12)
|
16
|
+
rack-test (~> 0.5.4)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.1)
|
19
|
+
activesupport (= 3.0.1)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4.1)
|
22
|
+
activerecord (3.0.1)
|
23
|
+
activemodel (= 3.0.1)
|
24
|
+
activesupport (= 3.0.1)
|
25
|
+
arel (~> 1.0.0)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.1)
|
28
|
+
activemodel (= 3.0.1)
|
29
|
+
activesupport (= 3.0.1)
|
30
|
+
activesupport (3.0.1)
|
31
|
+
arel (1.0.1)
|
32
|
+
activesupport (~> 3.0.0)
|
33
|
+
builder (2.1.2)
|
34
|
+
erubis (2.6.6)
|
35
|
+
abstract (>= 1.0.0)
|
36
|
+
i18n (0.4.1)
|
37
|
+
mail (2.2.7)
|
38
|
+
activesupport (>= 2.3.6)
|
39
|
+
mime-types
|
40
|
+
treetop (>= 1.4.5)
|
41
|
+
mime-types (1.16)
|
42
|
+
polyglot (0.3.1)
|
43
|
+
rack (1.2.1)
|
44
|
+
rack-mount (0.6.13)
|
45
|
+
rack (>= 1.0.0)
|
46
|
+
rack-test (0.5.6)
|
47
|
+
rack (>= 1.0)
|
48
|
+
rails (3.0.1)
|
49
|
+
actionmailer (= 3.0.1)
|
50
|
+
actionpack (= 3.0.1)
|
51
|
+
activerecord (= 3.0.1)
|
52
|
+
activeresource (= 3.0.1)
|
53
|
+
activesupport (= 3.0.1)
|
54
|
+
bundler (~> 1.0.0)
|
55
|
+
railties (= 3.0.1)
|
56
|
+
railties (3.0.1)
|
57
|
+
actionpack (= 3.0.1)
|
58
|
+
activesupport (= 3.0.1)
|
59
|
+
rake (>= 0.8.4)
|
60
|
+
thor (~> 0.14.0)
|
61
|
+
rake (0.8.7)
|
62
|
+
sqlite3-ruby (1.3.1)
|
63
|
+
thor (0.14.3)
|
64
|
+
treetop (1.4.8)
|
65
|
+
polyglot (>= 0.3.1)
|
66
|
+
tzinfo (0.3.23)
|
67
|
+
|
68
|
+
PLATFORMS
|
69
|
+
ruby
|
70
|
+
|
71
|
+
DEPENDENCIES
|
72
|
+
rails (= 3.0.1)
|
73
|
+
sqlite3-ruby
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
MockApp::Application.load_tasks
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class ProductsController < ApplicationController
|
2
|
+
def new
|
3
|
+
redirect_to users_path
|
4
|
+
end
|
5
|
+
|
6
|
+
def create
|
7
|
+
redirect_to users_path
|
8
|
+
end
|
9
|
+
|
10
|
+
def index
|
11
|
+
redirect_to users_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def update
|
15
|
+
redirect_to users_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy
|
19
|
+
redirect_to users_path
|
20
|
+
end
|
21
|
+
end
|