[英]RSpec 3 - Test controller action that does not have routes
I have a controller and there is an action within that controller.我有一个控制器,并且该控制器中有一个操作。 That action contains only a few lines of code and this method doesn't have any routes, as follows:
该操作仅包含几行代码,该方法没有任何路由,如下所示:
class MyController < ApplicationController
def action_a # an action does have routes
..some code..
end
def action b #(an action without a route, just contains few logic)
..some code..
end
end
My question is what is a proper way to write rspec to test action_b
?我的问题是编写 rspec 来测试
action_b
的正确方法是什么? Any help would be appreciated.任何帮助,将不胜感激。
action_b
should really be a private method. action_b
应该真的是一个私有方法。 Normally, you would not test this directly, you would verify it implicitly by testing action_a
.通常,您不会直接测试它,而是通过测试
action_a
隐式验证它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.