I'm developing a gem, and my Gemfile looks like this:
source :rubygems
gemspec
group :development, :test do
gem "pry"
gem "debugger"
gem "rake"
end
However, I don't want people to have to install pry and debugger when running tests, but I also want to be able to require them in my tests (because I'm running tests prefixed with bundle exec, and I cannot get it them in my load path if they're not in the Gemfile). How do I achieve this?
Also, when to put gems that I use for development in the gemspec, and when to put them in the Gemfile? I really don't know the difference.
You can add gems to your gemspec as a development dependency, like this:
Gem::Specification.new do |s|
# ...
s.add_development_dependency 'pry'
s.add_development_dependency 'debugger'
s.add_development_dependency 'rake'
end
These will only be installed when working on the gem and not when installing the gem itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With