Permalink
Browse files

Controller generators should generate tests when action is supplied. [#…

…3421 state:resolved]
  • Loading branch information...
1 parent 525382f commit 80095c54bdf134da1aaaca75653e7316bbcbdf70 @rubys rubys committed with josevalim Mar 19, 2010
@@ -3,6 +3,7 @@
module TestUnit
module Generators
class ControllerGenerator < Base
+ argument :actions, :type => :array, :default => [], :banner => "action action"
check_class_collision :suffix => "ControllerTest"
def create_test_files
@@ -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

0 comments on commit 80095c5

Please sign in to comment.