diff options
author | sawanoboly <sawanoboriyu@higanworks.com> | 2020-02-28 21:17:34 +0900 |
---|---|---|
committer | sawanoboly <sawanoboriyu@higanworks.com> | 2020-02-29 02:35:17 +0900 |
commit | 2eb3aff51e7105e2b207cbca515d57d9bf141ed0 (patch) | |
tree | 11689d53b47b0e8f240c5df6da844c1082d8e282 | |
parent | aae49363927449bbe5fbaaf2a7494a4345e37cb8 (diff) | |
download | ohai-2eb3aff51e7105e2b207cbca515d57d9bf141ed0.tar.gz |
use entries to stub. and update spec
Signed-off-by: sawanoboly <sawanoboriyu@higanworks.com>
-rw-r--r-- | lib/ohai/plugins/openstack.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/openstack_spec.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/ohai/plugins/openstack.rb b/lib/ohai/plugins/openstack.rb index 13305e4b..db2a1784 100644 --- a/lib/ohai/plugins/openstack.rb +++ b/lib/ohai/plugins/openstack.rb @@ -51,7 +51,7 @@ Ohai.plugin(:Openstack) do # dream host doesn't support windows so bail early if we're on windows return "openstack" if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - if Etc::Passwd.map(&:name).include?("dhc-user") + if Etc::Passwd.entries.map(&:name).include?("dhc-user") "dreamhost" else "openstack" diff --git a/spec/unit/plugins/openstack_spec.rb b/spec/unit/plugins/openstack_spec.rb index f31ab8f5..67ae76b2 100644 --- a/spec/unit/plugins/openstack_spec.rb +++ b/spec/unit/plugins/openstack_spec.rb @@ -43,7 +43,6 @@ describe Ohai::System, "plugin openstack" do .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout) .and_return(false) plugin[:virtualization] = { systems: { openstack: "guest" } } - expect(Etc).to receive(:getpwnam).and_raise(ArgumentError) plugin.run end @@ -64,7 +63,8 @@ describe Ohai::System, "plugin openstack" do .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout) .and_return(false) plugin[:virtualization] = { systems: { openstack: "guest" } } - expect(Etc).to receive(:getpwnam).and_return(PasswdEntry.new("dhc-user", 800, 800, "/var/www", "/bin/false", "The dreamhost user")) + # expect(Etc).to receive(:getpwnam).and_return(PasswdEntry.new("dhc-user", 800, 800, "/var/www", "/bin/false", "The dreamhost user")) + expect(Etc::Passwd).to receive(:entries).and_return([PasswdEntry.new("dhc-user", 800, 800, "/var/www", "/bin/false", "The dreamhost user")]) plugin.run expect(plugin[:openstack][:provider]).to eq("dreamhost") end |