Using Bundler To Create Gems With Rspec

Posted by mhagedorn on October 31st, 2011 filed in Uncategorized

Suppose you want to start gem development, and you want to use bundler to generate your skeleton gem.  Great!   Now what about the tests?  I wanted to know how to add Rspec to my basic gem and get going.

Here are the steps I used:

bundler gem fooster

Then edit the generated Gemfile (fooster/Gemfile) to add rspec as a dependency

s.adddevelopmentdependency "rspec"

Then create the spec directory to hold your specs

mkdir fooster/rspec

Then create the fooster/spec/spec_helper.rb file

require 'rubygems'

require 'bundler/setup'

require 'fooster' # and any other gems you need

RSpec.configure do |config|
  # some (optional) config here

I use guard to autorun my specs, so make sure that is installed (optional)

gem install guard

gem install rspec-guard

cd fooster

guard init rspec

Then create your first spec


require 'spec_helper'

describe Fooster do
  pending 'write it'

Then execute guard


Leave a Comment

You must be logged in to post a comment.