Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Set Up RSpec

DZone's Guide to

How to Set Up RSpec

· DevOps Zone
Free Resource

Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.



Set up RSpec for Ruby applications

For all Ruby applications you can use the rspec gem. The gem is a collection of 3 other gems:

You can also include one or more of these gems separately. For instance, if you want to use Bogus for mocking, like we did in last week’s episode, you can just add rspec-coreand rspec-expectations to your Gemfile, because you don’t need rspec-mocks.

If you run rspec from your project’s root directory without any argument, it will expect your specs to be in the ./spec directory and your classes to be in the ./lib directory. Although you can work around this assumption, I recommend you to stick to them: They are applied in almost all Ruby projects.

Set up RSpec for Rails applications

These rspec gem will work for every Ruby application you create, so you could also use it with your Rails applications. However, there is a more convenient option: The rspec-railsgem is the easiest way of setting up RSpec for Rails. It will provide you with convenient generators that get called when you generate resources like models or controllers. Watch the screencast to see it in action!

Up next: Setting up Cucumber

Next week we’ll set up our Ruby and Rails applications with Cucumber. In the meantime check out our other episodes on RSpec. You can find a list of them below in the “Further info” section.

Further info:

Download the ‘Practical Blueprint to Continuous Delivery’ to learn how Automic Release Automation can help you begin or continue your company’s digital transformation.

Topics:

Published at DZone with permission of Clemens Helm, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}