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 testassumes that you have installed the gem you want to test before you actually try to test it.All the tests would indicate that this is the case – they call
install_stub_gemfirst, which installs a fake gem to run thegem testcommands 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:
Gems that are also runtime dependencies would therefore not fit into this category.