Reputation: 266978
In view pages, people use form tag helpers and link helpers etc.
If I then rename a controller, or a action, my view pages may break.
How can I unit test view related tags for this kind of a breakage?
Upvotes: 0
Views: 169
Reputation: 7014
So the term "unit test" is usually reserved for tests that only test one piece of an application at a time-- you test one view and you test it independently of the associated controller and model.
But as you have found, if you isolate the tests, you can break the interaction between the two and still have all your unit tests passing.
That's why it's important to have tests that exercise your whole application working together. These are sometimes called functional, integration, or acceptance tests (I don't find it very useful to distinguish between these terms but YMMV).
This is usually done using a browser simulator like capybara or webrat so that you are using the application exactly how a user would in the browser. They demand different techniques than unit tests do, so that you don't end up with very brittle tests or tests that take a long time to run without providing additional value for the time spent.
You can use various test frameworks to drive capybara, including RSpec. Many people use RSpec for unit tests and use Cucumber for integration tests. I highly recommend The RSpec Book, which also covers Cucumber and the different methods of testing and when you should use them.
Upvotes: 1