Merge pull request #2189 from phinze/1736-fix-has-plugin-no-method-error

core: fix NoMethodError in Vagrant.has_plugin? [GH-1736]
This commit is contained in:
Fabio Rehm 2013-09-11 15:39:55 -07:00
commit aacea570b6
3 changed files with 20 additions and 1 deletions

View File

@ -7,6 +7,7 @@ IMPROVEMENTS:
BUG FIXES:
- core: Fix NoMethodError in the new `Vagrant.has_plugin?` method [GH-1736]
- hosts/arch: NFS exporting works properly, no exceptions. [GH-2161]
- hosts/fedora: Fix host detection encoding issues. [GH-1977]
- hosts/linux: Fix NFS export problems with `no_subtree_check`. [GH-2156]

View File

@ -133,7 +133,7 @@ module Vagrant
# be used from the Vagrantfile to easily branch based on plugin
# availability.
def self.has_plugin?(name)
plugin("2").registered.include?(name)
plugin("2").manager.registered.any? { |plugin| plugin.name == name }
end
# Returns a superclass to use when creating a plugin for Vagrant.

View File

@ -53,4 +53,22 @@ describe Vagrant do
to raise_error(Vagrant::Errors::PluginLoadFailed)
end
end
describe "has_plugin?" do
after(:each) do
described_class.plugin('2').manager.reset!
end
it "should return true if the plugin is installed" do
plugin = Class.new(described_class.plugin('2')) do
name "i_am_installed"
end
described_class.has_plugin?("i_am_installed").should be_true
end
it "should return false if the plugin is not installed" do
described_class.has_plugin?("i_dont_exist").should be_false
end
end
end