【发布时间】:2009-11-04 21:04:26
【问题描述】:
我正在使用 RSpec 和 Mocha 进行一些控制器测试。这是一个例子
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(:valid?).returns(true)
传递给控制器动作?
问题 2 与通过 post 方法直接将参数传递给控制器有何不同?
【问题讨论】:
标签: ruby-on-rails testing rspec mocha.js