简体   繁体   中英

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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM