1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Controller generators should generate tests when action is supplied. [#3421 state:resolved]

This commit is contained in:
Sam Ruby 2010-03-20 00:51:39 +01:00 committed by José Valim
parent 525382f638
commit 80095c54bd
2 changed files with 11 additions and 0 deletions

View file

@ -3,6 +3,7 @@ require 'generators/test_unit'
module TestUnit
module Generators
class ControllerGenerator < Base
argument :actions, :type => :array, :default => [], :banner => "action action"
check_class_collision :suffix => "ControllerTest"
def create_test_files

View file

@ -1,8 +1,18 @@
require 'test_helper'
class <%= class_name %>ControllerTest < ActionController::TestCase
<% if actions.empty? -%>
# Replace this with your real tests.
test "the truth" do
assert true
end
<% else -%>
<% for action in actions -%>
test "should get <%= action %>" do
get :<%= action %>
assert_response :success
end
<% end -%>
<% end -%>
end