Welcome to the Treehouse Community
Looking to learn something new?
Ron Chan10,987 Points
Should you ever ignore Rspec failure messages?
I encountered a problem at 2:25 of this video when rspec threw out a failure message that it was: Unable to find link "New todo Items". Followed the steps up to 3:30 by modifying the code in app view for todo_items/index.html.erb. Upon running rspec again it threw out the same error message as before.
Now I got curious and fired up the rails server. Upon visiting the todo_items page, I saw the link "New todo items" right there at the bottom of the page, contrary to the failure message made by Rspec! And when I click on that link it shows me the message that rspec should have shown me when I completed the changed: that there is a missing template for todo_items/new.
I then followed along the rest of this video and then periodically fire up the server and everything seems to work as intended (i.e. i can create new todo list items within a todo list). I run rspec again at the end and still the failure message hasn't changed.
I feel comfortable enough to git commit and move on to the rest of the videos, but I am really not sure if I should make it a rule to ignore rspec failure messages when the application component works as intended on the server. Is it sufficient to rely on just observing and testing the behaviour of the app on the server?
Any opinions or advice? Should I trust my gut or am I making a biiig mistake? 0_0
Maciej Czuchnowski36,440 Points
Are you sure the link says "New todo Items" when you run the server? And not "New todo item" or "New todo_item"? You know, singular form, underscores, uppercase, lower case - all the details are important.
Brandon Barrette20,485 Points
You shouldn't let the test fail and ignore it. Two things could happen. Either the test is written poorly (it's not testing the right thing that's actually on the page) or the behavior you want to actually happen is not right (there's an error in your actual page your users will see).
The idea behind tests is that you write them so everything is passing before submitting final work. These tests become crucial as you add features to your site. When a new feature is added and it breaks old features, the tests will fail and then you can change your code to match the new intended behavior. Without these tests, bugs become a bigger and bigger problem and it will effect the quality of your site.
Testing is definitely a challenge to learn, but once you get the hang of it, I think you'll appreciate it a lot more. Took me some time to figure out what I should be testing and I learned by making lots of mistakes and writing lots of bugs into my site. Now I test everything and am continually adding more and more tests to look at behavior between features to avoid any bugs.