KensoDev
KensoDev

Reputation: 3285

Creating a Gem dependent on rails, strategy for publishing/testing

I am in the process of open sourcing a gem I wrote. The gem handles cache more efficiently and you can tag your keys in groups.

The thing is, the in order to test it you really need an application that connects to cache with Rails.cache, meaning the gem is dependent on Rails and you need to have an application to test it out.

What's the strategy in open sourcing a gem like this, should my repository be a complete website and the gemspec point out only the spec and the lib directory?

if you download the lib and spec alone, all of the tests will fail since Rails.cache is not accesible.

I would love suggestions about how to open source this sort of gem and how should my repository should look like.

Thanks

Upvotes: 1

Views: 199

Answers (1)

Jazmin
Jazmin

Reputation: 271

Your repository should only include the files related to the gem itself, a lot of people simply add rails as a development dependency(in the gemspec or Gemfile of your gem).

TIP: To test your gem locally --before releasing the gem-- you can do the following:

  • Package your gem

  • Create a new rails project(if you are using RVM creating a new gemset is recommendable)

  • Include your gem in the Gemfile like this:

    gem 'your_gem' path=>'home/path_to_your_gem/your_gem'
    
  • When you are ready release the gem ;)

I feel that as long as you specify in the README that the gem runs on top of rails you will be fine.

Hope this helps,

Jazmin

Upvotes: 1

Related Questions