Skip to content

Instantly share code, notes, and snippets.

@fabriziomachado
Created October 22, 2011 09:59
Show Gist options
  • Save fabriziomachado/1305832 to your computer and use it in GitHub Desktop.
Save fabriziomachado/1305832 to your computer and use it in GitHub Desktop.
nested_forms_test_passing
context "create questions and answers for the exam" do
let(:build_object) { mock().as_null_object }
it "should instantiate at least 3 questions" do
exam_questions = mock("questions for an exam").as_null_object
Exam.any_instance.stub(:questions).and_return(exam_questions)
exam_questions.stub(:build).and_return(build_object)
exam_questions.should_receive(:build).exactly(3).times
get :new
end
it "should instantiate at least 4 answers for each of the 3 questions" do
Question.any_instance.stub(:answers).and_return(build_object)
build_object.should_receive(:build).exactly(12).times
get :new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment