Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use Gem::Requirement#satisfied_by? instead of #=~

- The former has been available in rubygems since v0.9.4.4 whereas the
  latter has only been available since v1.8.0.
- This is particularly pernicious, because Object#=~ defaults to
  nil/false and so no suitable versions will be found.
- Fixes #57. Thanks to fguillen for reporting and help in diagnosis.
  • Loading branch information...
commit 566ffc7ffccbdfd871c14cdc5840edeb9043c71d 1 parent faf46fd
James Mead authored
16 lib/mocha/integration/mini_test.rb
@@ -29,20 +29,20 @@ class TestCase
29 29
30 30 $stderr.puts "Detected MiniTest version: #{mini_test_version}" if $options['debug']
31 31
32   - if Gem::Requirement.new('>= 1.3.0', '<= 1.3.1') =~ mini_test_version
  32 + if Gem::Requirement.new('>= 1.3.0', '<= 1.3.1').satisfied_by?(mini_test_version)
33 33 include Mocha::Integration::MiniTest::Version13
34   - elsif Gem::Requirement.new('1.4.0') =~ mini_test_version
  34 + elsif Gem::Requirement.new('1.4.0').satisfied_by?(mini_test_version)
35 35 include Mocha::Integration::MiniTest::Version140
36   - elsif Gem::Requirement.new('1.4.1') =~ mini_test_version
  36 + elsif Gem::Requirement.new('1.4.1').satisfied_by?(mini_test_version)
37 37 include Mocha::Integration::MiniTest::Version141
38   - elsif Gem::Requirement.new('>= 1.4.2', '<= 1.7.2') =~ mini_test_version
  38 + elsif Gem::Requirement.new('>= 1.4.2', '<= 1.7.2').satisfied_by?(mini_test_version)
39 39 include Mocha::Integration::MiniTest::Version142To172
40   - elsif Gem::Requirement.new('2.0.0') =~ mini_test_version
  40 + elsif Gem::Requirement.new('2.0.0').satisfied_by?(mini_test_version)
41 41 include Mocha::Integration::MiniTest::Version200
42   - elsif Gem::Requirement.new('>= 2.0.1', '<= 2.2.2') =~ mini_test_version
  42 + elsif Gem::Requirement.new('>= 2.0.1', '<= 2.2.2').satisfied_by?(mini_test_version)
43 43 include Mocha::Integration::MiniTest::Version201To222
44   - elsif Gem::Requirement.new('>= 2.3.0') =~ mini_test_version
45   - $stderr.puts "*** MiniTest integration has not been verified but patching anyway ***" if (Gem::Requirement.new('> 2.6.2') =~ mini_test_version) && $options['debug']
  44 + elsif Gem::Requirement.new('>= 2.3.0').satisfied_by?(mini_test_version)
  45 + $stderr.puts "*** MiniTest integration has not been verified but patching anyway ***" if (Gem::Requirement.new('> 2.6.2').satisfied_by?(mini_test_version)) && $options['debug']
46 46 include Mocha::Integration::MiniTest::Version230To262
47 47 else
48 48 $stderr.puts "*** No Mocha integration for MiniTest version ***" if $options['debug']
10 lib/mocha/integration/test_unit.rb
@@ -37,14 +37,14 @@ class TestCase
37 37 else
38 38 include Mocha::Integration::TestUnit::RubyVersion186AndAbove
39 39 end
40   - elsif Gem::Requirement.new('2.0.0') =~ test_unit_version
  40 + elsif Gem::Requirement.new('2.0.0').satisfied_by?(test_unit_version)
41 41 include Mocha::Integration::TestUnit::GemVersion200
42   - elsif Gem::Requirement.new('>= 2.0.1', '<= 2.0.2') =~ test_unit_version
  42 + elsif Gem::Requirement.new('>= 2.0.1', '<= 2.0.2').satisfied_by?(test_unit_version)
43 43 include Mocha::Integration::TestUnit::GemVersion201To202
44   - elsif Gem::Requirement.new('>= 2.0.3', '<= 2.2.0') =~ test_unit_version
  44 + elsif Gem::Requirement.new('>= 2.0.3', '<= 2.2.0').satisfied_by?(test_unit_version)
45 45 include Mocha::Integration::TestUnit::GemVersion203To220
46   - elsif Gem::Requirement.new('>= 2.3.0') =~ test_unit_version
47   - $stderr.puts "*** Test::Unit integration has not been verified but patching anyway ***" if (Gem::Requirement.new('> 2.4.0') =~ test_unit_version) && $options['debug']
  46 + elsif Gem::Requirement.new('>= 2.3.0').satisfied_by?(test_unit_version)
  47 + $stderr.puts "*** Test::Unit integration has not been verified but patching anyway ***" if (Gem::Requirement.new('> 2.4.0').satisfied_by?(test_unit_version)) && $options['debug']
48 48 include Mocha::Integration::TestUnit::GemVersion230To240
49 49 else
50 50 $stderr.puts "*** No Mocha integration for Test::Unit version ***" if $options['debug']

0 comments on commit 566ffc7

Please sign in to comment.
Something went wrong with that request. Please try again.