Skip to content

Commit

Permalink
Deprecate support for Ruby versions earlier than v2.0
Browse files Browse the repository at this point in the history
This is long overdue. Extended maintenance of Ruby v1.9.3 ended on 23
Feb 2015 [1]. Actually dropping support will allow significant
simplification of the code.

The immediate motivation is to come up with better parameter matching
for keyword arguments and we've run into parsing issues when trying to
do this in conjunction with continuing to support Ruby v1.9.

Requiring 'mocha/ruby_version' from 'mocha/test_unit', 'mocha/minitest'
and 'mocha/api' is intended to ensure the deprecation warning appears at
the earliest possible time whether the library is being used via
Test::Unit, Minitest or RSpec.

See #325.

[1]: https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/
  • Loading branch information
wasabigeek authored and floehopper committed Sep 21, 2022
1 parent 6a09a37 commit d752f09
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mocha/api.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'mocha/ruby_version'
require 'mocha/parameter_matchers'
require 'mocha/hooks'
require 'mocha/mockery'
Expand Down
1 change: 1 addition & 0 deletions lib/mocha/minitest.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'mocha/ruby_version'
require 'mocha/integration/mini_test'
require 'mocha/deprecation'

Expand Down
8 changes: 8 additions & 0 deletions lib/mocha/ruby_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
require 'mocha/deprecation'

module Mocha
RUBY_V2_PLUS = Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2')

unless RUBY_V2_PLUS
Mocha::Deprecation.warning(
'Versions of Ruby earlier than v2.0 will not be supported in future versions of Mocha.'
)
end
end
1 change: 1 addition & 0 deletions lib/mocha/test_unit.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'mocha/ruby_version'
require 'mocha/integration/test_unit'
require 'mocha/deprecation'

Expand Down

0 comments on commit d752f09

Please sign in to comment.