同じモジュールを含む 3 つのコントローラーがあります。
Test:Unit モジュールを 1 か所でテストするにはどうすればよいですか?
各コントローラー (DRY ではない) に対して 3 つの同一の機能テストを作成する必要がありますか?
TestController / TestController1 / TestController2 :
class TestController < ApplicationController
include TestModule
test_module :test, :only => [:index]
...
end
テストモジュール:
module TestModule
extend ActiveSupport::Concern
module ClassMethods
private
def test_module(resource, options = {})
self.before_filter(options.slice(:only, :except)) do
puts 'test_module'
end
end
end
end
前もって感謝します !