diff --git a/lib/vagrant/guest.rb b/lib/vagrant/guest.rb index 1265e65dc..7883df987 100644 --- a/lib/vagrant/guest.rb +++ b/lib/vagrant/guest.rb @@ -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 diff --git a/test/unit/vagrant/guest_test.rb b/test/unit/vagrant/guest_test.rb index 0a7d76001..ffae22a4f 100644 --- a/test/unit/vagrant/guest_test.rb +++ b/test/unit/vagrant/guest_test.rb @@ -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]