Gem development — troubles and solutions

I would like to take a look at some of problems that I got stuck on during development of Active Explorer gem. I described the gem creation in the last blog post and this blogpost will be more about traps that you might encounter and tips that should help you.

Local Gem Deployment

I needed to test my gem in other project to confirm that it works. To do so you just add the gem to your Gemfile with `path` attribute that point to gem’s local location.

Could not find gem 'active_explorer' in source at `/Users/maxx/Development/Playground/Ruby/active_explorer`. (Bundler::GemNotFound) Source does not contain any versions of 'active_explorer'

The sentence "Source does not contain any versions of 'active_explorer'" suggests that there is no version of the gem, no gem at all. However, what it means is that you didn't specify what version you want. Pretty confusing.

The solution was really simple but it took me some time to figure this out. Just add version:

Appraisal

It helps you to test against different versions of other gems. And that is something that you would likely use when developing your own gem. In my case I needed to test against several Active Record versions (4.x, 5.x).

You just create `Appraisals` file and fill it with gems that should be used in different runs. My `Appraisals` file looks like this: