I am doing some controller testing with RSpec and Mocha. Here is an example
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
I have a few questions regarding this example
Where is the documentation for the post method (and other REST verbs)?
How does the object created by
MenuItem.any_instance.stubs(:valid?).returns(true)
get passed to the controller action?
How is question 2 differ from directly passing params to the controller via the post method?