【发布时间】:2011-04-28 02:15:36
【问题描述】:
我正在尝试使用 RSpec (2.x) 在控制器中测试渲染方法。 这是我控制器中的代码:
respond_to 做 |格式| format.html # index.html.erb format.json { 渲染 :json => @entities, :include => :properties, :overview => options[:overview] } 结尾这里是我在我的规范文件中尝试的测试:
controller.should_receive(:render).with(hash_include(:overview => true))问题是 RSpec 告诉我没有为渲染提供任何参数(“得到:(无参数)”)。甚至不是 :json 之一。如何正确存根渲染方法?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 rspec rspec2