1
我想动态地创建一个控制器来测试我的轨道控制器的关注,基于this example。创建一个虚拟控制器的导轨问题不起作用
我的代码看起来像这样
require 'test_helper'
class RequireAuthenticationTest < ActionController::TestCase
test "Throws token required error" do
@controller = RequireAuthenticationTestController.new(:index) { require_authentication; render :nothing => true }
get :index
assert_response :success
end
end
class RequireAuthenticationTestController < ActionController::Base
include RequireAuthentication
def initialize(method_name, &method_body)
self.class.send(:define_method, method_name, method_body)
end
end
每当我试着但是运行的代码,我得到了'
任何意见,错误块我在做什么错呢?谢谢!
你可以发布你的RequireAuthentication代码吗? – 2014-10-08 03:45:03
我不认为这是相关的。问题是控制器路由没有被识别。我的RequireAuthentication代码甚至没有被调用。 – 2014-10-08 03:49:28
嗡嗡声。试图从博客文章运行代码时出现错误。您正在使用哪个版本的Rails和迷你测试? – 2014-10-08 04:01:20