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)
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
# `false`, then {#detect!} should be called in order to detect the
# guest OS.
@ -42,12 +49,5 @@ module Vagrant
def ready?
!!capability_host_chain
end
# Returns the specified or detected guest type name
#
# @return [Symbol]
def name
capability_host_chain[0][0]
end
end
end

View File

@ -36,6 +36,16 @@ describe Vagrant::Guest do
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
before(:each) do
guests[:foo] = [detect_class(true), nil]