For this homework assignment, you will get started with automated testing of the code for your individual project. Continue using the individual app that you have been working on for previous assignments.
At this early stage, there is not too much that you can test, but at a minimum, you should be able to test that the correct page will load when a user clicks on a link or that your dynamic titles are correct. Whatever dynamic content you created for Homework 4 should be tested for this assignment. These tests will be fairly simple and may seem like a lot of work for little result, but once you are working with a large project, automated testing becomes essential.
You are urged to use either Minitest or Rspec as your testing framework. Minitest is the Ruby on Rails default, but RSpec is more of an industry standard. If applicable, you might consider using the framework that has been applied to your team project so that you are only learning one testing framework at a time.
Resources
- Hartl Chapter 3 (especially 3.3 & 3.4) uses Minitest
- Testing Rails applications (Minitest)
- Rails assertions list
- An Introduction to Minitest (Minitest and a little about how Rspec and Minitest differ)
- The Definitive RSpec Tutorial (Rspec)
- Rails Controller Testing Gem (needed if you are testing that instance variables in your controller are assigned)
What to Do
- If you use RSpec to test, you will need to update your Gemfile.
- Your app should already have directories and files set up for testing. You should add necessary code to make these scripts functional and test your app.
- If you are testing the controller (which I did in order to verify that my instance variables were not nil), you may need to add the gem ‘rails-controller-testing’ to your Gemfile (in the testing and development group). Don’t worry about specifying a version in the Gemfile.
- Run your test scripts and fix any code that is broken. (I strongly recommend that you do make sure that your code is broken and that your tests will find it. In other words, make yourself go from red to green on at least one test. )
What to Hand In
- Submit a text document in which you describe the tests that you created and why you chose to test those features. Describe your experience in running these automated tests. Did you find broken code?
- Include a link to your GitHub repo (showing a new commit with “HW5” as part of the commit message).
- In the same document, include the link to the Heroku app.
Scoring Rubric (10 points)
- New or modified testing files in “test” or “spec” folders
- Describes the tests that they created and why they chose to test those features.
- Describes their experience in running these automated tests.
- Says if they found and fixed broken code
- Gemfile updated if using Rspec or testing functionality of a controller.
- Uses Minitest or Rspec (or both …)
- New code uploaded to GitHub
- Functioning on Heroku (or other host)
- Link to the site/app and not the dashboard of Heroku!!
- “Sparkle” …. The site is starting to look like a real site with a purpose and content, even if the content is lorem ipsum at this point.