简体   繁体   中英

Should gem's development dependencies restate required runtime dependencies?

I can not find any documentation on this. My intuition was that add_development_dependency from a gemspec file should list only additional dependencies that are needed for development and testing and can rely on dependencies specified with add_runtime_dependency to be installed.

I was surprised to discover that gem test command installs only development dependencies, and fails if any runtime dependency is needed during tests.

Is it only gem test quirk or should development dependencies always restate required runtime dependencies, like below:

Gem::Specification.new do |s|
  # ...
  s.add_runtime_dependency 'rack'
  s.add_runtime_dependency 'net-http-persistent'
  s.add_development_dependency 'rack-test'
  s.add_development_dependency 'webmock'
  s.add_development_dependency 'rack'
  s.add_development_dependency 'net-http-persistent'
end

?

I think gem test assumes that you have installed the gem you want to test before you actually try to test it.

gem install whatever
gem test whatever

All the tests would indicate that this is the case - they call install_stub_gem first, which installs a fake gem to run the gem test commands against.

I've never seen a gem duplicate all its runtime dependencies as development dependencies, and the language of the docs suggests that it wouldn't make sense to do so:

development dependencies

Gems that are used for development purposes only . (emphasis mine)

Gems that are also runtime dependencies would therefore not fit into this category.

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