Skip to content

Commit

Permalink
Move development dependencies from gemspec to Gemfile
Browse files Browse the repository at this point in the history
Gemspec should not contain `RUBY_VERSION` as a condition to switch dependencies,
because it is meaningless.
Please see the following for details:
- rubocop/rubocop#7137
- rubocop/ruby-style-guide#763

In addition, Bundler no longer uses `add_development_dependency` when genererating new gems.
- rubygems/bundler#7222

For these reason, this PR moves development dependencies from gemspec to Gemfile.
  • Loading branch information
mishina2228 authored and floehopper committed Apr 25, 2022
1 parent 65bc626 commit dd127f7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 38 deletions.
31 changes: 31 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
source 'https://rubygems.org'

gemspec

# rubocop:disable Bundler/DuplicatedGem
if RUBY_VERSION < '1.9.3'
gem 'rake', '~> 10.0'
elsif RUBY_VERSION < '2'
gem 'rake', '~> 12.2.1'
elsif RUBY_VERSION < '2.2'
gem 'rake', '~> 12.3.3'
else
gem 'rake'
end
# rubocop:enable Bundler/DuplicatedGem

gem 'introspection', '~> 0.0.1'

# Avoid breaking change in psych v4 (https://bugs.ruby-lang.org/issues/17866)
if RUBY_VERSION >= '3.1.0'
gem 'psych', '< 4'
end

if RUBY_VERSION >= '2.2.0'
# No test libraries in standard library
gem 'minitest'
end
if RUBY_VERSION >= '2.2.0'
gem 'rubocop', '<= 0.58.2'
end
if ENV['MOCHA_GENERATE_DOCS']
gem 'redcarpet'
gem 'yard'
end
1 change: 1 addition & 0 deletions gemfiles/Gemfile.minitest.latest
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ source 'https://rubygems.org'
gemspec :path=>"../"

group :development do
gem "rake"
gem "minitest"
end
1 change: 1 addition & 0 deletions gemfiles/Gemfile.test-unit.latest
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source 'https://rubygems.org'
gemspec :path=>"../"

group :development do
gem "rake"
if RUBY_VERSION < '1.9'
gem "test-unit", "~> 2"
else
Expand Down
39 changes: 1 addition & 38 deletions mocha.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lib = File.expand_path('../lib/', __FILE__)
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
require 'mocha/version'

Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
Gem::Specification.new do |s|
s.name = 'mocha'
s.version = Mocha::VERSION
s.licenses = ['MIT', 'BSD-2-Clause']
Expand All @@ -21,41 +21,4 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
s.homepage = 'https://mocha.jamesmead.org'
s.require_paths = ['lib']
s.summary = 'Mocking and stubbing library'

unless s.respond_to?(:add_development_dependency)
class << s
def add_development_dependency(*args)
add_dependency(*args)
end
end
end

if RUBY_VERSION < '1.9.3'
s.add_development_dependency 'rake', '~> 10.0'
elsif RUBY_VERSION < '2'
s.add_development_dependency 'rake', '~> 12.2.1'
elsif RUBY_VERSION < '2.2'
s.add_development_dependency 'rake', '~> 12.3.3'
else
s.add_development_dependency 'rake'
end

s.add_development_dependency('introspection', '~> 0.0.1')

# Avoid breaking change in psych v4 (https://bugs.ruby-lang.org/issues/17866)
if RUBY_VERSION >= '3.1.0'
s.add_development_dependency('psych', '< 4')
end

if RUBY_VERSION >= '2.2.0'
# No test libraries in standard library
s.add_development_dependency('minitest')
end
if RUBY_VERSION >= '2.2.0'
s.add_development_dependency('rubocop', '<= 0.58.2')
end
if ENV['MOCHA_GENERATE_DOCS']
s.add_development_dependency('redcarpet')
s.add_development_dependency('yard')
end
end

0 comments on commit dd127f7

Please sign in to comment.