Over a million developers have joined DZone.

How to Set Up RSpec

· DevOps Zone

The DevOps Zone is brought to you in partnership with Sonatype Nexus. The Nexus Suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today



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:

The DevOps Zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today

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 best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

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

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

{{ parent.tldr }}

{{ parent.urlSource.name }}