在我的一些控制器中,我有一个没有相应路由的操作,因为它只能通过render ... and return其他控制器操作中的访问。
例如我有一个动作
def no_such_page
# displays a generic error screen
end
Run Code Online (Sandbox Code Playgroud)
在我的 RSpec 控制器测试中,如何“获取”该方法并查看响应主体?
如果我尝试:
get :no_such_page
response.status.should be(200)
Run Code Online (Sandbox Code Playgroud)
它当然给出了错误
No route matches {:controller=>"foo", :action=>"{:action=>:no_such_page}"}
Run Code Online (Sandbox Code Playgroud) 我有一个模板函数,使用if constexpr诸如以下命令检查模板参数的类型
template <typename T>
bool something(T arg) {
if constexpr (std::is_integral_v<T>) {
return true;
} else {
// What can I write here so that something<double>(0.0) does not compile?
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
如果没有if constexprs匹配,如何使代码无法编译?