我需要用 minitest 测试我的控制器。
我试过了:
describe 'CommentsController' do
it "should get index" do
get :index
assert_response :success
end
end
and
class CommentsControllerTest < MiniTest::Unit::TestCase
def test_should_get_index
get :index
assert_response :success
end
end
但我有“未定义的方法‘get’”错误
您应该添加迷你测试轨道 http://blowmage.com/minitest-rails/gem,按照文档中概述的步骤进行操作。那么你的测试应该如下所示:
require "minitest_helper"
describe CommentsController do
it "should get index" do
get :index
assert_response :success
end
end
或者,看起来像这样:
require "minitest_helper"
class CommentsControllerTest < MiniTest::Rails::ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)