From 2b72335b06c1dd39a3c0d5cff57c1c061cb6fdb5 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Sun, 30 Jun 2013 21:45:39 +0100 Subject: [PATCH] Use newer RubyGems API to look for bundler Closes #448 --- lib/cucumber/rake/task.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/cucumber/rake/task.rb b/lib/cucumber/rake/task.rb index 4866d9ce37..39cfc636cd 100644 --- a/lib/cucumber/rake/task.rb +++ b/lib/cucumber/rake/task.rb @@ -75,19 +75,13 @@ def quoted_binary(cucumber_bin) end def use_bundler - @bundler.nil? ? File.exist?("./Gemfile") && gem_available?("bundler") : @bundler + @bundler.nil? ? File.exist?("./Gemfile") && bundler_gem_available? : @bundler end - def gem_available?(gemname) - gem_available_new_rubygems?(gemname) || gem_available_old_rubygems?(gemname) - end - - def gem_available_old_rubygems?(gemname) - Gem.available?(gemname) - end - - def gem_available_new_rubygems?(gemname) - Gem::Specification.respond_to?(:find_all_by_name) && Gem::Specification.find_all_by_name(gemname).any? + def bundler_gem_available? + Gem::Specification.find_by_name('bundler') + rescue Gem::LoadError + false end def cmd