Ruby on rails 3 我的实践是否适合使用rails引擎进行辅助测试?
我写了一个引擎来添加一些辅助方法,只是为了学习Ruby on rails 3 我的实践是否适合使用rails引擎进行辅助测试?,ruby-on-rails-3,unit-testing,Ruby On Rails 3,Unit Testing,我写了一个引擎来添加一些辅助方法,只是为了学习 module SharpAssets class Engine < ::Rails::Engine initializer "sharp_asssets.assets_precompile" do |app| ActionView::Base.send(:include, SharpAssets::Helper) end end module Helper def hi_engine
module SharpAssets
class Engine < ::Rails::Engine
initializer "sharp_asssets.assets_precompile" do |app|
ActionView::Base.send(:include, SharpAssets::Helper)
end
end
module Helper
def hi_engine
"test"
end
end
end
我的测试用例是:
require 'test_helper'
class SharpAssetsTest < ActionView::TestCase
include SharpAssets::Helper
test "should work" do
assert_equal "test", hi_engine
end
end
我想知道这是一种好的做法吗
另一个问题是为什么我可以在测试用例中包括SharpAssets::Helper?我不需要lib文件夹中的任何文件