我应该如何使用JBuilder视图测试控制器?
这是我的控制器
class NewsController < ApplicationController
def show
@news = News.find_by id: params[:id]
end
end
,这是查看
json.extract! @news ,:id, :title , :content , :created_at , :updated_at
json.image @news.images do |image|
json.url url_for(image)
end
测试该控制器和视图的正确方法。我是新手进行测试,所以我对此有点沮丧
this is my controller
class NewsController < ApplicationController
def show
@news = News.find_by id: params[:id]
end
end
this is views
json.extract! @news ,:id, :title , :content , :created_at , :updated_at
json.image @news.images do |image|
json.url url_for(image)
end
what is right way of testing this controller and views. I'am new into testing so i'am little bit frustrated with this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以验证状态和JSON结果
。 nofollow noreferrer“>此有关更多信息的文章
You can verify the status and the json result you are expecting
Refer this article for more info