Why 'bundler gem' adds 'rake' and 'rspec' to Gemfile and not to .gemspec file as a development dependencies?

257 Views Asked by At

I am not well familiar with Ruby world. Java build tools usually use test scope for things like jUnit.

I initialized a new project with command: bundle gem new_gem_from_bundler and the content of Gemfile is

source "https://rubygems.org"

# Specify your gem's dependencies in new_gem_from_bundler.gemspec
gemspec

gem "rake", "~> 12.0"
gem "rspec", "~> 3.0"

Why not:

group :development do
  gem "rspec", "~> 3.9.0"
  gem "rake", "~> 3.0"
end

Also since there is a .gemspec file I would expect rake and rspec to be defined like this:

spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'rspec', '~> 3.0'

Why are they declared as a regular 'gem' dependencies?

1

There are 1 best solutions below

1
builder-7000 On

Bundler uses template files for creating new gems. You could change the template files Gemfile.tt and newgem.gemspec.tt according to your needs. For example you could use this Gemfile.tt:

source "https://rubygems.org"

# Specify your gem's dependencies in <%= config[:name] %>.gemspec
gemspec

To find where the template files are you could use this shell command:

find $(dirname $(gem which -g bundler)) -name Gemfile.tt