测试 js.erb 测试问题

zhugexinxin · December 27, 2020 · Last by zhugexinxin replied at December 28, 2020 · 392 hits

Controller:

render template: "replies/return_to"

views:

app/views/replies/return_to.js.erb

开发和产品模式跑都是正常通过,但是在写 Controller 测试是报错

错误消息

"#<ActionView::MissingTemplate: Missing template replies/return_to with {:locale=>[:\"zh-CN\"], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}. Searched in:\n  * \"/app/app/views\"\n  * \"/usr/local/bundle/gems/kaminari-core-1.2.1/app/views\"\n  * \"/usr/local/bundle/gems/actiontext-6.1.0/app/views\"\n  * \"/usr/local/bundle/gems/actionmailbox-6.1.0/app/views\"\n>"

好像要请求 js,你这是 html 吧。

测试请求语句加上参数 xhr: true

Reply to pynix

我是请求的响应是 js.erb 里的 js 内容😀

Reply to Rei

3q, 原来是这样,忽然明白了自己哪些方面不理解😀

You need to Sign in before reply, if you don't have an account, please Sign up first.