Isaac Sloan - Web Developer, Photographer, Musician and Citizen of Earth
Banner700

How to Create a Ruby Gem

November 10, 2014

1. Create your gem:

Here is the most modern approach to gem crafting:

bundle gem gemname
cd gemname

edit your_gem.gemspec and add description, summary, required gems and optional website. Add required gems for development such as rspec, rails or minitest to the Gemfile.

2. Add testing framework:

RSpec:
rspec --init
touch spec/your_gem_spec.rb
Minitest:
# Rakefile
How to Create a Ruby Gem

Setting up MiniTest for a Rails 4 App

October 03, 2014

Getting started is easy!

Add this code:

Gemfile

gem "minitest-rails", github: "blowmage/minitest-rails"
gem "minitest-reporters"

application.rb

config.generators do |g|
  g.test_framework :minitest, spec: true, fixture: true
  g.helper false
  g.view_specs false
end

$> rails g minitest:install

test_helper.rb

Rails.env = "test"
Setting up MiniTest for a Rails 4 App