Writing controller tests
We'll want to have some good tests covering all of the code that we will be writing in the course of this application, since we're all good software engineers and should follow good software engineering processes! We'll start off with our controller tests, which include a few cool tools to simulate making connection requests to various controller actions and inspecting the output of the controller functions.
Understanding the code behind tests
When we start off creating our own controllers/views/etc
, if we're not using a generator, we won't have any new logic or functionality to cover tests for the new code we’re writing. Due to this, if we just run mix test without any modifications, we'll see a few passing tests but nothing that actually covers our poll controller. The best place to start is right there, so we'll start off by implementing some tests to cover our dummy data poll response first. We'll create a new file under test/vocial_web/controllers/poll_controller_test...