You’re closer than you think to a career in tech. Our grads have launched rewarding new careers — you can too.View Our Jobs Report
This weekend I scoured speakerdeck.com for a presentation related to the topics that we’re beginning to cover in class. I came across the following slide deck from Emily Price titled “Testing Ruby using RSPEC with Factory Girl and Autotest”.
The first two weeks of class we’ve really focused on just getting our programs to work and getting familiar with Ruby. However, late last week we began covering the concept of test-driven development. Emily Price’s slide deck gives a high level overview of the topic.
Testing best practices
The presentation’s author emphasized the following best practices for testing:
write tests first: testing is a continuous process of making your code fail, fixing it so it passes, refactoring, and repeating.
test your edge cases: there are always scenarios in which your code will fail that you may not think of right off the bat. Get creative and try to create tests for those scenarios that might break your code or give you strange results.
test behavior, not implementation: this essentially means that you want to test if the code produces the desired result, not necessarily how it produces it produces the result.
What the heck is RSPEC, Factory Girl, and Autotest anyway?
RSPEC is a testing tool for Ruby, and as with all things Ruby it was designed to “make Test-Driven Development a productive and enjoyable experience.” Factory Girl and Autotest are both gems that work with RSPEC to aid with testing. For example, Autotest is a gem that automatically runs your tests each time you change or save a file. It allows for continuous, quick testing so that you rarely have to open up the browser to see what’s happening to your code.
OK, so I’m not an expert in test-driven development yet. But, as they say, “the beginning of wisdom is to call things by their right names.” Now I know what RSPEC, Factory Girl, and Autotest are and have some best practices to refer to. Thanks Emily for your speakerdeck presentation!
Blog Post Author
Since we opened our doors in 2012, thousands of students have joined Flatiron School to launch new careers in tech.
Find the perfect course for you across our in-person and online programs designed to power your career change.
Connect with students and staff at meetups, lectures, and demos – on campus and online.
Have a question about our programs? Our admissions team is here to help.