Declaring dependencies: Runtime vs. Development

RubyGems provides two main types of dependencies: runtime and development.

  1. Runtime dependencies are what your gem needs to work (such as rails needing activesupport).
  2. Development dependencies are useful for when someone wants to make modifications to your gem.

gem install -dev

When you specify development dependencies, another developer can run

gem install --dev your_gem

and RubyGems will grab both sets of dependencies (runtime and development).

Typical development dependencies include test frameworks (like rspec) and build systems (like rake).

gemspec: add_runtime_dependency y add_development_dependency

Setting dependencies in your gemspec is easy.

Just use add_runtime_dependency and add_development_dependency: do |s| = "hola"
  s.version = "2.0.0"
  s.add_runtime_dependency "daemons",
    ["= 1.1.0"]
  s.add_development_dependency "bourne",
    [">= 0"]

gem "wirble", :groups => [:development, :test]

Inside the Gemfile we can also specify groups. Each gem may specify membership in one or more groups. Any gem that does not specify membership in any group is placed in the default group.
   gem "rspec", :group => :test
   gem "wirble", :groups => [:development, :test]

bundle install -without development

then we can run bundle install --without development test to omit some groups.

Casiano Rodriguez León 2015-01-07