How to test a local gem (when no internet available)
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…
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…
I have found 2 options since this post:
- http://blog.sprout-technology.com/2011/07/setting-up-rubygems-proxy-on-local-server/ – a full blown rubygems proxy option. Will look at this with a view to saving on network bandwidth when setting up new projects. Strangely, the link has gone, but also available via Google cache – http://webcache.googleusercontent.com/search?q=cache:iiJdI3t1blAJ:blog.sprout-technology.com/2011/07/setting-up-rubygems-proxy-on-local-server/+blog.sprout-technology.com/2011/07/setting-up-rubygems-proxy-on-local-server/&cd=1&hl=nl&ct=clnk – but must find out why its been removed, some issue, perhaps?
- Use the :path option with bundler to refer to a local gem – http://gembundler.com/ – this seems the best option for testing local gems.