Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Adding Todo Items

Ron Chan
Ron Chan
10,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

2 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,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.

Ron Chan
Ron Chan
10,987 Points

omg... you are right. Had singular for the app view and plural for the spec. I feel so silly now. -_-

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

No worries, this happens a lot to everyone :)

Brandon Barrette
Brandon Barrette
20,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.

Ron Chan
Ron Chan
10,987 Points

Thanks for the tip Brandon. I am starting to develop a new found respect (pun?) for the rspec testing tool since it is reliably pointing out where the code has failed as I write it. It does seem to provide more information than simply running the server and testing it as I write bits of code. Missed a non crucial typo in this instance!