Browse files

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...
1 parent faf46fd commit 566ffc7ffccbdfd871c14cdc5840edeb9043c71d @floehopper committed Jan 20, 2012
Showing with 13 additions and 13 deletions.
  1. +8 −8 lib/mocha/integration/mini_test.rb
  2. +5 −5 lib/mocha/integration/test_unit.rb
View
16 lib/mocha/integration/mini_test.rb
@@ -29,20 +29,20 @@ class TestCase
$stderr.puts "Detected MiniTest version: #{mini_test_version}" if $options['debug']
- if Gem::Requirement.new('>= 1.3.0', '<= 1.3.1') =~ mini_test_version
+ if Gem::Requirement.new('>= 1.3.0', '<= 1.3.1').satisfied_by?(mini_test_version)
include Mocha::Integration::MiniTest::Version13
- elsif Gem::Requirement.new('1.4.0') =~ mini_test_version
+ elsif Gem::Requirement.new('1.4.0').satisfied_by?(mini_test_version)
include Mocha::Integration::MiniTest::Version140
- elsif Gem::Requirement.new('1.4.1') =~ mini_test_version
+ elsif Gem::Requirement.new('1.4.1').satisfied_by?(mini_test_version)
include Mocha::Integration::MiniTest::Version141
- elsif Gem::Requirement.new('>= 1.4.2', '<= 1.7.2') =~ mini_test_version
+ elsif Gem::Requirement.new('>= 1.4.2', '<= 1.7.2').satisfied_by?(mini_test_version)
include Mocha::Integration::MiniTest::Version142To172
- elsif Gem::Requirement.new('2.0.0') =~ mini_test_version
+ elsif Gem::Requirement.new('2.0.0').satisfied_by?(mini_test_version)
include Mocha::Integration::MiniTest::Version200
- elsif Gem::Requirement.new('>= 2.0.1', '<= 2.2.2') =~ mini_test_version
+ elsif Gem::Requirement.new('>= 2.0.1', '<= 2.2.2').satisfied_by?(mini_test_version)
include Mocha::Integration::MiniTest::Version201To222
- elsif Gem::Requirement.new('>= 2.3.0') =~ mini_test_version
- $stderr.puts "*** MiniTest integration has not been verified but patching anyway ***" if (Gem::Requirement.new('> 2.6.2') =~ mini_test_version) && $options['debug']
+ elsif Gem::Requirement.new('>= 2.3.0').satisfied_by?(mini_test_version)
+ $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']
include Mocha::Integration::MiniTest::Version230To262
else
$stderr.puts "*** No Mocha integration for MiniTest version ***" if $options['debug']
View
10 lib/mocha/integration/test_unit.rb
@@ -37,14 +37,14 @@ class TestCase
else
include Mocha::Integration::TestUnit::RubyVersion186AndAbove
end
- elsif Gem::Requirement.new('2.0.0') =~ test_unit_version
+ elsif Gem::Requirement.new('2.0.0').satisfied_by?(test_unit_version)
include Mocha::Integration::TestUnit::GemVersion200
- elsif Gem::Requirement.new('>= 2.0.1', '<= 2.0.2') =~ test_unit_version
+ elsif Gem::Requirement.new('>= 2.0.1', '<= 2.0.2').satisfied_by?(test_unit_version)
include Mocha::Integration::TestUnit::GemVersion201To202
- elsif Gem::Requirement.new('>= 2.0.3', '<= 2.2.0') =~ test_unit_version
+ elsif Gem::Requirement.new('>= 2.0.3', '<= 2.2.0').satisfied_by?(test_unit_version)
include Mocha::Integration::TestUnit::GemVersion203To220
- elsif Gem::Requirement.new('>= 2.3.0') =~ test_unit_version
- $stderr.puts "*** Test::Unit integration has not been verified but patching anyway ***" if (Gem::Requirement.new('> 2.4.0') =~ test_unit_version) && $options['debug']
+ elsif Gem::Requirement.new('>= 2.3.0').satisfied_by?(test_unit_version)
+ $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']
include Mocha::Integration::TestUnit::GemVersion230To240
else
$stderr.puts "*** No Mocha integration for Test::Unit version ***" if $options['debug']

0 comments on commit 566ffc7

Please sign in to comment.