How to test a local gem (when no internet available)

Hi,

I frequently use my laptop on the train with little or no internet connectivity.

Thus, when testing locally developed gems, besides running their own test suites, its good to test them with my/an app that uses the gem.  But I want to do this without pushing the gem onto rubygems/github and then pulling it down again.

These are my notes on how I tried to do it – but I did not get it working…

Firstly, I use RVM and Bundler – so any solution needs to be compatible with that.

From this ascii/rails-cast, it seems there should be a rake task of “rake install” which will install into the current ruby/gem environment.

So, the plan is:

  • to switch to my app’s ruby/gemset
  • rake install my dev gem
  • test the app.

However, even though the gem list showed the new gem version, it was not being used.  Perhaps I need to run bundle update…

~chris

UPDATE:

I have found 2 options since this post:

  • Mig

    Hello,

    I am surprised because I thought one could install a gem that is local. I’ll have a look at the doc.

    Personaly, I just put the lib folder in the LOAD_PATH of the app I want to test. The usual:

    $:.unshift(‘/path/to/lib/of/my/gem’)

    Not as great as installing a local gem but it is just a line of code and it takes precedence to the current installed version, which is what you expect. And at the end of the day, this is what rubygem does.

    Sorry it is a bit late to answer that question, but who knows. Maybe I could help a bit.

    Have a nice day,
    mig

  • kimptoc

    Many Thanks – I didnt know that option either.