如何测试render_remote_content接收正确的本地

时间:2012-02-16 03:26:01

标签: ruby-on-rails rspec2 rspec-rails

在控制器规范中,我试图测试一个调用render_remote_content的控制器动作使用正确的部分呈现正确的部分。

目前,我正在尝试做类似的事情:

response.should render_template(partial: "path/to/_template", locals: {local_array: []})

这导致rspec在assert_template中爆炸。我宁愿避免使用存根渲染方法。

任何人对如何做到这一点有任何好的想法?

Rails 3.1 RSpec 2.7

1 个答案:

答案 0 :(得分:0)

当您检查本地人时,似乎rspec代码中存在错误,您必须删除部分名称中的下划线

具体做法是:

response.should render_template(partial: "path/to/template", locals: {local_array: []})

会起作用,但你的例子不会。

编辑:

这个问题实际上在assert_template中,因为render_template委托给它。此问题正在跟踪此问题:https://github.com/rails/rails/issues/8516