Sunday, April 6, 2014

Add RSpec

I need to add the rspec gem to my ruby project. How do I do that?  Can I do this from the command line or do I need to open a file? Looks like I need to open my "gemspec" file and add the line:

spec.add_development_dependency "rspec"

Then, I can install the gem through bundler from the command line:

$ bundle install

Next, add a directory structure and spec files.

[project]/spec/spec_helper.rb # Reference code in ../lib
[project]/spec/[gem name]/actual_spec.rb # Relative reference to ../spec_helper.rb

Now you should be able to run rspec from the command line:

$ bundle exec rspec actual_spec.rb

No comments:

Post a Comment