Now with full test coverage using MiniTest.

Rubygems link:

Github Link:

A few things I learned here along the way:

MiniTest has not replaced TestUnit for the hard-core Rails developer. MiniTest worked great fro this, except Rails version 4.0.x, 3.1.x and 3.2.x needs “minitest-rails”, “~> 1.0”. I tried testing with Rspec but since Rails itself is tested with Minitest this was actually easier (since I needed access to some special tests written inside of Railtie)

I used a fantastic tool called Appraisal to run my tests suite against several different versions of Rails (3.1, 3.2, 4.0, 4.1, and 4.2). Getting this set up with a little bit of work, but well worth it. You can configure Travis CI to work seamlessly with Appraisal, so you can run your Gem against different versions of Ruby, Rails, and three different databases (SQLite, MySQL, and Postgres). See the .travis.yml and Appraisals inside the gem code for details.

When writing a Gem, you’ll want to explicitly include all your files in the files setting inside the Gemspec (example). This is important, and if you fail to do this those files will work when the Gem is loaded via git: or path: but not when it is pulled from RubyGems.

Rubygems forces you to publish explicit version numbers on your gems. You cannot overwrite an existing version number, but you are allowed to “yank” a version down to remove it from Rubygems.

By Jason

Leave a Reply

Your email address will not be published. Required fields are marked *