我正在尝试构建一些单元测试来测试我的 Rails 助手,但我永远不记得如何访问它们。恼人的。有什么建议吗?
最佳答案
在 Rails 3 中,您可以这样做(实际上这是生成器创建的内容):
require 'test_helper'
class YourHelperTest < ActionView::TestCase
test "should work" do
assert_equal "result", your_helper_method
end
end
当然还有the rspec variant by Matt Darby也适用于 Rails 3
关于ruby-on-rails - 我如何在 Rails 中测试助手?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/440571/