diff options
author | Adam Edwards <adamed@opscode.com> | 2014-04-22 16:26:35 -0700 |
---|---|---|
committer | Adam Edwards <adamed@opscode.com> | 2014-04-22 16:26:35 -0700 |
commit | c045931b3f3ca872df8b4479c0a62d6c45ac472f (patch) | |
tree | fda95b72e75b7f7531001c7b43dad3c922025e17 | |
parent | bd1691730f6d1fbcb5f912155328347983228ef7 (diff) | |
parent | f8b096cfbe86dccb3f1eb443577b4f8fc44df519 (diff) | |
download | chef-c045931b3f3ca872df8b4479c0a62d6c45ac472f.tar.gz |
Merge pull request #1387 from opscode/adamed/CHEF-5211
CHEF-5211: 'knife configure --initial' fails to load 'os' and 'hostname' ohai plugins properly
-rw-r--r-- | lib/chef/knife/configure.rb | 1 | ||||
-rw-r--r-- | spec/functional/knife/configure_spec.rb | 37 | ||||
-rw-r--r-- | spec/unit/knife/configure_spec.rb | 1 |
3 files changed, 39 insertions, 0 deletions
diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb index 6af3d4ea1d..2c77bf101d 100644 --- a/lib/chef/knife/configure.rb +++ b/lib/chef/knife/configure.rb @@ -153,6 +153,7 @@ EOH def guess_servername o = Ohai::System.new + o.load_plugins o.require_plugin 'os' o.require_plugin 'hostname' o[:fqdn] || 'localhost' diff --git a/spec/functional/knife/configure_spec.rb b/spec/functional/knife/configure_spec.rb new file mode 100644 index 0000000000..ac60cb3e00 --- /dev/null +++ b/spec/functional/knife/configure_spec.rb @@ -0,0 +1,37 @@ +# +# Author:: Bryan McLellan <btm@loftninjas.org> +# Copyright:: Copyright (c) 2014 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'spec_helper' + +require 'chef/knife/configure' +require 'ohai' + +describe "knife configure" do + let (:ohai) do + o = Ohai::System.new + o.load_plugins + o.require_plugin 'os' + o.require_plugin 'hostname' + o + end + + it "loads the fqdn from Ohai" do + knife_configure = Chef::Knife::Configure.new + expect(knife_configure.guess_servername).to eql(ohai[:fqdn]) + end +end diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb index eab42fadd5..c16019dcf7 100644 --- a/spec/unit/knife/configure_spec.rb +++ b/spec/unit/knife/configure_spec.rb @@ -28,6 +28,7 @@ describe Chef::Knife::Configure do let(:ohai) do o = {} o.stub(:require_plugin) + o.stub(:load_plugins) o[:fqdn] = fqdn o end |