RSpec 및 Mocha로 컨트롤러 테스트를하고 있습니다. 여기에 내가이 예 포스트 방법 (및 기타 REST 동사)에 대한 설명서입니다변수 통과 레일 테스트 컨트롤러
에 관한 몇 가지 질문이 예
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
입니까?
어떻게 객체가MenuItem.any_instance.stubs 만든 않습니다
- (? : 유효). 반환 (사실은)
질문 2는 post 메서드를 통해 매개 변수를 컨트롤러에 직접 전달하는 것과 어떻게 다릅니 까?
는 컨트롤러 액션에 전달받을?
위대한 답변입니다. 고맙습니다!! – stellard