Testing Models With RSpec

Testing models with RSpec is essentially one of its primary uses. After all, you do want to make sure your backend logic is working, and models are where most of that logic should go.

For more information about testing, Everyday Rails Testing With RSpec is a great source for learning more about testing Ruby with RSpec. A lot of the following was built using this as a guide.

Continue reading

Advertisements

BDD and Setting Up RSpec and Testing Suite

(This article assumes a rails app and database have been created and that the developer has an intermediate understanding of Rails).

Behavior-driven development (BDD) takes the position that you can turn an idea for an app or feature into product ready code that’s specific enough for both the developers and clients to understand what’s going on. There is a focus on creating tests that are written in natural language constructs, making it easier to identify what part of the website is not working.  It’s BDD that’s at the heart of using RSpec, which is a software testing tool for Ruby programmers that tests the functionality of an application.

For more on the origins of BDD see here.

The following explains how to install RSpec along with some other testing features that can be used in your Rails app.

Continue reading