In this third part of a four-part series on setting up a forum for an online bookstore using Ruby on Rails, we pick up where we left off; we'll also start setting up the sections that allow visitors to view forum posts. This article is excerpted from chapter six of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).
If you followed our instructions, the test should pass without errors.
If you want, you can try a manual test as well. Manual testing is an important complement to automated tests and also makes development more fun, as you can see what you are building. Open http://localhost:3000/forum/post in your browser. Enter your name, the subject, and the body of the post in the form. Figure 6-2 shows our validation at work: an error message appears because we tried to post a message without entering any data into the fields.
Figure 6-2.The create post page showing some validation errors
When you click the Post button, and if the data you entered passes validation, you're redirected to http://localhost:3000/forum . The page displays the message Forum#index , as we have not yet implemented the View Forum user story.
Note Here, we showed you how to implement a test that verifies that a valid post is created successfully. It would be a good idea to also create tests for other scenarios, such as when data fails validation.