Skip to content
Test repository containing a simple gem.
C++ Ruby C
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
ext/firstgem
lib
spec
.gitignore
.rspec
Gemfile
README.md
Rakefile
firstgem.gemspec

README.md

First Gem

This repository contains a simple gem with rspec and a native extension.

Installation

Add gem to the Gemfile:

# TODO: test on private repository
gem 'firstgem', source => 'git://github.com/bdwong/firstgem.git'

Then just bundle install and you're good to go!

Troubleshooting

Gems installed from github do not show up on the gem list. You can see the gems with:

bundle list

To make sure things are working properly, you can do this from irb:

require "rubygems"
require "bundler/setup"
require "firstgem"

Some simple tests

a = Shape.new('triangle') # The ruby part of the gem
a.describe
 => "I am a triangle."
b = Calculator.new  # The native extension
b.Add(2+2)
 => 4.0

More troubleshooting tips on the Bundler page

Developers

Clone the source from Github, then build for development:

$ bundle install    # Install prerequisites
$ rake compile      # Compile extensions if present
$ rake spec         # run tests, for example.

For local installation, the recommended way is:

$ rake install      # Build and install the gem

Or you can do it manually with gem:

$ gem build firstgem.gemspec
$ gem install firstgem*.gem

References

Other Possibilities

  • Jeweler is nice but uses shoulda instead of rspec.
  • NewGem doesn't work with rspec 2 but it has some nice features.
Something went wrong with that request. Please try again.