我正在做一些使用RSpec和Mocha的控制器测试。下面是一个例子变量在Rails控制器测试中传递
describe MenuItemsController, "creating a new menu item" do
integrate_views
fixtures :menu_items
it "should redirect to index with a notice on successful save" do
MenuItem.any_instance.stubs(:valid?).returns(true)
post 'create'
assigns[:menu_item].should_not be_new_record
flash[:notice].should_not be_nil
response.should redirect_to(menu_items_path)
end
end
我有一个关于这个例子
如果是POST方法(和其他REST动词)的文档几个问题吗?
如何对象由
MenuItem.any_instance.stubs创建(?:有效)。返回(真)
获得通过控制器行动?
问题2如何通过post方法直接传递参数给控制器?
伟大的答案。谢谢!! – stellard 2009-11-05 01:38:19