提交 e5e4d084 编写于 作者: J José Valim

Bring back the helpers tests

Also keep the hook as other tools may rely on it,
we just don't do anything by default on Rails.
上级 d44702ee
......@@ -6,6 +6,8 @@ class HelperGenerator < NamedBase # :nodoc:
def create_helper_files
template 'helper.rb', File.join('app/helpers', class_path, "#{file_name}_helper.rb")
end
hook_for :test_framework
end
end
end
require 'rails/generators/test_unit'
module TestUnit # :nodoc:
module Generators # :nodoc:
class HelperGenerator < Base # :nodoc:
# Rails does not generate anything here.
end
end
end
require 'generators/generators_test_helper'
require 'rails/generators/rails/helper/helper_generator'
ObjectHelper = Class.new
AnotherObjectHelperTest = Class.new
class HelperGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
arguments %w(admin)
def test_helper_skeleton_is_created
run_generator
assert_file "app/helpers/admin_helper.rb", /module AdminHelper/
end
def test_check_class_collision
content = capture(:stderr){ run_generator ["object"] }
assert_match(/The name 'ObjectHelper' is either already used in your application or reserved/, content)
end
def test_namespaced_and_not_namespaced_helpers
run_generator ["products"]
# We have to require the generated helper to show the problem because
# the test helpers just check for generated files and contents but
# do not actually load them. But they have to be loaded (as in a real environment)
# to make the second generator run fail
require "#{destination_root}/app/helpers/products_helper"
assert_nothing_raised do
begin
run_generator ["admin::products"]
ensure
# cleanup
Object.send(:remove_const, :ProductsHelper)
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册