O'Reilly logo

Effective Testing with RSpec 3 by Myron Marston, Ian Dees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hooking Up the Database

We’ve put off implementing the database layer for as long as we could. But with the rest of the surrounding layers defined, it’s all that’s left.

Getting to Know Sequel

For this exercise, you’re going to use a Ruby database library called Sequel. Sequel allows you to create tables, add data, and so on, without tying your code to any specific database product. You’ll still need to choose a database, though, and for this project the low-maintenance SQLite library will do fine.[40]

Go ahead and add the following two lines to your Gemfile:

 gem ​'sequel'​, ​'4.48.0'
 gem ​'sqlite3'​, ​'1.3.13'

Now, rerun Bundler to install the new libraries:

 $ ​​bundle install
 Fetching ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required