Skip to content

Instantly share code, notes, and snippets.

@nmk
Created February 17, 2010 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmk/306521 to your computer and use it in GitHub Desktop.
Save nmk/306521 to your computer and use it in GitHub Desktop.
describe CoursesController, "POST /my/courses #create" do
before(:each) do
@valid_course_attributes = { :name => '7C', :subject => 'Philosophie', :school_year => '2010-2011' }.stringify_keys
@new_course = Course.make_unsaved(@valid_course_attributes)
end
def do_post
post :create, :course => @valid_course_attributes
end
it "should build the new course" do
@teacher.courses.should_receive(:build).with(@valid_course_attributes).and_return(@new_course)
@new_course.should_receive(:save).and_return(true)
do_post
end
it "should redirect back to the courses page" do
do_post
response.should redirect_to(my_courses_path)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment