【发布时间】:2011-08-04 10:51:15
【问题描述】:
我有 3 个包含相同模块的控制器。
如何使用 Test:Unit 将模块集中在一个地方进行测试?
我应该为每个控制器编写 3 个相同的功能测试(不是 DRY)吗?
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
提前致谢!
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 unit-testing testunit