Bundler

When you’re using Bundler to manage your dependencies, there are a few different ways you can ensure that the correct versions of all your libraries get loaded:

  • Call Bundler.require from your Ruby code
  • Wrap every Ruby program with bundle exec at the command line
  • Use Bundler’s stand-alone mode

All of these techniques work with RSpec. Let’s take a look at each one in turn.

The first option, Bundler.require, is convenient: it loads all your project’s gems, so you don’t have to remember to require each gem individually before use. But it has implications for your application’s boot time and maintainability, as Myron points out in his blog post.[123]

The second option, bundle exec, is faster and avoids some of these maintainability pitfalls, ...

Get Effective Testing with RSpec 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.