core: tests for Guest#name

This commit is contained in:
Mitchell Hashimoto 2014-01-09 09:09:40 -08:00
parent 013a9ae779
commit 9fe702a000
2 changed files with 17 additions and 7 deletions

View File

@ -34,6 +34,13 @@ module Vagrant
initialize_capabilities!(guest_name, @guests, @capabilities, @machine) initialize_capabilities!(guest_name, @guests, @capabilities, @machine)
end end
# Returns the specified or detected guest type name.
#
# @return [Symbol]
def name
capability_host_chain[0][0]
end
# This returns whether the guest is ready to work. If this returns # This returns whether the guest is ready to work. If this returns
# `false`, then {#detect!} should be called in order to detect the # `false`, then {#detect!} should be called in order to detect the
# guest OS. # guest OS.
@ -42,12 +49,5 @@ module Vagrant
def ready? def ready?
!!capability_host_chain !!capability_host_chain
end end
# Returns the specified or detected guest type name
#
# @return [Symbol]
def name
capability_host_chain[0][0]
end
end end
end end

View File

@ -36,6 +36,16 @@ describe Vagrant::Guest do
end end
end end
describe "#name" do
it "should be the name of the detected guest" do
guests[:foo] = [detect_class(true), nil]
guests[:bar] = [detect_class(false), nil]
subject.detect!
expect(subject.name).to eql(:foo)
end
end
describe "#ready?" do describe "#ready?" do
before(:each) do before(:each) do
guests[:foo] = [detect_class(true), nil] guests[:foo] = [detect_class(true), nil]