summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <mcquin@users.noreply.github.com>2014-11-17 12:59:38 -0800
committerClaire McQuin <mcquin@users.noreply.github.com>2014-11-17 12:59:38 -0800
commit495cd710e2f5d0a7131cb415e4a861248bb331ca (patch)
tree0a84ba79c2dde4ce936e7326f0d84ccd23996da8
parentf606ca119c4867d5e19163b0135a6ee7ec6d0eaa (diff)
parent2c9a43c738f1974dd8cb1227c5e89f98ed9dac15 (diff)
downloadohai-495cd710e2f5d0a7131cb415e4a861248bb331ca.tar.gz
Merge pull request #438 from opscode/mcquin/rspec-3
Update to RSpec 3 syntax
-rw-r--r--CHANGELOG.md2
-rw-r--r--spec/functional/plugins/powershell_spec.rb8
-rw-r--r--spec/functional/plugins/root_group_spec.rb2
-rw-r--r--spec/ohai_spec.rb2
-rw-r--r--spec/spec_helper.rb24
-rw-r--r--spec/unit/dsl/plugin_spec.rb80
-rw-r--r--spec/unit/hints_spec.rb6
-rw-r--r--spec/unit/loader_spec.rb32
-rw-r--r--spec/unit/mixin/cloudstack_metadata_spec.rb2
-rw-r--r--spec/unit/mixin/command_spec.rb12
-rw-r--r--spec/unit/mixin/ec2_metadata_spec.rb16
-rw-r--r--spec/unit/plugins/aix/cpu_spec.rb30
-rw-r--r--spec/unit/plugins/aix/filesystem_spec.rb30
-rw-r--r--spec/unit/plugins/aix/hostname_spec.rb6
-rw-r--r--spec/unit/plugins/aix/kernel_spec.rb28
-rw-r--r--spec/unit/plugins/aix/network_spec.rb86
-rw-r--r--spec/unit/plugins/aix/platform_spec.rb10
-rw-r--r--spec/unit/plugins/aix/uptime_spec.rb14
-rw-r--r--spec/unit/plugins/aix/virtualization_spec.rb6
-rw-r--r--spec/unit/plugins/azure_spec.rb36
-rw-r--r--spec/unit/plugins/c_spec.rb104
-rw-r--r--spec/unit/plugins/chef_spec.rb2
-rw-r--r--spec/unit/plugins/cloud_spec.rb62
-rw-r--r--spec/unit/plugins/cloud_v2_spec.rb66
-rw-r--r--spec/unit/plugins/cloudstack_spec.rb12
-rw-r--r--spec/unit/plugins/darwin/cpu_spec.rb38
-rw-r--r--spec/unit/plugins/darwin/hostname_spec.rb12
-rw-r--r--spec/unit/plugins/darwin/kernel_spec.rb28
-rw-r--r--spec/unit/plugins/darwin/memory_spec.rb14
-rw-r--r--spec/unit/plugins/darwin/network_spec.rb716
-rw-r--r--spec/unit/plugins/darwin/platform_spec.rb20
-rw-r--r--spec/unit/plugins/darwin/system_profiler_spec.rb8
-rw-r--r--spec/unit/plugins/dmi_spec.rb6
-rw-r--r--spec/unit/plugins/ec2_spec.rb160
-rw-r--r--spec/unit/plugins/erlang_spec.rb14
-rw-r--r--spec/unit/plugins/eucalyptus_spec.rb56
-rw-r--r--spec/unit/plugins/fail_spec.rb16
-rw-r--r--spec/unit/plugins/freebsd/cpu_spec.rb20
-rw-r--r--spec/unit/plugins/freebsd/hostname_spec.rb8
-rw-r--r--spec/unit/plugins/freebsd/kernel_spec.rb12
-rw-r--r--spec/unit/plugins/freebsd/os_spec.rb6
-rw-r--r--spec/unit/plugins/freebsd/platform_spec.rb10
-rw-r--r--spec/unit/plugins/freebsd/virtualization_spec.rb40
-rw-r--r--spec/unit/plugins/gce_spec.rb36
-rw-r--r--spec/unit/plugins/go_spec.rb10
-rw-r--r--spec/unit/plugins/groovy_spec.rb10
-rw-r--r--spec/unit/plugins/hostname_spec.rb48
-rw-r--r--spec/unit/plugins/init_package_spec.rb10
-rw-r--r--spec/unit/plugins/ip_scopes_spec.rb2
-rw-r--r--spec/unit/plugins/java_spec.rb46
-rw-r--r--spec/unit/plugins/joyent_spec.rb26
-rw-r--r--spec/unit/plugins/kernel_spec.rb40
-rw-r--r--spec/unit/plugins/linode_spec.rb36
-rw-r--r--spec/unit/plugins/linux/cpu_spec.rb50
-rw-r--r--spec/unit/plugins/linux/filesystem_spec.rb121
-rw-r--r--spec/unit/plugins/linux/hostname_spec.rb14
-rw-r--r--spec/unit/plugins/linux/kernel_spec.rb10
-rw-r--r--spec/unit/plugins/linux/lsb_spec.rb46
-rw-r--r--spec/unit/plugins/linux/mdadm_spec.rb22
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb334
-rw-r--r--spec/unit/plugins/linux/uptime_spec.rb12
-rw-r--r--spec/unit/plugins/linux/virtualization_spec.rb312
-rw-r--r--spec/unit/plugins/lua_spec.rb10
-rw-r--r--spec/unit/plugins/mono_spec.rb10
-rw-r--r--spec/unit/plugins/netbsd/hostname_spec.rb12
-rw-r--r--spec/unit/plugins/netbsd/kernel_spec.rb12
-rw-r--r--spec/unit/plugins/netbsd/platform_spec.rb10
-rw-r--r--spec/unit/plugins/network_spec.rb232
-rw-r--r--spec/unit/plugins/nodejs_spec.rb10
-rw-r--r--spec/unit/plugins/ohai_spec.rb2
-rw-r--r--spec/unit/plugins/ohai_time_spec.rb10
-rw-r--r--spec/unit/plugins/openbsd/hostname_spec.rb12
-rw-r--r--spec/unit/plugins/openbsd/kernel_spec.rb12
-rw-r--r--spec/unit/plugins/openbsd/platform_spec.rb8
-rw-r--r--spec/unit/plugins/openstack_spec.rb16
-rw-r--r--spec/unit/plugins/os_spec.rb10
-rw-r--r--spec/unit/plugins/passwd_spec.rb26
-rw-r--r--spec/unit/plugins/perl_spec.rb16
-rw-r--r--spec/unit/plugins/php_spec.rb14
-rw-r--r--spec/unit/plugins/platform_spec.rb18
-rw-r--r--spec/unit/plugins/powershell_spec.rb20
-rw-r--r--spec/unit/plugins/rackspace_spec.rb140
-rw-r--r--spec/unit/plugins/root_group_spec.rb28
-rw-r--r--spec/unit/plugins/ruby_spec.rb2
-rw-r--r--spec/unit/plugins/sigar/network_route_spec.rb34
-rw-r--r--spec/unit/plugins/solaris2/cpu_spec.rb36
-rw-r--r--spec/unit/plugins/solaris2/hostname_spec.rb8
-rw-r--r--spec/unit/plugins/solaris2/kernel_spec.rb16
-rw-r--r--spec/unit/plugins/solaris2/memory_spec.rb6
-rw-r--r--spec/unit/plugins/solaris2/network_spec.rb26
-rw-r--r--spec/unit/plugins/solaris2/platform_spec.rb28
-rw-r--r--spec/unit/plugins/solaris2/virtualization_spec.rb48
-rw-r--r--spec/unit/plugins/solaris2/zpools_spec.rb12
-rw-r--r--spec/unit/plugins/ssh_host_keys_spec.rb36
-rw-r--r--spec/unit/runner_spec.rb52
-rw-r--r--spec/unit/system_spec.rb108
-rw-r--r--spec/unit/util/file_helper_spec.rb4
97 files changed, 2046 insertions, 2045 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2371162..ffcf887c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,7 @@
# Ohai Changelog
## Unreleased:
-
+* Update specs to use RSpec 3 syntax
## Release 7.6.0
diff --git a/spec/functional/plugins/powershell_spec.rb b/spec/functional/plugins/powershell_spec.rb
index ec435923..37d81c62 100644
--- a/spec/functional/plugins/powershell_spec.rb
+++ b/spec/functional/plugins/powershell_spec.rb
@@ -23,10 +23,10 @@ describe Ohai::System, 'languages plugin' do
describe 'powershell plugin', :windows_only do
RSpec.shared_examples "a version looking thing" do
it 'should be present' do
- subject.should_not be_nil
+ expect(subject).not_to be_nil
end
it 'should look like a version' do
- subject.should match(VERSION_MATCHING_REGEX)
+ expect(subject).to match(VERSION_MATCHING_REGEX)
end
end
before(:all) do
@@ -38,7 +38,7 @@ describe Ohai::System, 'languages plugin' do
subject { @plugin[:languages][:powershell] }
it 'should have information about powershell' do
- subject.should_not be_nil
+ expect(subject).not_to be_nil
end
describe :version do
@@ -74,7 +74,7 @@ describe Ohai::System, 'languages plugin' do
describe :compatible_versions do
it 'has compatible_versions that look like versions' do
@plugin.languages[:powershell][described_class].each do |version|
- version.should match(VERSION_MATCHING_REGEX)
+ expect(version).to match(VERSION_MATCHING_REGEX)
end
end
end
diff --git a/spec/functional/plugins/root_group_spec.rb b/spec/functional/plugins/root_group_spec.rb
index c567ba45..936249ec 100644
--- a/spec/functional/plugins/root_group_spec.rb
+++ b/spec/functional/plugins/root_group_spec.rb
@@ -32,7 +32,7 @@ describe Ohai::System, 'root_group plugin' do
# groups in Active Directory -- not a typical test scenario, but
# something to watch if you run this test in such an environment.
groups = wmi.query("select * from Win32_Group where sid = 'S-1-5-32-544'")
- groups.length.should == 1
+ expect(groups.length).to eq(1)
administrators_group = groups[0]['name'].downcase
plugin.run
expect(plugin[:root_group].downcase).to be == administrators_group
diff --git a/spec/ohai_spec.rb b/spec/ohai_spec.rb
index 24c79545..560d43f0 100644
--- a/spec/ohai_spec.rb
+++ b/spec/ohai_spec.rb
@@ -21,7 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
describe Ohai do
it "should have a version constant defined" do
- Ohai::VERSION.should be_a_kind_of(String)
+ expect(Ohai::VERSION).to be_a_kind_of(String)
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 7432e4fb..6fa88491 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -35,34 +35,34 @@ end
def it_should_check_from(plugin, attribute, from, value)
it "should set the #{attribute} to the value from '#{from}'" do
@plugin.run
- @plugin[attribute].should == value
+ expect(@plugin[attribute]).to eq(value)
end
end
def it_should_check_from_mash(plugin, attribute, from, value)
it "should get the #{plugin}[:#{attribute}] value from '#{from}'" do
- @plugin.should_receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
+ expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
@plugin.run
end
it "should set the #{plugin}[:#{attribute}] to the value from '#{from}'" do
@plugin.run
- @plugin[plugin][attribute].should == value[1].split($/)[0]
+ expect(@plugin[plugin][attribute]).to eq(value[1].split($/)[0])
end
end
def mock_shell_out(exitstatus, stdout, stderr)
shell_out = double("mixlib_shell_out")
- shell_out.stub(:exitstatus).and_return(exitstatus)
- shell_out.stub(:stdout).and_return(stdout)
- shell_out.stub(:stderr).and_return(stderr)
+ allow(shell_out).to receive(:exitstatus).and_return(exitstatus)
+ allow(shell_out).to receive(:stdout).and_return(stdout)
+ allow(shell_out).to receive(:stderr).and_return(stderr)
shell_out
end
# the mash variable may be an array listing multiple levels of Mash hierarchy
def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
it "should get the #{mash.inspect}[:#{attribute}] value from '#{from}'" do
- @plugin.should_receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
+ expect(@plugin).to receive(:shell_out).with(from).and_return(mock_shell_out(value[0], value[1], value[2]))
@plugin.run
end
@@ -70,12 +70,12 @@ def it_should_check_from_deep_mash(plugin, mash, attribute, from, value)
@plugin.run
value = value[1].split($/)[0]
if mash.is_a?(String)
- @plugin[mash][attribute].should == value
+ expect(@plugin[mash][attribute]).to eq(value)
elsif mash.is_a?(Array)
if mash.length == 2
- @plugin[mash[0]][mash[1]][attribute].should == value
+ expect(@plugin[mash[0]][mash[1]][attribute]).to eq value
elsif mash.length == 3
- @plugin[mash[0]][mash[1]][mash[2]][attribute].should == value
+ expect(@plugin[mash[0]][mash[1]][mash[2]][attribute]).to eq value
else
return nil
end
@@ -92,10 +92,10 @@ RSpec.configure do |config|
# `expect` should be preferred for new tests or when refactoring old tests,
# but we're not going to do a "big bang" change at this time.
config.expect_with :rspec do |c|
- c.syntax = [:should, :expect]
+ c.syntax = :expect
end
config.mock_with :rspec do |c|
- c.syntax = [:expect, :should]
+ c.syntax = :expect
end
config.filter_run :focus => true
diff --git a/spec/unit/dsl/plugin_spec.rb b/spec/unit/dsl/plugin_spec.rb
index 558d661a..25ca166d 100644
--- a/spec/unit/dsl/plugin_spec.rb
+++ b/spec/unit/dsl/plugin_spec.rb
@@ -22,54 +22,54 @@ require File.expand_path("../../../spec_helper.rb", __FILE__)
shared_examples "Ohai::DSL::Plugin" do
context "#initialize" do
it "should set has_run? to false" do
- plugin.has_run?.should be false
+ expect(plugin.has_run?).to be false
end
it "should set the correct plugin version" do
- plugin.version.should eql(version)
+ expect(plugin.version).to eql(version)
end
end
context "#run" do
before do
- plugin.stub(:run_plugin).and_return(true)
- plugin.stub(:name).and_return(:TestPlugin)
+ allow(plugin).to receive(:run_plugin).and_return(true)
+ allow(plugin).to receive(:name).and_return(:TestPlugin)
end
describe "when plugin is enabled" do
before do
- Ohai::Config.stub(:[]).with(:disabled_plugins).and_return([ ])
+ allow(Ohai::Config).to receive(:[]).with(:disabled_plugins).and_return([ ])
end
it "should run the plugin" do
- plugin.should_receive(:run_plugin)
+ expect(plugin).to receive(:run_plugin)
plugin.run
end
it "should set has_run? to true" do
plugin.run
- plugin.has_run?.should be true
+ expect(plugin.has_run?).to be true
end
end
describe "if the plugin is disabled" do
before do
- Ohai::Config.stub(:[]).with(:disabled_plugins).and_return([ :TestPlugin ])
+ allow(Ohai::Config).to receive(:[]).with(:disabled_plugins).and_return([ :TestPlugin ])
end
it "should not run the plugin" do
- plugin.should_not_receive(:run_plugin)
+ expect(plugin).not_to receive(:run_plugin)
plugin.run
end
it "should log a message to debug" do
- Ohai::Log.should_receive(:debug).with(/Skipping disabled plugin TestPlugin/)
+ expect(Ohai::Log).to receive(:debug).with(/Skipping disabled plugin TestPlugin/)
plugin.run
end
it "should set has_run? to true" do
plugin.run
- plugin.has_run?.should be true
+ expect(plugin.has_run?).to be true
end
end
end
@@ -77,16 +77,16 @@ shared_examples "Ohai::DSL::Plugin" do
context "when accessing data via method_missing" do
it "should take a missing method and store the method name as a key, with its arguments as values" do
plugin.guns_n_roses("chinese democracy")
- plugin.data["guns_n_roses"].should eql("chinese democracy")
+ expect(plugin.data["guns_n_roses"]).to eql("chinese democracy")
end
it "should return the current value of the method name" do
- plugin.guns_n_roses("chinese democracy").should eql("chinese democracy")
+ expect(plugin.guns_n_roses("chinese democracy")).to eql("chinese democracy")
end
it "should allow you to get the value of a key by calling method_missing with no arguments" do
plugin.guns_n_roses("chinese democracy")
- plugin.guns_n_roses.should eql("chinese democracy")
+ expect(plugin.guns_n_roses).to eql("chinese democracy")
end
end
@@ -96,18 +96,18 @@ shared_examples "Ohai::DSL::Plugin" do
end
it "should return true if an attribute exists with the given name" do
- plugin.attribute?("metallica").should eql(true)
+ expect(plugin.attribute?("metallica")).to eql(true)
end
it "should return false if an attribute does not exist with the given name" do
- plugin.attribute?("alice in chains").should eql(false)
+ expect(plugin.attribute?("alice in chains")).to eql(false)
end
end
context "when setting attributes" do
it "should let you set an attribute" do
plugin.set_attribute(:tea, "is soothing")
- plugin.data["tea"].should eql("is soothing")
+ expect(plugin.data["tea"]).to eql("is soothing")
end
end
@@ -117,7 +117,7 @@ shared_examples "Ohai::DSL::Plugin" do
end
it "should let you get an attribute" do
- plugin.get_attribute("tea").should eql("is soothing")
+ expect(plugin.get_attribute("tea")).to eql("is soothing")
end
end
end
@@ -125,7 +125,7 @@ end
describe Ohai::DSL::Plugin::VersionVII do
it "should not modify the plugin name when the plugin is named correctly" do
plugin = Ohai.plugin(:FunkyVALIDpluginName) { }.new({ })
- plugin.name.should eql(:FunkyVALIDpluginName)
+ expect(plugin.name).to eql(:FunkyVALIDpluginName)
end
describe "when the plugin is named incorrectly" do
@@ -151,19 +151,19 @@ describe Ohai::DSL::Plugin::VersionVII do
describe "#version" do
it "should save the plugin version as :version7" do
plugin = Ohai.plugin(:Test) { }
- plugin.version.should eql(:version7)
+ expect(plugin.version).to eql(:version7)
end
end
describe "#provides" do
it "should collect a single attribute" do
plugin = Ohai.plugin(:Test) { provides("one") }
- plugin.provides_attrs.should eql(["one"])
+ expect(plugin.provides_attrs).to eql(["one"])
end
it "should collect a list of attributes" do
plugin = Ohai.plugin(:Test) { provides("one", "two", "three") }
- plugin.provides_attrs.should eql(["one", "two", "three"])
+ expect(plugin.provides_attrs).to eql(["one", "two", "three"])
end
it "should collect from multiple provides statements" do
@@ -172,31 +172,31 @@ describe Ohai::DSL::Plugin::VersionVII do
provides("two", "three")
provides("four")
}
- plugin.provides_attrs.should eql(["one", "two", "three", "four"])
+ expect(plugin.provides_attrs).to eql(["one", "two", "three", "four"])
end
it "should collect attributes across multiple plugin files" do
plugin = Ohai.plugin(:Test) { provides("one") }
plugin = Ohai.plugin(:Test) { provides("two", "three") }
- plugin.provides_attrs.should eql(["one", "two", "three"])
+ expect(plugin.provides_attrs).to eql(["one", "two", "three"])
end
it "should collect unique attributes" do
plugin = Ohai.plugin(:Test) { provides("one") }
plugin = Ohai.plugin(:Test) { provides("one", "two") }
- plugin.provides_attrs.should eql(["one", "two"])
+ expect(plugin.provides_attrs).to eql(["one", "two"])
end
end
describe "#depends" do
it "should collect a single dependency" do
plugin = Ohai.plugin(:Test) { depends("one") }
- plugin.depends_attrs.should eql(["one"])
+ expect(plugin.depends_attrs).to eql(["one"])
end
it "should collect a list of dependencies" do
plugin = Ohai.plugin(:Test) { depends("one", "two", "three") }
- plugin.depends_attrs.should eql(["one", "two", "three"])
+ expect(plugin.depends_attrs).to eql(["one", "two", "three"])
end
it "should collect from multiple depends statements" do
@@ -205,37 +205,37 @@ describe Ohai::DSL::Plugin::VersionVII do
depends("two", "three")
depends("four")
}
- plugin.depends_attrs.should eql(["one", "two", "three", "four"])
+ expect(plugin.depends_attrs).to eql(["one", "two", "three", "four"])
end
it "should collect dependencies across multiple plugin files" do
plugin = Ohai.plugin(:Test) { depends("one") }
plugin = Ohai.plugin(:Test) { depends("two", "three") }
- plugin.depends_attrs.should eql(["one", "two", "three"])
+ expect(plugin.depends_attrs).to eql(["one", "two", "three"])
end
it "should collect unique attributes" do
plugin = Ohai.plugin(:Test) { depends("one") }
plugin = Ohai.plugin(:Test) { depends("one", "two") }
- plugin.depends_attrs.should eql(["one", "two"])
+ expect(plugin.depends_attrs).to eql(["one", "two"])
end
end
describe "#collect_data" do
it "should save as :default if no platform is given" do
plugin = Ohai.plugin(:Test) { collect_data { } }
- plugin.data_collector.should have_key(:default)
+ expect(plugin.data_collector).to have_key(:default)
end
it "should save a single given platform" do
plugin = Ohai.plugin(:Test) { collect_data(:ubuntu) { } }
- plugin.data_collector.should have_key(:ubuntu)
+ expect(plugin.data_collector).to have_key(:ubuntu)
end
it "should save a list of platforms" do
plugin = Ohai.plugin(:Test) { collect_data(:freebsd, :netbsd, :openbsd) { } }
[:freebsd, :netbsd, :openbsd].each do |platform|
- plugin.data_collector.should have_key(platform)
+ expect(plugin.data_collector).to have_key(platform)
end
end
@@ -246,7 +246,7 @@ describe Ohai::DSL::Plugin::VersionVII do
collect_data(:darwin) { }
}
[:darwin, :default, :windows].each do |platform|
- plugin.data_collector.should have_key(platform)
+ expect(plugin.data_collector).to have_key(platform)
end
end
@@ -254,7 +254,7 @@ describe Ohai::DSL::Plugin::VersionVII do
plugin = Ohai.plugin(:Test) { collect_data { } }
plugin = Ohai.plugin(:Test) { collect_data(:aix, :sigar) { } }
[:aix, :default, :sigar].each do |platform|
- plugin.data_collector.should have_key(platform)
+ expect(plugin.data_collector).to have_key(platform)
end
end
@@ -280,7 +280,7 @@ describe Ohai::DSL::Plugin::VersionVII do
describe "#provides (deprecated)" do
it "should log a warning" do
plugin = Ohai::DSL::Plugin::VersionVII.new(Mash.new)
- Ohai::Log.should_receive(:warn).with(/\[UNSUPPORTED OPERATION\]/)
+ expect(Ohai::Log).to receive(:warn).with(/\[UNSUPPORTED OPERATION\]/)
plugin.provides("attribute")
end
end
@@ -288,7 +288,7 @@ describe Ohai::DSL::Plugin::VersionVII do
describe "#require_plugin (deprecated)" do
it "should log a warning" do
plugin = Ohai::DSL::Plugin::VersionVII.new(Mash.new)
- Ohai::Log.should_receive(:warn).with(/\[UNSUPPORTED OPERATION\]/)
+ expect(Ohai::Log).to receive(:warn).with(/\[UNSUPPORTED OPERATION\]/)
plugin.require_plugin("plugin")
end
end
@@ -304,7 +304,7 @@ describe Ohai::DSL::Plugin::VersionVI do
describe "#version" do
it "should save the plugin version as :version6" do
plugin = Class.new(Ohai::DSL::Plugin::VersionVI) { }
- plugin.version.should eql(:version6)
+ expect(plugin.version).to eql(:version6)
end
end
@@ -314,7 +314,7 @@ describe Ohai::DSL::Plugin::VersionVI do
end
it "should log a debug message when provides is used" do
- Ohai::Log.should_receive(:debug).with(/Skipping provides/)
+ expect(Ohai::Log).to receive(:debug).with(/Skipping provides/)
plugin = Ohai::DSL::Plugin::VersionVI.new(@ohai, "/some/plugin/path.rb", "/some/plugin")
plugin.provides("attribute")
end
@@ -322,7 +322,7 @@ describe Ohai::DSL::Plugin::VersionVI do
it "should not update the provides map for version 6 plugins." do
plugin = Ohai::DSL::Plugin::VersionVI.new(@ohai, "/some/plugin/path.rb", "/some/plugin")
plugin.provides("attribute")
- @ohai.provides_map.map.should be_empty
+ expect(@ohai.provides_map.map).to be_empty
end
end
diff --git a/spec/unit/hints_spec.rb b/spec/unit/hints_spec.rb
index 9a2c82c8..5faf0af8 100644
--- a/spec/unit/hints_spec.rb
+++ b/spec/unit/hints_spec.rb
@@ -37,7 +37,7 @@ describe "Ohai::Hints" do
end
it "hint? should return nil" do
- Ohai::Hints.hint?("cloud").should be_nil
+ expect(Ohai::Hints.hint?("cloud")).to be_nil
end
end
@@ -54,11 +54,11 @@ EOF
end
it "hint? should return the data for full hints" do
- Ohai::Hints.hint?("cloud").should == {"name" => "circus"}
+ expect(Ohai::Hints.hint?("cloud")).to eq({"name" => "circus"})
end
it "hint? should return empty hash for empty hints" do
- Ohai::Hints.hint?("cloud_empty").should == { }
+ expect(Ohai::Hints.hint?("cloud_empty")).to eq({ })
end
end
diff --git a/spec/unit/loader_spec.rb b/spec/unit/loader_spec.rb
index 74679056..38d9abf3 100644
--- a/spec/unit/loader_spec.rb
+++ b/spec/unit/loader_spec.rb
@@ -33,7 +33,7 @@ describe Ohai::Loader do
describe "#initialize" do
it "should return an Ohai::Loader object" do
loader = Ohai::Loader.new(@ohai)
- loader.should be_a_kind_of(Ohai::Loader)
+ expect(loader).to be_a_kind_of(Ohai::Loader)
end
end
@@ -61,38 +61,38 @@ EOF
end
it "should save the plugin according to its attribute" do
- @provides_map.map.keys.should include("seals")
+ expect(@provides_map.map.keys).to include("seals")
end
it "should save a single plugin source" do
- @plugin.source.should eql([path_to("zoo.rb")])
+ expect(@plugin.source).to eql([path_to("zoo.rb")])
end
it "should save all plugin sources" do
@loader.load_plugin(path_to("zoo_too.rb"))
- @plugin.source.should eql([path_to("zoo.rb"), path_to("zoo_too.rb")])
+ expect(@plugin.source).to eql([path_to("zoo.rb"), path_to("zoo_too.rb")])
end
end
describe "when loading a v6 plugin" do
before(:each) do
- Ohai::Log.should_receive(:warn).with(/\[DEPRECATION\]/)
+ expect(Ohai::Log).to receive(:warn).with(/\[DEPRECATION\]/)
@plugin = @loader.load_plugin(path_to("lake.rb"), path_to("."))
end
it "should not add this plugin's provided attributes to the provides map" do
- @provides_map.map.should be_empty
+ expect(@provides_map.map).to be_empty
end
it "should save the plugin's source" do
- @plugin.source.should eql(path_to("lake.rb"))
+ expect(@plugin.source).to eql(path_to("lake.rb"))
end
end
it "should log a warning if a plugin doesn't exist" do
- Ohai::Log.should_receive(:warn).with(/Unable to open or read plugin/)
+ expect(Ohai::Log).to receive(:warn).with(/Unable to open or read plugin/)
@loader.load_plugin(path_to("rainier.rb"), path_to("."))
- @provides_map.map.should be_empty
+ expect(@provides_map.map).to be_empty
end
end
end
@@ -147,7 +147,7 @@ EOF
describe "load_plugin() method" do
describe "when the plugin uses Ohai.plugin instead of Ohai.plugins" do
it "should log an unsupported operation warning" do
- Ohai::Log.should_receive(:warn).with(/Plugin Method Error: <#{path_to("extra_s.rb")}>:/)
+ expect(Ohai::Log).to receive(:warn).with(/Plugin Method Error: <#{path_to("extra_s.rb")}>:/)
@loader.load_plugin(path_to("extra_s.rb"))
end
@@ -158,7 +158,7 @@ EOF
describe "when the plugin tries to call an unexisting method" do
it "shoud log an unsupported operation warning" do
- Ohai::Log.should_receive(:warn).with(/Plugin Method Error: <#{path_to("no_method.rb")}>:/)
+ expect(Ohai::Log).to receive(:warn).with(/Plugin Method Error: <#{path_to("no_method.rb")}>:/)
@loader.load_plugin(path_to("no_method.rb"))
end
@@ -169,7 +169,7 @@ EOF
describe "when the plugin defines collect_data on the same platform more than once" do
it "shoud log an illegal plugin definition warning" do
- Ohai::Log.should_receive(:warn).with(/Plugin Definition Error: <#{path_to("illegal_def.rb")}>:/)
+ expect(Ohai::Log).to receive(:warn).with(/Plugin Definition Error: <#{path_to("illegal_def.rb")}>:/)
@loader.load_plugin(path_to("illegal_def.rb"))
end
@@ -180,7 +180,7 @@ EOF
describe "when an unexpected error is encountered" do
it "should log a warning" do
- Ohai::Log.should_receive(:warn).with(/Plugin Error: <#{path_to("unexpected_error.rb")}>:/)
+ expect(Ohai::Log).to receive(:warn).with(/Plugin Error: <#{path_to("unexpected_error.rb")}>:/)
@loader.load_plugin(path_to("unexpected_error.rb"))
end
@@ -191,7 +191,7 @@ EOF
describe "when the plugin name symbol has bad syntax" do
it "should log a syntax error warning" do
- Ohai::Log.should_receive(:warn).with(/Plugin Syntax Error: <#{path_to("bad_symbol.rb")}>:/)
+ expect(Ohai::Log).to receive(:warn).with(/Plugin Syntax Error: <#{path_to("bad_symbol.rb")}>:/)
@loader.load_plugin(path_to("bad_symbol.rb"))
end
@@ -202,7 +202,7 @@ EOF
describe "when the plugin forgets an 'end'" do
it "should log a syntax error warning" do
- Ohai::Log.should_receive(:warn).with(/Plugin Syntax Error: <#{path_to("no_end.rb")}>:/)
+ expect(Ohai::Log).to receive(:warn).with(/Plugin Syntax Error: <#{path_to("no_end.rb")}>:/)
@loader.load_plugin(path_to("no_end.rb"))
end
@@ -213,7 +213,7 @@ EOF
describe "when the plugin has an invalid name" do
it "should log an invalid plugin name warning" do
- Ohai::Log.should_receive(:warn).with(/Plugin Name Error: <#{path_to("bad_name.rb")}>:/)
+ expect(Ohai::Log).to receive(:warn).with(/Plugin Name Error: <#{path_to("bad_name.rb")}>:/)
@loader.load_plugin(path_to("bad_name.rb"))
end
diff --git a/spec/unit/mixin/cloudstack_metadata_spec.rb b/spec/unit/mixin/cloudstack_metadata_spec.rb
index 24634179..693926c5 100644
--- a/spec/unit/mixin/cloudstack_metadata_spec.rb
+++ b/spec/unit/mixin/cloudstack_metadata_spec.rb
@@ -27,7 +27,7 @@ describe Ohai::Mixin::CloudstackMetadata do
context "#best_api_version" do
it "returns the string latest" do
- mixin.best_api_version.should == "latest"
+ expect(mixin.best_api_version).to eq("latest")
end
end
end
diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb
index 26189dfd..7b1bc0dd 100644
--- a/spec/unit/mixin/command_spec.rb
+++ b/spec/unit/mixin/command_spec.rb
@@ -25,14 +25,14 @@ describe Ohai::Mixin::Command, "popen4" do
it "should default all commands to be run in the POSIX standard C locale" do
Ohai::Mixin::Command.popen4("echo $LC_ALL") do |pid, stdin, stdout, stderr|
stdin.close
- stdout.read.strip.should == "C"
+ expect(stdout.read.strip).to eq("C")
end
end
it "should respect locale when specified explicitly" do
Ohai::Mixin::Command.popen4("echo $LC_ALL", :environment => {"LC_ALL" => "es"}) do |pid, stdin, stdout, stderr|
stdin.close
- stdout.read.strip.should == "es"
+ expect(stdout.read.strip).to eq("es")
end
end
@@ -53,14 +53,14 @@ describe Ohai::Mixin::Command, "popen4" do
it "should force encode the string to UTF-8" do
extend Ohai::Mixin::Command
snowy = run_command(:command => ("echo '" + ('☃' * 8096) + "'"))[1]
- snowy.encoding.should == Encoding::UTF_8
+ expect(snowy.encoding).to eq(Encoding::UTF_8)
end
end
it "should force encode the string to UTF-8" do
extend Ohai::Mixin::Command
snowy = run_command(:command => ("echo '" + ('☃' * 8096) + "'"))[1]
- snowy.encoding.should == Encoding::UTF_8
+ expect(snowy.encoding).to eq(Encoding::UTF_8)
end
end
@@ -77,13 +77,13 @@ describe Ohai::Mixin::Command, "popen4" do
created_procs += 1
end
end
- created_procs.should == 100
+ expect(created_procs).to eq(100)
reaped_procs = 0
begin
loop { Process.wait(-1); reaped_procs += 1 }
rescue Errno::ECHILD
end
- reaped_procs.should == 0
+ expect(reaped_procs).to eq(0)
end
end
diff --git a/spec/unit/mixin/ec2_metadata_spec.rb b/spec/unit/mixin/ec2_metadata_spec.rb
index c9543fe3..58527258 100644
--- a/spec/unit/mixin/ec2_metadata_spec.rb
+++ b/spec/unit/mixin/ec2_metadata_spec.rb
@@ -23,8 +23,8 @@ describe Ohai::Mixin::Ec2Metadata do
let(:mixin) {
metadata_object = Object.new.extend(Ohai::Mixin::Ec2Metadata)
http_client = double("Net::HTTP client")
- http_client.stub(:get).and_return(response)
- metadata_object.stub(:http_client).and_return(http_client)
+ allow(http_client).to receive(:get).and_return(response)
+ allow(metadata_object).to receive(:http_client).and_return(http_client)
metadata_object
}
@@ -33,7 +33,7 @@ describe Ohai::Mixin::Ec2Metadata do
let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "200") }
it "returns the most recent version" do
- mixin.best_api_version.should == "2012-01-12"
+ expect(mixin.best_api_version).to eq("2012-01-12")
end
end
@@ -41,7 +41,7 @@ describe Ohai::Mixin::Ec2Metadata do
let(:response) { double("Net::HTTP Response", :body => "1.0\n2009-04-04\n2007-03-01\n2011-05-01\n2008-09-01\nUnsupported", :code => "200") }
it "returns the most recent version (using string sort)" do
- mixin.best_api_version.should == "2011-05-01"
+ expect(mixin.best_api_version).to eq("2011-05-01")
end
end
@@ -49,7 +49,7 @@ describe Ohai::Mixin::Ec2Metadata do
let(:response) { double("Net::HTTP Response", :body => "2020-01-01\nUnsupported", :code => "200") }
it "raises an error" do
- lambda { mixin.best_api_version}.should raise_error
+ expect { mixin.best_api_version}.to raise_error
end
end
@@ -58,7 +58,7 @@ describe Ohai::Mixin::Ec2Metadata do
let(:response) { double("Net::HTTP Response", :code => "404") }
it "returns 'latest' as the version" do
- mixin.best_api_version.should == 'latest'
+ expect(mixin.best_api_version).to eq('latest')
end
end
@@ -66,7 +66,7 @@ describe Ohai::Mixin::Ec2Metadata do
let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "418") }
it "raises an error" do
- lambda { mixin.best_api_version}.should raise_error
+ expect { mixin.best_api_version}.to raise_error
end
end
end
@@ -76,7 +76,7 @@ describe Ohai::Mixin::Ec2Metadata do
let(:response) { double("Net::HTTP Response", :body => "", :code => "418") }
it "raises an error" do
- lambda { mixin.metadata_get('', '2012-01-12') }.should raise_error(RuntimeError)
+ expect { mixin.metadata_get('', '2012-01-12') }.to raise_error(RuntimeError)
end
end
end
diff --git a/spec/unit/plugins/aix/cpu_spec.rb b/spec/unit/plugins/aix/cpu_spec.rb
index 5a58d18d..26ba57ab 100644
--- a/spec/unit/plugins/aix/cpu_spec.rb
+++ b/spec/unit/plugins/aix/cpu_spec.rb
@@ -32,49 +32,49 @@ state enable Processor state False
type PowerPC_POWER5 Processor type False
LSATTR_EL
@plugin = get_plugin("aix/cpu")
- @plugin.stub(:collect_os).and_return(:aix)
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
- @plugin.stub(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_Cc_processor, nil))
- @plugin.stub(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_El_proc0, nil))
+ allow(@plugin).to receive(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_Cc_processor, nil))
+ allow(@plugin).to receive(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_El_proc0, nil))
@plugin.run
end
it "sets the vendor id to IBM" do
- @plugin[:cpu][:vendor_id].should == "IBM"
+ expect(@plugin[:cpu][:vendor_id]).to eq("IBM")
end
it "sets the available attribute" do
- @plugin[:cpu][:available].should == 1
+ expect(@plugin[:cpu][:available]).to eq(1)
end
it "sets the total number of devices" do
- @plugin[:cpu][:total].should == 2
+ expect(@plugin[:cpu][:total]).to eq(2)
end
it "detects the model" do
- @plugin[:cpu][:model].should == "PowerPC_POWER5"
+ expect(@plugin[:cpu][:model]).to eq("PowerPC_POWER5")
end
it "detects the mhz" do
- @plugin[:cpu][:mhz].should == 1615570
+ expect(@plugin[:cpu][:mhz]).to eq(1615570)
end
it "detects the status of the device" do
- @plugin[:cpu][:proc0][:status].should == "Available"
+ expect(@plugin[:cpu][:proc0][:status]).to eq("Available")
end
it "detects the location of the device" do
- @plugin[:cpu][:proc0][:location].should == "00-00"
+ expect(@plugin[:cpu][:proc0][:location]).to eq("00-00")
end
context "lsattr -El device_name" do
it "detects all the attributes of the device" do
- @plugin[:cpu][:proc0][:frequency].should == "1654344000"
- @plugin[:cpu][:proc0][:smt_enabled].should == "true"
- @plugin[:cpu][:proc0][:smt_threads].should == "2"
- @plugin[:cpu][:proc0][:state].should == "enable"
- @plugin[:cpu][:proc0][:type].should == "PowerPC_POWER5"
+ expect(@plugin[:cpu][:proc0][:frequency]).to eq("1654344000")
+ expect(@plugin[:cpu][:proc0][:smt_enabled]).to eq("true")
+ expect(@plugin[:cpu][:proc0][:smt_threads]).to eq("2")
+ expect(@plugin[:cpu][:proc0][:state]).to eq("enable")
+ expect(@plugin[:cpu][:proc0][:type]).to eq("PowerPC_POWER5")
end
end
end
diff --git a/spec/unit/plugins/aix/filesystem_spec.rb b/spec/unit/plugins/aix/filesystem_spec.rb
index c03f2c01..95ca3801 100644
--- a/spec/unit/plugins/aix/filesystem_spec.rb
+++ b/spec/unit/plugins/aix/filesystem_spec.rb
@@ -46,10 +46,10 @@ DF_P
MOUNT
@plugin = get_plugin("aix/filesystem")
- @plugin.stub(:collect_os).and_return(:aix)
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
@plugin[:filesystem] = Mash.new
- @plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, @df_P, nil))
- @plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, @mount, nil))
+ allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @df_P, nil))
+ allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @mount, nil))
@plugin.run
end
@@ -57,56 +57,56 @@ MOUNT
describe "df -P" do
it "returns the filesystem block size" do
- @plugin[:filesystem]["/dev/hd4"]['kb_size'].should == "786432"
+ expect(@plugin[:filesystem]["/dev/hd4"]['kb_size']).to eq("786432")
end
it "returns the filesystem used space in kb" do
- @plugin[:filesystem]["/dev/hd4"]['kb_used'].should == "495632"
+ expect(@plugin[:filesystem]["/dev/hd4"]['kb_used']).to eq("495632")
end
it "returns the filesystem available space in kb" do
- @plugin[:filesystem]["/dev/hd4"]['kb_available'].should == "290800"
+ expect(@plugin[:filesystem]["/dev/hd4"]['kb_available']).to eq("290800")
end
it "returns the filesystem capacity in percentage" do
- @plugin[:filesystem]["/dev/hd4"]['percent_used'].should == "64%"
+ expect(@plugin[:filesystem]["/dev/hd4"]['percent_used']).to eq("64%")
end
it "returns the filesystem mounted location" do
- @plugin[:filesystem]["/dev/hd4"]['mount'].should == "/"
+ expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/")
end
end
describe "mount" do
it "returns the filesystem mount location" do
- @plugin[:filesystem]["/dev/hd4"]['mount'].should == "/"
+ expect(@plugin[:filesystem]["/dev/hd4"]['mount']).to eq("/")
end
it "returns the filesystem type" do
- @plugin[:filesystem]["/dev/hd4"]['fs_type'].should == "jfs2"
+ expect(@plugin[:filesystem]["/dev/hd4"]['fs_type']).to eq("jfs2")
end
it "returns the filesystem mount options" do
- @plugin[:filesystem]["/dev/hd4"]['mount_options'].should == "rw,log=/dev/hd8"
+ expect(@plugin[:filesystem]["/dev/hd4"]['mount_options']).to eq("rw,log=/dev/hd8")
end
# For entries like 192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
context "having node values" do
before do
- @plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, "192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys", nil))
+ allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "192.168.1.11 /stage/middleware /stage/middleware nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys", nil))
end
it "returns the filesystem mount location" do
- @plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount'].should == "/stage/middleware"
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount']).to eq("/stage/middleware")
end
it "returns the filesystem type" do
- @plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type'].should == "nfs3"
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['fs_type']).to eq("nfs3")
end
it "returns the filesystem mount options" do
- @plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options'].should == "ro,bg,hard,intr,sec=sys"
+ expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware"]['mount_options']).to eq("ro,bg,hard,intr,sec=sys")
end
end
end
diff --git a/spec/unit/plugins/aix/hostname_spec.rb b/spec/unit/plugins/aix/hostname_spec.rb
index 4406ce5b..2a92c9c1 100644
--- a/spec/unit/plugins/aix/hostname_spec.rb
+++ b/spec/unit/plugins/aix/hostname_spec.rb
@@ -20,13 +20,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Aix hostname plugin" do
before(:each) do
@plugin = get_plugin("hostname")
- @plugin.stub(:collect_os).and_return(:aix)
- @plugin.stub(:from_cmd).with("hostname").and_return("aix_admin")
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
+ allow(@plugin).to receive(:from_cmd).with("hostname").and_return("aix_admin")
@plugin.run
end
it "should set the machinename" do
- @plugin[:machinename].should eql("aix_admin")
+ expect(@plugin[:machinename]).to eql("aix_admin")
end
end
diff --git a/spec/unit/plugins/aix/kernel_spec.rb b/spec/unit/plugins/aix/kernel_spec.rb
index 6319db9c..2428a25a 100644
--- a/spec/unit/plugins/aix/kernel_spec.rb
+++ b/spec/unit/plugins/aix/kernel_spec.rb
@@ -20,36 +20,36 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "AIX kernel plugin" do
before(:each) do
@plugin = get_plugin("aix/kernel")
- @plugin.stub(:collect_os).and_return(:aix)
- @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil))
- @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "1", nil))
- @plugin.stub(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil))
- @plugin.stub(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil))
- @plugin.stub(:shell_out).with("genkex -d").and_return(mock_shell_out(0, " Text address Size Data address Size File\nf1000000c0338000 77000 f1000000c0390000 1ec8c /usr/lib/drivers/cluster\n 6390000 20000 63a0000 ba8 /usr/lib/drivers/if_en", nil))
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
+ allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "AIX", nil))
+ allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "1", nil))
+ allow(@plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil))
+ allow(@plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil))
+ allow(@plugin).to receive(:shell_out).with("genkex -d").and_return(mock_shell_out(0, " Text address Size Data address Size File\nf1000000c0338000 77000 f1000000c0390000 1ec8c /usr/lib/drivers/cluster\n 6390000 20000 63a0000 ba8 /usr/lib/drivers/if_en", nil))
@plugin.run
end
it "uname -s detects the name" do
- @plugin[:kernel][:name].should == "aix"
+ expect(@plugin[:kernel][:name]).to eq("aix")
end
it "uname -r detects the release" do
- @plugin[:kernel][:release].should == "1"
+ expect(@plugin[:kernel][:release]).to eq("1")
end
it "uname -v detects the version" do
- @plugin[:kernel][:version].should == "6"
+ expect(@plugin[:kernel][:version]).to eq("6")
end
it "uname -p detects the machine" do
- @plugin[:kernel][:machine].should == "powerpc"
+ expect(@plugin[:kernel][:machine]).to eq("powerpc")
end
it "detects the modules" do
- @plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["text"].should == { "address" => "f1000000c0338000", "size" => "77000" }
- @plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["data"].should == { "address" => "f1000000c0390000", "size" => "1ec8c" }
- @plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["text"].should == { "address" => "6390000", "size" => "20000"}
- @plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["data"].should == { "address" => "63a0000", "size" => "ba8"}
+ expect(@plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["text"]).to eq({ "address" => "f1000000c0338000", "size" => "77000" })
+ expect(@plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["data"]).to eq({ "address" => "f1000000c0390000", "size" => "1ec8c" })
+ expect(@plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["text"]).to eq({ "address" => "6390000", "size" => "20000"})
+ expect(@plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["data"]).to eq({ "address" => "63a0000", "size" => "ba8"})
end
end
diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb
index ab4a6ac5..cc87345f 100644
--- a/spec/unit/plugins/aix/network_spec.rb
+++ b/spec/unit/plugins/aix/network_spec.rb
@@ -64,15 +64,15 @@ There are 6 entries in the arp table.
ARP_AN
@plugin = get_plugin("aix/network")
- @plugin.stub(:collect_os).and_return(:aix)
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
@plugin[:network] = Mash.new
- @plugin.stub(:shell_out).with("netstat -rn |grep default").and_return(mock_shell_out(0, @netstat_rn_grep_default, nil))
- @plugin.stub(:shell_out).with("lsdev -Cc if").and_return(mock_shell_out(0, @lsdev_Cc_if, nil))
- @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, @ifconfig_en0, nil))
- @plugin.stub(:shell_out).with("entstat -d en0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, "Hardware Address: be:42:80:00:b0:05", nil))
- @plugin.stub(:shell_out).with("netstat -nrf inet").and_return(mock_shell_out(0, @netstat_nrf_inet, nil))
- @plugin.stub(:shell_out).with("netstat -nrf inet6").and_return(mock_shell_out(0, "::1%1 ::1%1 UH 1 109392 en0 - -", nil))
- @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @aix_arp_an, nil))
+ allow(@plugin).to receive(:shell_out).with("netstat -rn |grep default").and_return(mock_shell_out(0, @netstat_rn_grep_default, nil))
+ allow(@plugin).to receive(:shell_out).with("lsdev -Cc if").and_return(mock_shell_out(0, @lsdev_Cc_if, nil))
+ allow(@plugin).to receive(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, @ifconfig_en0, nil))
+ allow(@plugin).to receive(:shell_out).with("entstat -d en0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, "Hardware Address: be:42:80:00:b0:05", nil))
+ allow(@plugin).to receive(:shell_out).with("netstat -nrf inet").and_return(mock_shell_out(0, @netstat_nrf_inet, nil))
+ allow(@plugin).to receive(:shell_out).with("netstat -nrf inet6").and_return(mock_shell_out(0, "::1%1 ::1%1 UH 1 109392 en0 - -", nil))
+ allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @aix_arp_an, nil))
end
describe "run" do
@@ -81,15 +81,15 @@ ARP_AN
end
it "detects network information" do
- @plugin['network'].should_not be_nil
+ expect(@plugin['network']).not_to be_nil
end
it "detects the interfaces" do
- @plugin['network']['interfaces'].keys.sort.should == ["en0"]
+ expect(@plugin['network']['interfaces'].keys.sort).to eq(["en0"])
end
it "detects the ip addresses of the interfaces" do
- @plugin['network']['interfaces']['en0']['addresses'].keys.should include('172.29.174.58')
+ expect(@plugin['network']['interfaces']['en0']['addresses'].keys).to include('172.29.174.58')
end
end
@@ -99,34 +99,34 @@ ARP_AN
end
it "returns the default gateway of the system's network" do
- @plugin[:network][:default_gateway].should == '172.31.8.1'
+ expect(@plugin[:network][:default_gateway]).to eq('172.31.8.1')
end
it "returns the default interface of the system's network" do
- @plugin[:network][:default_interface].should == 'en0'
+ expect(@plugin[:network][:default_interface]).to eq('en0')
end
end
describe "lsdev -Cc if" do
it "detects the state of the interfaces in the system" do
@plugin.run
- @plugin['network']['interfaces']['en0'][:state].should == "up"
+ expect(@plugin['network']['interfaces']['en0'][:state]).to eq("up")
end
it "detects the description of the interfaces in the system" do
@plugin.run
- @plugin['network']['interfaces']['en0'][:description].should == "Standard Ethernet Network Interface"
+ expect(@plugin['network']['interfaces']['en0'][:description]).to eq("Standard Ethernet Network Interface")
end
describe "ifconfig interface" do
it "detects the CHAIN network flag" do
@plugin.run
- @plugin['network']['interfaces']['en0'][:flags].should include('CHAIN')
+ expect(@plugin['network']['interfaces']['en0'][:flags]).to include('CHAIN')
end
it "detects the metric network flag" do
@plugin.run
- @plugin['network']['interfaces']['en0'][:metric].should == '1'
+ expect(@plugin['network']['interfaces']['en0'][:metric]).to eq('1')
end
context "inet entries" do
@@ -136,54 +136,54 @@ ARP_AN
end
it "detects the family" do
- @inet_entry[:family].should == 'inet'
+ expect(@inet_entry[:family]).to eq('inet')
end
it "detects the netmask" do
- @inet_entry[:netmask].should == '255.255.192.0'
+ expect(@inet_entry[:netmask]).to eq('255.255.192.0')
end
it "detects the broadcast" do
- @inet_entry[:broadcast].should == '172.29.191.255'
+ expect(@inet_entry[:broadcast]).to eq('172.29.191.255')
end
it "detects all key-values" do
- @plugin['network']['interfaces']['en0'][:tcp_sendspace].should == "262144"
- @plugin['network']['interfaces']['en0'][:tcp_recvspace].should == "262144"
- @plugin['network']['interfaces']['en0'][:rfc1323].should == "1"
+ expect(@plugin['network']['interfaces']['en0'][:tcp_sendspace]).to eq("262144")
+ expect(@plugin['network']['interfaces']['en0'][:tcp_recvspace]).to eq("262144")
+ expect(@plugin['network']['interfaces']['en0'][:rfc1323]).to eq("1")
end
# For an output with no netmask like inet 172.29.174.59 broadcast 172.29.191.255
context "with no netmask in the output" do
before do
- @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet 172.29.174.59 broadcast 172.29.191.255", nil))
+ allow(@plugin).to receive(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet 172.29.174.59 broadcast 172.29.191.255", nil))
end
it "detects the default prefixlen" do
@inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["172.29.174.59"]
- @inet_entry[:prefixlen].should == '32'
+ expect(@inet_entry[:prefixlen]).to eq('32')
end
it "detects the default netmask" do
@inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["172.29.174.59"]
- @inet_entry[:netmask].should == '255.255.255.255'
+ expect(@inet_entry[:netmask]).to eq('255.255.255.255')
end
end
end
context "inet6 entries" do
before do
- @plugin.stub(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet6 ::1%1/0", nil))
+ allow(@plugin).to receive(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, "inet6 ::1%1/0", nil))
@plugin.run
@inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["::1"]
end
it "detects the prefixlen" do
- @inet_entry[:prefixlen].should == '0'
+ expect(@inet_entry[:prefixlen]).to eq('0')
end
it "detects the family" do
- @inet_entry[:family].should == 'inet6'
+ expect(@inet_entry[:family]).to eq('inet6')
end
end
end
@@ -194,7 +194,7 @@ ARP_AN
@inet_interface_addresses = @plugin['network']['interfaces']['en0'][:addresses]["BE:42:80:00:B0:05"]
end
it "detects the family" do
- @inet_interface_addresses[:family].should == 'lladdr'
+ expect(@inet_interface_addresses[:family]).to eq('lladdr')
end
end
end
@@ -206,39 +206,39 @@ ARP_AN
context "inet" do
it "detects the route destinations" do
- @plugin['network']['interfaces']['en0'][:routes][0][:destination].should == "default"
- @plugin['network']['interfaces']['en0'][:routes][1][:destination].should == "172.29.128.0"
+ expect(@plugin['network']['interfaces']['en0'][:routes][0][:destination]).to eq("default")
+ expect(@plugin['network']['interfaces']['en0'][:routes][1][:destination]).to eq("172.29.128.0")
end
it "detects the route family" do
- @plugin['network']['interfaces']['en0'][:routes][0][:family].should == "inet"
+ expect(@plugin['network']['interfaces']['en0'][:routes][0][:family]).to eq("inet")
end
it "detects the route gateway" do
- @plugin['network']['interfaces']['en0'][:routes][0][:via].should == "172.29.128.13"
+ expect(@plugin['network']['interfaces']['en0'][:routes][0][:via]).to eq("172.29.128.13")
end
it "detects the route flags" do
- @plugin['network']['interfaces']['en0'][:routes][0][:flags].should == "UG"
+ expect(@plugin['network']['interfaces']['en0'][:routes][0][:flags]).to eq("UG")
end
end
context "inet6" do
it "detects the route destinations" do
- @plugin['network']['interfaces']['en0'][:routes][4][:destination].should == "::1%1"
+ expect(@plugin['network']['interfaces']['en0'][:routes][4][:destination]).to eq("::1%1")
end
it "detects the route family" do
- @plugin['network']['interfaces']['en0'][:routes][4][:family].should == "inet6"
+ expect(@plugin['network']['interfaces']['en0'][:routes][4][:family]).to eq("inet6")
end
it "detects the route gateway" do
- @plugin['network']['interfaces']['en0'][:routes][4][:via].should == "::1%1"
+ expect(@plugin['network']['interfaces']['en0'][:routes][4][:via]).to eq("::1%1")
end
it "detects the route flags" do
- @plugin['network']['interfaces']['en0'][:routes][4][:flags].should == "UH"
+ expect(@plugin['network']['interfaces']['en0'][:routes][4][:flags]).to eq("UH")
end
end
end
@@ -248,15 +248,15 @@ ARP_AN
@plugin.run
end
it "supresses the hostname entries" do
- @plugin['network']['arp'][0][:remote_host].should == "?"
+ expect(@plugin['network']['arp'][0][:remote_host]).to eq("?")
end
it "detects the remote ip entry" do
- @plugin['network']['arp'][0][:remote_ip].should == "172.29.131.16"
+ expect(@plugin['network']['arp'][0][:remote_ip]).to eq("172.29.131.16")
end
it "detects the remote mac entry" do
- @plugin['network']['arp'][0][:remote_mac].should == "6e:87:70:0:40:3"
+ expect(@plugin['network']['arp'][0][:remote_mac]).to eq("6e:87:70:0:40:3")
end
end
@@ -265,7 +265,7 @@ ARP_AN
@plugin.run
end
it "converts a netmask from hexadecimal form to decimal form" do
- @plugin.hex_to_dec_netmask('0xffff0000').should == "255.255.0.0"
+ expect(@plugin.hex_to_dec_netmask('0xffff0000')).to eq("255.255.0.0")
end
end
end
diff --git a/spec/unit/plugins/aix/platform_spec.rb b/spec/unit/plugins/aix/platform_spec.rb
index e2797090..89f6469f 100644
--- a/spec/unit/plugins/aix/platform_spec.rb
+++ b/spec/unit/plugins/aix/platform_spec.rb
@@ -20,24 +20,24 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Aix plugin platform" do
before(:each) do
@plugin = get_plugin("aix/platform")
- @plugin.stub(:collect_os).and_return(:aix)
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
kernel = Mash.new
kernel[:name] = "aix"
kernel[:version] = "1"
kernel[:release] = "0"
- @plugin.stub(:kernel).and_return(kernel)
+ allow(@plugin).to receive(:kernel).and_return(kernel)
@plugin.run
end
it "should set platform to aix" do
- @plugin[:platform].should == "aix"
+ expect(@plugin[:platform]).to eq("aix")
end
it "should set the platform_version" do
- @plugin[:platform_version].should == "1.0"
+ expect(@plugin[:platform_version]).to eq("1.0")
end
it "should set platform_family" do
- @plugin[:platform_family].should == @plugin[:platform]
+ expect(@plugin[:platform_family]).to eq(@plugin[:platform])
end
end
diff --git a/spec/unit/plugins/aix/uptime_spec.rb b/spec/unit/plugins/aix/uptime_spec.rb
index 6d089c8f..986889de 100644
--- a/spec/unit/plugins/aix/uptime_spec.rb
+++ b/spec/unit/plugins/aix/uptime_spec.rb
@@ -21,20 +21,20 @@ describe Ohai::System, "Aix plugin uptime" do
before(:each) do
@plugin = get_plugin("aix/uptime")
- @plugin.stub(:collect_os).and_return(:aix)
- Time.stub_chain(:now, :to_i).and_return(1412072511)
- Time.stub_chain(:now, :zone).and_return("IST")
- DateTime.stub_chain(:parse, :strftime, :to_i).and_return(1411561320)
- @plugin.stub(:shell_out).with("who -b").and_return(mock_shell_out(0, " . system boot Sep 24 17:52", nil))
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
+ allow(Time).to receive_message_chain(:now, :to_i).and_return(1412072511)
+ allow(Time).to receive_message_chain(:now, :zone).and_return("IST")
+ allow(DateTime).to receive_message_chain(:parse, :strftime, :to_i).and_return(1411561320)
+ allow(@plugin).to receive(:shell_out).with("who -b").and_return(mock_shell_out(0, " . system boot Sep 24 17:52", nil))
@plugin.run
end
it "should set uptime_seconds to uptime" do
- @plugin[:uptime_seconds].should == 511191
+ expect(@plugin[:uptime_seconds]).to eq(511191)
end
it "should set uptime to a human readable date" do
- @plugin[:uptime].should == "5 days 21 hours 59 minutes 51 seconds"
+ expect(@plugin[:uptime]).to eq("5 days 21 hours 59 minutes 51 seconds")
end
end
diff --git a/spec/unit/plugins/aix/virtualization_spec.rb b/spec/unit/plugins/aix/virtualization_spec.rb
index 1198e838..2cafabbf 100644
--- a/spec/unit/plugins/aix/virtualization_spec.rb
+++ b/spec/unit/plugins/aix/virtualization_spec.rb
@@ -30,8 +30,8 @@ describe Ohai::System, "AIX virtualization plugin" do
end
it "uname -L detects the LPAR number and name" do
- plugin[:virtualization][:lpar_no].should == "29"
- plugin[:virtualization][:lpar_name].should == "l273pp027"
+ expect(plugin[:virtualization][:lpar_no]).to eq("29")
+ expect(plugin[:virtualization][:lpar_name]).to eq("l273pp027")
end
end
@@ -46,7 +46,7 @@ describe Ohai::System, "AIX virtualization plugin" do
end
it "uname -W detects the WPAR number" do
- plugin[:virtualization][:wpar_no].should == "42"
+ expect(plugin[:virtualization][:wpar_no]).to eq("42")
end
end
diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb
index 375b4204..242e11ab 100644
--- a/spec/unit/plugins/azure_spec.rb
+++ b/spec/unit/plugins/azure_spec.rb
@@ -27,45 +27,45 @@ describe Ohai::System, "plugin azure" do
describe "with azure cloud file" do
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}')
- File.stub(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}')
@plugin.run
end
it 'should set the azure cloud attributes' do
- @plugin[:azure].should_not be_nil
- @plugin[:azure]['public_ip'].should == "137.135.46.202"
- @plugin[:azure]['vm_name'].should == "test-vm"
- @plugin[:azure]['public_fqdn'].should == "service.cloudapp.net"
- @plugin[:azure]['public_ssh_port'].should == "22"
- @plugin[:azure]['public_winrm_port'].should == "5985"
+ expect(@plugin[:azure]).not_to be_nil
+ expect(@plugin[:azure]['public_ip']).to eq("137.135.46.202")
+ expect(@plugin[:azure]['vm_name']).to eq("test-vm")
+ expect(@plugin[:azure]['public_fqdn']).to eq("service.cloudapp.net")
+ expect(@plugin[:azure]['public_ssh_port']).to eq("22")
+ expect(@plugin[:azure]['public_winrm_port']).to eq("5985")
end
end
describe "without azure cloud file" do
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false)
end
it 'should not behave like azure' do
- @plugin[:azure].should be_nil
+ expect(@plugin[:azure]).to be_nil
end
end
describe "with rackspace cloud file" do
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
- File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
end
it 'should not behave like azure' do
- @plugin[:azure].should be_nil
+ expect(@plugin[:azure]).to be_nil
end
end
diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb
index 9668317e..96efd15d 100644
--- a/spec/unit/plugins/c_spec.rb
+++ b/spec/unit/plugins/c_spec.rb
@@ -107,202 +107,202 @@ describe Ohai::System, "plugin c" do
@plugin[:languages] = Mash.new
#gcc
- @plugin.stub(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
+ allow(@plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
#glibc
- @plugin.stub(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
+ allow(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
#ms cl
- @plugin.stub(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
+ allow(@plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
#ms vs
- @plugin.stub(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
+ allow(@plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
#ibm xlc
- @plugin.stub(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
+ allow(@plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
#sun pro
- @plugin.stub(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
+ allow(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
#hpux cc
- @plugin.stub(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
+ allow(@plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
end
#gcc
it "should get the gcc version from running gcc -v" do
- @plugin.should_receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
+ expect(@plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(0, "", C_GCC))
@plugin.run
end
it "should set languages[:c][:gcc][:version]" do
@plugin.run
- @plugin.languages[:c][:gcc][:version].should eql("3.4.6")
+ expect(@plugin.languages[:c][:gcc][:version]).to eql("3.4.6")
end
it "should set languages[:c][:gcc][:description]" do
@plugin.run
- @plugin.languages[:c][:gcc][:description].should eql(C_GCC.split($/).last)
+ expect(@plugin.languages[:c][:gcc][:description]).to eql(C_GCC.split($/).last)
end
it "should not set the languages[:c][:gcc] tree up if gcc command fails" do
- @plugin.stub(:shell_out).with("gcc -v").and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).with("gcc -v").and_return(mock_shell_out(1, "", ""))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:gcc) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:gcc) if @plugin[:languages][:c]
end
#glibc
it "should get the glibc x.x.x version from running /lib/libc.so.6" do
- @plugin.should_receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
+ expect(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_3_4, ""))
@plugin.run
end
it "should set languages[:c][:glibc][:version]" do
@plugin.run
- @plugin.languages[:c][:glibc][:version].should eql("2.3.4")
+ expect(@plugin.languages[:c][:glibc][:version]).to eql("2.3.4")
end
it "should set languages[:c][:glibc][:description]" do
@plugin.run
- @plugin.languages[:c][:glibc][:description].should eql(C_GLIBC_2_3_4.split($/).first)
+ expect(@plugin.languages[:c][:glibc][:description]).to eql(C_GLIBC_2_3_4.split($/).first)
end
it "should not set the languages[:c][:glibc] tree up if glibc command fails" do
- @plugin.stub(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(1, "", ""))
- @plugin.stub(:shell_out).with("/lib64/libc.so.6").and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).with("/lib64/libc.so.6").and_return(mock_shell_out(1, "", ""))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:glibc) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:glibc) if @plugin[:languages][:c]
end
it "should get the glibc x.x version from running /lib/libc.so.6" do
- @plugin.stub(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
- @plugin.should_receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
+ allow(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
+ expect(@plugin).to receive(:shell_out).with("/lib/libc.so.6").and_return(mock_shell_out(0, C_GLIBC_2_5, ""))
@plugin.run
- @plugin.languages[:c][:glibc][:version].should eql("2.5")
+ expect(@plugin.languages[:c][:glibc][:version]).to eql("2.5")
end
#ms cl
it "should get the cl version from running cl /?" do
- @plugin.should_receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
+ expect(@plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(0, "", C_CL))
@plugin.run
end
it "should set languages[:c][:cl][:version]" do
@plugin.run
- @plugin.languages[:c][:cl][:version].should eql("14.00.50727.762")
+ expect(@plugin.languages[:c][:cl][:version]).to eql("14.00.50727.762")
end
it "should set languages[:c][:cl][:description]" do
@plugin.run
- @plugin.languages[:c][:cl][:description].should eql(C_CL.split($/).first)
+ expect(@plugin.languages[:c][:cl][:description]).to eql(C_CL.split($/).first)
end
it "should not set the languages[:c][:cl] tree up if cl command fails" do
- @plugin.stub(:shell_out).with("cl /\?").and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).with("cl /\?").and_return(mock_shell_out(1, "", ""))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:cl) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:cl) if @plugin[:languages][:c]
end
#ms vs
it "should get the vs version from running devenv.com /?" do
- @plugin.should_receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
+ expect(@plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(0, C_VS, ""))
@plugin.run
end
it "should set languages[:c][:vs][:version]" do
@plugin.run
- @plugin.languages[:c][:vs][:version].should eql("8.0.50727.762")
+ expect(@plugin.languages[:c][:vs][:version]).to eql("8.0.50727.762")
end
it "should set languages[:c][:vs][:description]" do
@plugin.run
- @plugin.languages[:c][:vs][:description].should eql(C_VS.split($/)[1])
+ expect(@plugin.languages[:c][:vs][:description]).to eql(C_VS.split($/)[1])
end
it "should not set the languages[:c][:vs] tree up if devenv command fails" do
- @plugin.stub(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).with("devenv.com /\?").and_return(mock_shell_out(1, "", ""))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:vs) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:vs) if @plugin[:languages][:c]
end
#ibm xlc
it "should get the xlc version from running xlc -qversion" do
- @plugin.should_receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
+ expect(@plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC, ""))
@plugin.run
end
it "should set languages[:c][:xlc][:version]" do
@plugin.run
- @plugin.languages[:c][:xlc][:version].should eql("9.0")
+ expect(@plugin.languages[:c][:xlc][:version]).to eql("9.0")
end
it "should set languages[:c][:xlc][:description]" do
@plugin.run
- @plugin.languages[:c][:xlc][:description].should eql(C_XLC.split($/).first)
+ expect(@plugin.languages[:c][:xlc][:description]).to eql(C_XLC.split($/).first)
end
it "should not set the languages[:c][:xlc] tree up if xlc command fails" do
- @plugin.stub(:shell_out).with("xlc -qversion").and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(1, "", ""))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:xlc) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:xlc) if @plugin[:languages][:c]
end
it "should set the languages[:c][:xlc] tree up if xlc exit status is 249" do
- @plugin.stub(:shell_out).with("xlc -qversion").and_return(mock_shell_out(63744, "", ""))
+ allow(@plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(63744, "", ""))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:xlc) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:xlc) if @plugin[:languages][:c]
end
#sun pro
it "should get the cc version from running cc -V -flags" do
- @plugin.should_receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
+ expect(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", C_SUN))
@plugin.run
end
it "should set languages[:c][:sunpro][:version]" do
@plugin.run
- @plugin.languages[:c][:sunpro][:version].should eql("5.8")
+ expect(@plugin.languages[:c][:sunpro][:version]).to eql("5.8")
end
it "should set languages[:c][:sunpro][:description]" do
@plugin.run
- @plugin.languages[:c][:sunpro][:description].should eql(C_SUN.chomp)
+ expect(@plugin.languages[:c][:sunpro][:description]).to eql(C_SUN.chomp)
end
it "should not set the languages[:c][:sunpro] tree up if cc command fails" do
- @plugin.stub(:shell_out).with("cc -V -flags").and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(1, "", ""))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:sunpro) if @plugin[:languages][:c]
end
it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on linux" do
fedora_error_message = "cc: error trying to exec 'i686-redhat-linux-gcc--flags': execvp: No such file or directory"
- @plugin.stub(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", fedora_error_message))
+ allow(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", fedora_error_message))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:sunpro) if @plugin[:languages][:c]
end
it "should not set the languages[:c][:sunpro] tree if the corresponding cc command fails on hpux" do
hpux_error_message = "cc: warning 901: unknown option: `-flags': use +help for online documentation.\ncc: HP C/aC++ B3910B A.06.25 [Nov 30 2009]"
- @plugin.stub(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", hpux_error_message))
+ allow(@plugin).to receive(:shell_out).with("cc -V -flags").and_return(mock_shell_out(0, "", hpux_error_message))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:sunpro) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:sunpro) if @plugin[:languages][:c]
end
#hpux cc
it "should get the cc version from running what cc" do
- @plugin.should_receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
+ expect(@plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(0, C_HPUX, ""))
@plugin.run
end
it "should set languages[:c][:hpcc][:version]" do
@plugin.run
- @plugin.languages[:c][:hpcc][:version].should eql("B.11.11.16")
+ expect(@plugin.languages[:c][:hpcc][:version]).to eql("B.11.11.16")
end
it "should set languages[:c][:hpcc][:description]" do
@plugin.run
- @plugin.languages[:c][:hpcc][:description].should eql(C_HPUX.split($/)[3].strip)
+ expect(@plugin.languages[:c][:hpcc][:description]).to eql(C_HPUX.split($/)[3].strip)
end
it "should not set the languages[:c][:hpcc] tree up if cc command fails" do
- @plugin.stub(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).with("what /opt/ansic/bin/cc").and_return(mock_shell_out(1, "", ""))
@plugin.run
- @plugin[:languages][:c].should_not have_key(:hpcc) if @plugin[:languages][:c]
+ expect(@plugin[:languages][:c]).not_to have_key(:hpcc) if @plugin[:languages][:c]
end
end
diff --git a/spec/unit/plugins/chef_spec.rb b/spec/unit/plugins/chef_spec.rb
index e12b202b..0ca0ff20 100644
--- a/spec/unit/plugins/chef_spec.rb
+++ b/spec/unit/plugins/chef_spec.rb
@@ -30,7 +30,7 @@ begin
it "should set [:chef_packages][:chef][:version] to the current chef version", :if => defined?(Chef) do
@plugin.run
- @plugin[:chef_packages][:chef][:version].should == Chef::VERSION
+ expect(@plugin[:chef_packages][:chef][:version]).to eq(Chef::VERSION)
end
pending "would set [:chef_packages][:chef][:version] if chef was available", :unless => defined?(Chef)
diff --git a/spec/unit/plugins/cloud_spec.rb b/spec/unit/plugins/cloud_spec.rb
index 828ee169..7e6a4f92 100644
--- a/spec/unit/plugins/cloud_spec.rb
+++ b/spec/unit/plugins/cloud_spec.rb
@@ -31,7 +31,7 @@ describe Ohai::System, "plugin cloud" do
@plugin[:azure] = nil
@plugin[:cloudstack] = nil
@plugin.run
- @plugin[:cloud].should be_nil
+ expect(@plugin[:cloud]).to be_nil
end
end
@@ -43,18 +43,18 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:ec2]['public_ipv4'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:public_ips][0].should == @plugin[:ec2]['public_ipv4']
+ expect(@plugin[:cloud][:public_ips][0]).to eq(@plugin[:ec2]['public_ipv4'])
end
it "populates cloud private ip" do
@plugin[:ec2]['local_ipv4'] = "10.252.42.149"
@plugin.run
- @plugin[:cloud][:private_ips][0].should == @plugin[:ec2]['local_ipv4']
+ expect(@plugin[:cloud][:private_ips][0]).to eq(@plugin[:ec2]['local_ipv4'])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud][:provider].should == "ec2"
+ expect(@plugin[:cloud][:provider]).to eq("ec2")
end
end
@@ -66,42 +66,42 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:rackspace][:public_ipv4] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:public_ipv4].should == @plugin[:rackspace][:public_ipv4]
+ expect(@plugin[:cloud][:public_ipv4]).to eq(@plugin[:rackspace][:public_ipv4])
end
it "populates cloud public ipv6" do
@plugin[:rackspace][:public_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
@plugin.run
- @plugin[:cloud][:public_ipv6].should == @plugin[:rackspace][:public_ipv6]
+ expect(@plugin[:cloud][:public_ipv6]).to eq(@plugin[:rackspace][:public_ipv6])
end
it "populates cloud private ip" do
@plugin[:rackspace][:local_ipv4] = "10.252.42.149"
@plugin.run
- @plugin[:cloud][:local_ipv4].should == @plugin[:rackspace][:local_ipv4]
+ expect(@plugin[:cloud][:local_ipv4]).to eq(@plugin[:rackspace][:local_ipv4])
end
it "populates cloud private ipv6" do
@plugin[:rackspace][:local_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
@plugin.run
- @plugin[:cloud][:local_ipv6].should == @plugin[:rackspace][:local_ipv6]
+ expect(@plugin[:cloud][:local_ipv6]).to eq(@plugin[:rackspace][:local_ipv6])
end
it "populates first cloud public ip" do
@plugin[:rackspace][:public_ipv4] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:public_ips].first.should == @plugin[:rackspace][:public_ipv4]
+ expect(@plugin[:cloud][:public_ips].first).to eq(@plugin[:rackspace][:public_ipv4])
end
it "populates first cloud public ip" do
@plugin[:rackspace][:local_ipv4] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:private_ips].first.should == @plugin[:rackspace][:local_ipv4]
+ expect(@plugin[:cloud][:private_ips].first).to eq(@plugin[:rackspace][:local_ipv4])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud][:provider].should == "rackspace"
+ expect(@plugin[:cloud][:provider]).to eq("rackspace")
end
end
@@ -113,24 +113,24 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:linode]['public_ip'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:public_ips][0].should == @plugin[:linode][:public_ip]
+ expect(@plugin[:cloud][:public_ips][0]).to eq(@plugin[:linode][:public_ip])
end
it "populates cloud private ip" do
@plugin[:linode]['private_ip'] = "10.252.42.149"
@plugin.run
- @plugin[:cloud][:private_ips][0].should == @plugin[:linode][:private_ip]
+ expect(@plugin[:cloud][:private_ips][0]).to eq(@plugin[:linode][:private_ip])
end
it "populates first cloud public ip" do
@plugin[:linode]['public_ip'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:public_ips].first.should == @plugin[:linode][:public_ip]
+ expect(@plugin[:cloud][:public_ips].first).to eq(@plugin[:linode][:public_ip])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud][:provider].should == "linode"
+ expect(@plugin[:cloud][:provider]).to eq("linode")
end
end
@@ -142,18 +142,18 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:eucalyptus]['public_ipv4'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:public_ips][0].should == @plugin[:eucalyptus]['public_ipv4']
+ expect(@plugin[:cloud][:public_ips][0]).to eq(@plugin[:eucalyptus]['public_ipv4'])
end
it "populates cloud private ip" do
@plugin[:eucalyptus]['local_ipv4'] = "10.252.42.149"
@plugin.run
- @plugin[:cloud][:private_ips][0].should == @plugin[:eucalyptus]['local_ipv4']
+ expect(@plugin[:cloud][:private_ips][0]).to eq(@plugin[:eucalyptus]['local_ipv4'])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud][:provider].should == "eucalyptus"
+ expect(@plugin[:cloud][:provider]).to eq("eucalyptus")
end
end
@@ -165,44 +165,44 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:azure]['public_ip'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:public_ips][0].should == @plugin[:azure]['public_ip']
- @plugin[:cloud][:public_ipv4].should == @plugin[:azure]['public_ip']
+ expect(@plugin[:cloud][:public_ips][0]).to eq(@plugin[:azure]['public_ip'])
+ expect(@plugin[:cloud][:public_ipv4]).to eq(@plugin[:azure]['public_ip'])
end
it "populates cloud vm_name" do
@plugin[:azure]['vm_name'] = "linux-vm"
@plugin.run
- @plugin[:cloud][:vm_name].should == @plugin[:azure]['vm_name']
+ expect(@plugin[:cloud][:vm_name]).to eq(@plugin[:azure]['vm_name'])
end
it "populates cloud public_fqdn" do
@plugin[:azure]['public_fqdn'] = "linux-vm-svc.cloudapp.net"
@plugin.run
- @plugin[:cloud][:public_fqdn].should == @plugin[:azure]['public_fqdn']
- @plugin[:cloud][:public_hostname].should == @plugin[:azure]['public_fqdn']
+ expect(@plugin[:cloud][:public_fqdn]).to eq(@plugin[:azure]['public_fqdn'])
+ expect(@plugin[:cloud][:public_hostname]).to eq(@plugin[:azure]['public_fqdn'])
end
it "populates cloud public_ssh_port" do
@plugin[:azure]['public_ssh_port'] = "22"
@plugin.run
- @plugin[:cloud][:public_ssh_port].should == @plugin[:azure]['public_ssh_port']
+ expect(@plugin[:cloud][:public_ssh_port]).to eq(@plugin[:azure]['public_ssh_port'])
end
it "should not populate cloud public_ssh_port when winrm is used" do
@plugin[:azure]['public_winrm_port'] = "5985"
@plugin.run
- @plugin[:cloud][:public_ssh_port].should be_nil
+ expect(@plugin[:cloud][:public_ssh_port]).to be_nil
end
it "populates cloud public_winrm_port" do
@plugin[:azure]['public_winrm_port'] = "5985"
@plugin.run
- @plugin[:cloud][:public_winrm_port].should == @plugin[:azure]['public_winrm_port']
+ expect(@plugin[:cloud][:public_winrm_port]).to eq(@plugin[:azure]['public_winrm_port'])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud][:provider].should == "azure"
+ expect(@plugin[:cloud][:provider]).to eq("azure")
end
end
@@ -214,24 +214,24 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:cloudstack]['public_ipv4'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud][:public_ips][0].should == @plugin[:cloudstack]['public_ipv4']
+ expect(@plugin[:cloud][:public_ips][0]).to eq(@plugin[:cloudstack]['public_ipv4'])
end
it "populates cloud private ip" do
@plugin[:cloudstack]['local_ipv4'] = "10.252.42.149"
@plugin.run
- @plugin[:cloud][:private_ips][0].should == @plugin[:cloudstack]['local_ipv4']
+ expect(@plugin[:cloud][:private_ips][0]).to eq(@plugin[:cloudstack]['local_ipv4'])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud][:provider].should == "cloudstack"
+ expect(@plugin[:cloud][:provider]).to eq("cloudstack")
end
it "populates vm id" do
@plugin[:cloudstack]['vm_id'] = "8983fb85-fb7f-46d6-8af1-c1b6666fec39"
@plugin.run
- @plugin[:cloud][:vm_id].should == @plugin[:cloudstack]['vm_id']
+ expect(@plugin[:cloud][:vm_id]).to eq(@plugin[:cloudstack]['vm_id'])
end
end
diff --git a/spec/unit/plugins/cloud_v2_spec.rb b/spec/unit/plugins/cloud_v2_spec.rb
index a075eb63..8c32cf0a 100644
--- a/spec/unit/plugins/cloud_v2_spec.rb
+++ b/spec/unit/plugins/cloud_v2_spec.rb
@@ -47,27 +47,27 @@ describe "CloudAttrs object" do
@cloud_attr_obj.public_hostname = "myhost.somewhere.com"
@cloud_attr_obj.local_hostname = "my-localhost"
@cloud_attr_obj.provider = "my_awesome_cloud"
- @cloud_attr_obj.cloud_mash.should == cloud_node
+ expect(@cloud_attr_obj.cloud_mash).to eq(cloud_node)
end
it "throws exception with a bad ipv4 address" do
@cloud_attr_obj = ::CloudAttrs.new()
- lambda { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.should raise_error
+ expect { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.to raise_error
end
it "throws exception with a bad ipv6 address" do
@cloud_attr_obj = ::CloudAttrs.new()
- lambda { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.should raise_error
+ expect { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.to raise_error
end
it "throws exception with ipv6 address passed to ipv4" do
@cloud_attr_obj = ::CloudAttrs.new()
- lambda { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.should raise_error
+ expect { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.to raise_error
end
it "throws exception with ipv4 address passed to ipv6" do
@cloud_attr_obj = ::CloudAttrs.new()
- lambda { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.should raise_error
+ expect { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.to raise_error
end
@@ -87,7 +87,7 @@ describe Ohai::System, "plugin cloud" do
@plugin[:azure] = nil
@plugin[:gce] = nil
@plugin.run
- @plugin[:cloud_v2].should be_nil
+ expect(@plugin[:cloud_v2]).to be_nil
end
end
@@ -99,18 +99,18 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:ec2]['public_ipv4'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud_v2][:public_ipv4_addrs][0].should == @plugin[:ec2]['public_ipv4']
+ expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:ec2]['public_ipv4'])
end
it "populates cloud private ip" do
@plugin[:ec2]['local_ipv4'] = "10.252.42.149"
@plugin.run
- @plugin[:cloud_v2][:local_ipv4_addrs][0].should == @plugin[:ec2]['local_ipv4']
+ expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:ec2]['local_ipv4'])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud_v2][:provider].should == "ec2"
+ expect(@plugin[:cloud_v2][:provider]).to eq("ec2")
end
end
@@ -129,17 +129,17 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin.run
- @plugin[:cloud_v2][:public_ipv4_addrs][0].should == "8.35.198.173"
+ expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq("8.35.198.173")
end
it "populates cloud private ip" do
@plugin.run
- @plugin[:cloud_v2][:local_ipv4_addrs][0].should == "10.240.0.102"
+ expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq("10.240.0.102")
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud_v2][:provider].should == "gce"
+ expect(@plugin[:cloud_v2][:provider]).to eq("gce")
end
end
@@ -151,42 +151,42 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:rackspace][:public_ipv4] = "174.129.150.8"
@plugin.run
- @plugin[:cloud_v2][:public_ipv4].should == @plugin[:rackspace][:public_ipv4]
+ expect(@plugin[:cloud_v2][:public_ipv4]).to eq(@plugin[:rackspace][:public_ipv4])
end
it "populates cloud public ipv6" do
@plugin[:rackspace][:public_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
@plugin.run
- @plugin[:cloud_v2][:public_ipv6].should == @plugin[:rackspace][:public_ipv6]
+ expect(@plugin[:cloud_v2][:public_ipv6]).to eq(@plugin[:rackspace][:public_ipv6])
end
it "populates cloud private ip" do
@plugin[:rackspace][:local_ipv4] = "10.252.42.149"
@plugin.run
- @plugin[:cloud_v2][:local_ipv4].should == @plugin[:rackspace][:local_ipv4]
+ expect(@plugin[:cloud_v2][:local_ipv4]).to eq(@plugin[:rackspace][:local_ipv4])
end
it "populates cloud private ipv6" do
@plugin[:rackspace][:local_ipv6] = "2a00:1a48:7805:111:e875:efaf:ff08:75"
@plugin.run
- @plugin[:cloud_v2][:local_ipv6].should == @plugin[:rackspace][:local_ipv6]
+ expect(@plugin[:cloud_v2][:local_ipv6]).to eq(@plugin[:rackspace][:local_ipv6])
end
it "populates first cloud public ip" do
@plugin[:rackspace][:public_ipv4] = "174.129.150.8"
@plugin.run
- @plugin[:cloud_v2][:public_ipv4_addrs].first.should == @plugin[:rackspace][:public_ipv4]
+ expect(@plugin[:cloud_v2][:public_ipv4_addrs].first).to eq(@plugin[:rackspace][:public_ipv4])
end
it "populates first cloud public ip" do
@plugin[:rackspace][:local_ipv4] = "174.129.150.8"
@plugin.run
- @plugin[:cloud_v2][:local_ipv4_addrs].first.should == @plugin[:rackspace][:local_ipv4]
+ expect(@plugin[:cloud_v2][:local_ipv4_addrs].first).to eq(@plugin[:rackspace][:local_ipv4])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud_v2][:provider].should == "rackspace"
+ expect(@plugin[:cloud_v2][:provider]).to eq("rackspace")
end
end
@@ -198,24 +198,24 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:linode]['public_ip'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud_v2][:public_ipv4_addrs][0].should == @plugin[:linode][:public_ip]
+ expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:linode][:public_ip])
end
it "populates cloud private ip" do
@plugin[:linode]['private_ip'] = "10.252.42.149"
@plugin.run
- @plugin[:cloud_v2][:local_ipv4_addrs][0].should == @plugin[:linode][:private_ip]
+ expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:linode][:private_ip])
end
it "populates first cloud public ip" do
@plugin[:linode]['public_ip'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud_v2][:public_ipv4_addrs].first.should == @plugin[:linode][:public_ip]
+ expect(@plugin[:cloud_v2][:public_ipv4_addrs].first).to eq(@plugin[:linode][:public_ip])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud_v2][:provider].should == "linode"
+ expect(@plugin[:cloud_v2][:provider]).to eq("linode")
end
end
@@ -227,18 +227,18 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:eucalyptus]['public_ipv4'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud_v2][:public_ipv4_addrs][0].should == @plugin[:eucalyptus]['public_ipv4']
+ expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]['public_ipv4'])
end
it "populates cloud private ip" do
@plugin[:eucalyptus]['local_ipv4'] = "10.252.42.149"
@plugin.run
- @plugin[:cloud_v2][:local_ipv4_addrs][0].should == @plugin[:eucalyptus]['local_ipv4']
+ expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]['local_ipv4'])
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud_v2][:provider].should == "eucalyptus"
+ expect(@plugin[:cloud_v2][:provider]).to eq("eucalyptus")
end
end
@@ -250,42 +250,42 @@ describe Ohai::System, "plugin cloud" do
it "populates cloud public ip" do
@plugin[:azure]['public_ip'] = "174.129.150.8"
@plugin.run
- @plugin[:cloud_v2][:public_ipv4_addrs][0].should == @plugin[:azure]['public_ip']
+ expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:azure]['public_ip'])
end
it "doesn't populates cloud vm_name" do
@plugin[:azure]['vm_name'] = "linux-vm"
@plugin.run
- @plugin[:cloud_v2][:vm_name].should_not == @plugin[:azure]['vm_name']
+ expect(@plugin[:cloud_v2][:vm_name]).not_to eq(@plugin[:azure]['vm_name'])
end
it "populates cloud public_hostname" do
@plugin[:azure]['public_fqdn'] = "linux-vm-svc.cloudapp.net"
@plugin.run
- @plugin[:cloud_v2][:public_hostname].should == @plugin[:azure]['public_fqdn']
+ expect(@plugin[:cloud_v2][:public_hostname]).to eq(@plugin[:azure]['public_fqdn'])
end
it "doesn't populate cloud public_ssh_port" do
@plugin[:azure]['public_ssh_port'] = "22"
@plugin.run
- @plugin[:cloud_v2][:public_ssh_port].should be_nil
+ expect(@plugin[:cloud_v2][:public_ssh_port]).to be_nil
end
it "should not populate cloud public_ssh_port when winrm is used" do
@plugin[:azure]['public_winrm_port'] = "5985"
@plugin.run
- @plugin[:cloud_v2][:public_ssh_port].should be_nil
+ expect(@plugin[:cloud_v2][:public_ssh_port]).to be_nil
end
it "populates cloud public_winrm_port" do
@plugin[:azure]['public_winrm_port'] = "5985"
@plugin.run
- @plugin[:cloud_v2][:public_winrm_port].should be_nil
+ expect(@plugin[:cloud_v2][:public_winrm_port]).to be_nil
end
it "populates cloud provider" do
@plugin.run
- @plugin[:cloud_v2][:provider].should == "azure"
+ expect(@plugin[:cloud_v2][:provider]).to eq("azure")
end
end
diff --git a/spec/unit/plugins/cloudstack_spec.rb b/spec/unit/plugins/cloudstack_spec.rb
index 209901c1..d2ae76dd 100644
--- a/spec/unit/plugins/cloudstack_spec.rb
+++ b/spec/unit/plugins/cloudstack_spec.rb
@@ -28,7 +28,7 @@ describe "Cloudstack Plugin" do
let(:cloudstack_plugin) do
plugin = get_plugin("cloudstack", ohai_system)
- plugin.stub(:hint?).with("cloudstack").and_return(cloudstack_hint)
+ allow(plugin).to receive(:hint?).with("cloudstack").and_return(cloudstack_hint)
plugin
end
@@ -51,7 +51,7 @@ describe "Cloudstack Plugin" do
context "and the metadata service is not available" do
before do
- cloudstack_plugin.should_receive(:can_metadata_connect?).
+ expect(cloudstack_plugin).to receive(:can_metadata_connect?).
with(Ohai::Mixin::CloudstackMetadata::CLOUDSTACK_METADATA_ADDR,80).
and_return(false)
end
@@ -97,21 +97,21 @@ EOM
let(:http_client) { double("Net::HTTP", :read_timeout= => nil) }
def expect_get(url, response_body)
- http_client.should_receive(:get).
+ expect(http_client).to receive(:get).
with(url).
and_return(double("HTTP Response", :code => "200", :body => response_body))
end
before do
- cloudstack_plugin.should_receive(:can_metadata_connect?).
+ expect(cloudstack_plugin).to receive(:can_metadata_connect?).
with(Ohai::Mixin::CloudstackMetadata::CLOUDSTACK_METADATA_ADDR,80).
and_return(true)
- Net::HTTP.stub(:start).
+ allow(Net::HTTP).to receive(:start).
with(Ohai::Mixin::CloudstackMetadata::CLOUDSTACK_METADATA_ADDR).
and_return(http_client)
- cloudstack_plugin.stub(:best_api_version).and_return(metadata_version)
+ allow(cloudstack_plugin).to receive(:best_api_version).and_return(metadata_version)
expect_get("/#{metadata_version}/meta-data/", metadata_root)
diff --git a/spec/unit/plugins/darwin/cpu_spec.rb b/spec/unit/plugins/darwin/cpu_spec.rb
index 9ad385b4..5ddc6e3a 100644
--- a/spec/unit/plugins/darwin/cpu_spec.rb
+++ b/spec/unit/plugins/darwin/cpu_spec.rb
@@ -22,52 +22,52 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Darwin cpu plugin" do
before(:each) do
@plugin = get_plugin("darwin/cpu")
- @plugin.stub(:collect_os).and_return(:darwin)
- @plugin.stub(:shell_out).with("sysctl -n hw.physicalcpu").and_return(mock_shell_out(0, "4", ""))
- @plugin.stub(:shell_out).with("sysctl -n hw.logicalcpu").and_return(mock_shell_out(0, "8", ""))
- @plugin.stub(:shell_out).with("sysctl -n hw.cpufrequency").and_return(mock_shell_out(0, "2300000000", ""))
- @plugin.stub(:shell_out).with("sysctl -n machdep.cpu.vendor").and_return(mock_shell_out(0, "GenuineIntel\n", ""))
- @plugin.stub(:shell_out).with("sysctl -n machdep.cpu.brand_string").and_return(mock_shell_out(0, "Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz\n", ""))
- @plugin.stub(:shell_out).with("sysctl -n machdep.cpu.model").and_return(mock_shell_out(0, "58", ""))
- @plugin.stub(:shell_out).with("sysctl -n machdep.cpu.family").and_return(mock_shell_out(0, "6", ""))
- @plugin.stub(:shell_out).with("sysctl -n machdep.cpu.stepping").and_return(mock_shell_out(0, "9", ""))
- @plugin.stub(:shell_out).with("sysctl -n machdep.cpu.features").and_return(mock_shell_out(0, "FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0 RDRAND F16C", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.physicalcpu").and_return(mock_shell_out(0, "4", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.logicalcpu").and_return(mock_shell_out(0, "8", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.cpufrequency").and_return(mock_shell_out(0, "2300000000", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n machdep.cpu.vendor").and_return(mock_shell_out(0, "GenuineIntel\n", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n machdep.cpu.brand_string").and_return(mock_shell_out(0, "Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz\n", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n machdep.cpu.model").and_return(mock_shell_out(0, "58", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n machdep.cpu.family").and_return(mock_shell_out(0, "6", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n machdep.cpu.stepping").and_return(mock_shell_out(0, "9", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n machdep.cpu.features").and_return(mock_shell_out(0, "FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0 RDRAND F16C", ""))
@plugin.run
end
it "should set cpu[:total] to 8" do
- @plugin[:cpu][:total].should == 8
+ expect(@plugin[:cpu][:total]).to eq(8)
end
it "should set cpu[:real] to 4" do
- @plugin[:cpu][:real].should == 4
+ expect(@plugin[:cpu][:real]).to eq(4)
end
it "should set cpu[:mhz] to 2300" do
- @plugin[:cpu][:mhz].should == 2300
+ expect(@plugin[:cpu][:mhz]).to eq(2300)
end
it "should set cpu[:vendor_id] to GenuineIntel" do
- @plugin[:cpu][:vendor_id].should == "GenuineIntel"
+ expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
end
it "should set cpu[:model_name] to Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz" do
- @plugin[:cpu][:model_name].should == "Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz"
+ expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz")
end
it "should set cpu[:model] to 58" do
- @plugin[:cpu][:model].should == 58
+ expect(@plugin[:cpu][:model]).to eq(58)
end
it "should set cpu[:family] to 6" do
- @plugin[:cpu][:family].should == 6
+ expect(@plugin[:cpu][:family]).to eq(6)
end
it "should set cpu[:stepping] to 9" do
- @plugin[:cpu][:stepping].should == 9
+ expect(@plugin[:cpu][:stepping]).to eq(9)
end
it "should set cpu[:flags] to array of flags" do
- @plugin[:cpu][:flags].should == ["fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "clfsh", "ds", "acpi", "mmx", "fxsr", "sse", "sse2", "ss", "htt", "tm", "pbe", "sse3", "pclmulqdq", "dtes64", "mon", "dscpl", "vmx", "est", "tm2", "ssse3", "cx16", "tpr", "pdcm", "sse4.1", "sse4.2", "x2apic", "popcnt", "aes", "pcid", "xsave", "osxsave", "tsctmr", "avx1.0", "rdrand", "f16c"]
+ expect(@plugin[:cpu][:flags]).to eq(["fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "clfsh", "ds", "acpi", "mmx", "fxsr", "sse", "sse2", "ss", "htt", "tm", "pbe", "sse3", "pclmulqdq", "dtes64", "mon", "dscpl", "vmx", "est", "tm2", "ssse3", "cx16", "tpr", "pdcm", "sse4.1", "sse4.2", "x2apic", "popcnt", "aes", "pcid", "xsave", "osxsave", "tsctmr", "avx1.0", "rdrand", "f16c"])
end
end
diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb
index 9f06678c..9ee0ec1e 100644
--- a/spec/unit/plugins/darwin/hostname_spec.rb
+++ b/spec/unit/plugins/darwin/hostname_spec.rb
@@ -22,10 +22,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Darwin hostname plugin" do
before(:each) do
@plugin = get_plugin("hostname")
- @plugin.stub(:collect_os).and_return(:darwin)
- @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
- @plugin.stub(:resolve_fqdn).and_return("katie.bethell")
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
+ allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
it_should_check_from("darwin::hostname", "hostname", "hostname -s", "katie")
@@ -34,12 +34,12 @@ describe Ohai::System, "Darwin hostname plugin" do
it "should use #resolve_fqdn to find the fqdn" do
@plugin.run
- @plugin[:fqdn].should == "katie.bethell"
+ expect(@plugin[:fqdn]).to eq("katie.bethell")
end
it "should set the domain to everything after the first dot of the fqdn" do
@plugin.run
- @plugin[:domain].should == "bethell"
+ expect(@plugin[:domain]).to eq("bethell")
end
end
diff --git a/spec/unit/plugins/darwin/kernel_spec.rb b/spec/unit/plugins/darwin/kernel_spec.rb
index 2df35d7d..c5f46b27 100644
--- a/spec/unit/plugins/darwin/kernel_spec.rb
+++ b/spec/unit/plugins/darwin/kernel_spec.rb
@@ -22,13 +22,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Darwin kernel plugin" do
before(:each) do
@plugin = get_plugin("kernel")
- @plugin.stub(:collect_os).and_return(:darwin)
- @plugin.stub(:init_kernel).and_return({})
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
+ allow(@plugin).to receive(:init_kernel).and_return({})
end
it "should populate kernel[:modules] from `kextstat -k -l`" do
- @plugin.stub(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", ""))
- @plugin.stub(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, <<EOF, ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", ""))
+ allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, <<EOF, ""))
8 0 0xffffff7f81aed000 0x41000 0x41000 com.apple.kec.corecrypto (1.0) <7 6 5 4 3 1>
9 22 0xffffff7f807f3000 0x9000 0x9000 com.apple.iokit.IOACPIFamily (1.4) <7 6 4 3>
10 30 0xffffff7f80875000 0x29000 0x29000 com.apple.iokit.IOPCIFamily (2.8) <7 6 5 4 3>
@@ -43,27 +43,27 @@ EOF
{"version"=>"2.8", "size"=>167936, "index"=>"10", "refcount"=>"30"}}
@plugin.run
- @plugin[:kernel][:modules].should eql(modules)
+ expect(@plugin[:kernel][:modules]).to eql(modules)
end
it "should not set kernel_machine to x86_64" do
- @plugin.stub(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", ""))
- @plugin.stub(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", ""))
+ allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
@plugin.run
- @plugin[:kernel][:machine].should_not == 'x86_64'
+ expect(@plugin[:kernel][:machine]).not_to eq('x86_64')
end
it "should set kernel_machine to x86_64" do
- @plugin.stub(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", ""))
- @plugin.stub(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", ""))
+ allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
@plugin.run
- @plugin[:kernel][:machine].should == 'x86_64'
+ expect(@plugin[:kernel][:machine]).to eq('x86_64')
end
it "should set the kernel_os to the kernel_name value" do
- @plugin.stub(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", ""))
- @plugin.stub(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", ""))
+ allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", ""))
@plugin.run
- @plugin[:kernel][:os].should == @plugin[:kernel][:name]
+ expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
end
end
diff --git a/spec/unit/plugins/darwin/memory_spec.rb b/spec/unit/plugins/darwin/memory_spec.rb
index 17595ae8..297a35be 100644
--- a/spec/unit/plugins/darwin/memory_spec.rb
+++ b/spec/unit/plugins/darwin/memory_spec.rb
@@ -40,25 +40,25 @@ Object cache: 12 hits of 139872 lookups (0% hit rate)
DARWIN_VM_STAT
@plugin = get_plugin("darwin/memory")
- @plugin.stub(:collect_os).and_return(:darwin)
- @plugin.stub(:shell_out).with("sysctl -n hw.memsize").and_return(mock_shell_out(0, darwin_memsize, ""))
- @plugin.stub(:shell_out).with("vm_stat").and_return(mock_shell_out(0, darwin_vm_stat, ""))
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.memsize").and_return(mock_shell_out(0, darwin_memsize, ""))
+ allow(@plugin).to receive(:shell_out).with("vm_stat").and_return(mock_shell_out(0, darwin_vm_stat, ""))
@plugin.run
end
it "should set memory[:total] to 16384MB" do
- @plugin[:memory][:total].should == '16384MB'
+ expect(@plugin[:memory][:total]).to eq('16384MB')
end
it "should set memory[:active] to 5140MB" do
- @plugin[:memory][:active].should == '5140MB'
+ expect(@plugin[:memory][:active]).to eq('5140MB')
end
it "should set memory[:inactive] to 738MB" do
- @plugin[:memory][:inactive].should == '738MB'
+ expect(@plugin[:memory][:inactive]).to eq('738MB')
end
it "should set memory[:free] to 10504MB" do
- @plugin[:memory][:free].should == '10504MB'
+ expect(@plugin[:memory][:free]).to eq('10504MB')
end
end
diff --git a/spec/unit/plugins/darwin/network_spec.rb b/spec/unit/plugins/darwin/network_spec.rb
index 2cf5ed04..a6843ffb 100644
--- a/spec/unit/plugins/darwin/network_spec.rb
+++ b/spec/unit/plugins/darwin/network_spec.rb
@@ -413,7 +413,7 @@ net.smb.fs.tcprcvbuf: 261120
DARWIN_SYSCTL
@plugin = get_plugin("darwin/network")
- @plugin.stub(:collect_os).and_return(:darwin)
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
# @stdin_ifconfig = StringIO.new
# @stdin_arp = StringIO.new
@@ -425,426 +425,426 @@ net.smb.fs.tcprcvbuf: 261120
# @netstat_lines = darwin_netstat.split("\n")
# @sysctl_lines = darwin_sysctl.split("\n")
- @plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @darwin_route, ""))
- @plugin.stub(:shell_out).with("netstat -i -d -l -b -n")
+ allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @darwin_route, ""))
+ allow(@plugin).to receive(:shell_out).with("netstat -i -d -l -b -n")
end
describe "gathering IP layer address info" do
before(:each) do
- @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @darwin_arp, ""))
- @plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @darwin_ifconfig, ""))
- @plugin.stub(:shell_out).with("netstat -i -d -l -b -n").and_return(mock_shell_out(0, @darwin_netstat, ""))
- @plugin.stub(:shell_out).with("sysctl net").and_return(mock_shell_out(0, @darwin_sysctl, ""))
+ allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @darwin_arp, ""))
+ allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @darwin_ifconfig, ""))
+ allow(@plugin).to receive(:shell_out).with("netstat -i -d -l -b -n").and_return(mock_shell_out(0, @darwin_netstat, ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl net").and_return(mock_shell_out(0, @darwin_sysctl, ""))
@plugin.run
end
it "completes the run" do
- @plugin['network'].should_not be_nil
+ expect(@plugin['network']).not_to be_nil
end
it "detects the interfaces" do
- @plugin['network']['interfaces'].keys.sort.should == ["en0", "en1", "fw0", "gif0", "lo0", "p2p0", "stf0", "utun0"]
+ expect(@plugin['network']['interfaces'].keys.sort).to eq(["en0", "en1", "fw0", "gif0", "lo0", "p2p0", "stf0", "utun0"])
end
it "detects the ipv4 addresses of the ethernet interface" do
- @plugin['network']['interfaces']['en1']['addresses'].keys.should include('10.20.10.144')
- @plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['netmask'].should == '255.255.255.0'
- @plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['broadcast'].should == '10.20.10.255'
- @plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['family'].should == 'inet'
+ expect(@plugin['network']['interfaces']['en1']['addresses'].keys).to include('10.20.10.144')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['netmask']).to eq('255.255.255.0')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['broadcast']).to eq('10.20.10.255')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['family']).to eq('inet')
end
it "detects the ipv6 addresses of the ethernet interface" do
- @plugin['network']['interfaces']['en1']['addresses'].keys.should include('fe80::ba8d:12ff:fe3a:32de')
- @plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['scope'].should == 'Link'
- @plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['prefixlen'].should == '64'
- @plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['family'].should == 'inet6'
-
- @plugin['network']['interfaces']['en1']['addresses'].keys.should include('2001:44b8:4186:1100:ba8d:12ff:fe3a:32de')
- @plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['scope'].should == 'Global'
- @plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['prefixlen'].should == '64'
- @plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['family'].should == 'inet6'
+ expect(@plugin['network']['interfaces']['en1']['addresses'].keys).to include('fe80::ba8d:12ff:fe3a:32de')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['scope']).to eq('Link')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['prefixlen']).to eq('64')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['family']).to eq('inet6')
+
+ expect(@plugin['network']['interfaces']['en1']['addresses'].keys).to include('2001:44b8:4186:1100:ba8d:12ff:fe3a:32de')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['scope']).to eq('Global')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['prefixlen']).to eq('64')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['family']).to eq('inet6')
end
it "detects the mac addresses of the ethernet interface" do
- @plugin['network']['interfaces']['en1']['addresses'].keys.should include('b8:8d:12:3a:32:de')
- @plugin['network']['interfaces']['en1']['addresses']['b8:8d:12:3a:32:de']['family'].should == 'lladdr'
+ expect(@plugin['network']['interfaces']['en1']['addresses'].keys).to include('b8:8d:12:3a:32:de')
+ expect(@plugin['network']['interfaces']['en1']['addresses']['b8:8d:12:3a:32:de']['family']).to eq('lladdr')
end
it "detects the encapsulation type of the ethernet interface" do
- @plugin['network']['interfaces']['en1']['encapsulation'].should == 'Ethernet'
+ expect(@plugin['network']['interfaces']['en1']['encapsulation']).to eq('Ethernet')
end
it "detects the flags of the ethernet interface" do
- @plugin['network']['interfaces']['en1']['flags'].sort.should == ["BROADCAST", "MULTICAST", "RUNNING", "SIMPLEX", "SMART", "UP"]
+ expect(@plugin['network']['interfaces']['en1']['flags'].sort).to eq(["BROADCAST", "MULTICAST", "RUNNING", "SIMPLEX", "SMART", "UP"])
end
it "detects the mtu of the ethernet interface" do
- @plugin['network']['interfaces']['en1']['mtu'].should == "1500"
+ expect(@plugin['network']['interfaces']['en1']['mtu']).to eq("1500")
end
it "detects the ipv4 addresses of the loopback interface" do
- @plugin['network']['interfaces']['lo0']['addresses'].keys.should include('127.0.0.1')
- @plugin['network']['interfaces']['lo0']['addresses']['127.0.0.1']['netmask'].should == '255.0.0.0'
- @plugin['network']['interfaces']['lo0']['addresses']['127.0.0.1']['family'].should == 'inet'
+ expect(@plugin['network']['interfaces']['lo0']['addresses'].keys).to include('127.0.0.1')
+ expect(@plugin['network']['interfaces']['lo0']['addresses']['127.0.0.1']['netmask']).to eq('255.0.0.0')
+ expect(@plugin['network']['interfaces']['lo0']['addresses']['127.0.0.1']['family']).to eq('inet')
end
it "detects the ipv6 addresses of the loopback interface" do
- @plugin['network']['interfaces']['lo0']['addresses'].keys.should include('::1')
- @plugin['network']['interfaces']['lo0']['addresses']['::1']['scope'].should == 'Node'
- @plugin['network']['interfaces']['lo0']['addresses']['::1']['prefixlen'].should == '128'
- @plugin['network']['interfaces']['lo0']['addresses']['::1']['family'].should == 'inet6'
+ expect(@plugin['network']['interfaces']['lo0']['addresses'].keys).to include('::1')
+ expect(@plugin['network']['interfaces']['lo0']['addresses']['::1']['scope']).to eq('Node')
+ expect(@plugin['network']['interfaces']['lo0']['addresses']['::1']['prefixlen']).to eq('128')
+ expect(@plugin['network']['interfaces']['lo0']['addresses']['::1']['family']).to eq('inet6')
end
it "detects the encapsulation type of the loopback interface" do
- @plugin['network']['interfaces']['lo0']['encapsulation'].should == 'Loopback'
+ expect(@plugin['network']['interfaces']['lo0']['encapsulation']).to eq('Loopback')
end
it "detects the flags of the ethernet interface" do
- @plugin['network']['interfaces']['lo0']['flags'].sort.should == ["LOOPBACK", "MULTICAST", "RUNNING", "UP"]
+ expect(@plugin['network']['interfaces']['lo0']['flags'].sort).to eq(["LOOPBACK", "MULTICAST", "RUNNING", "UP"])
end
it "detects the mtu of the loopback interface" do
- @plugin['network']['interfaces']['lo0']['mtu'].should == "16384"
+ expect(@plugin['network']['interfaces']['lo0']['mtu']).to eq("16384")
end
it "detects the arp entries" do
- @plugin['network']['interfaces']['en1']['arp']['10.20.10.1'].should == '0:4:ed:de:41:bf'
+ expect(@plugin['network']['interfaces']['en1']['arp']['10.20.10.1']).to eq('0:4:ed:de:41:bf')
end
it "detects the ethernet counters" do
- @plugin['counters']['network']['interfaces']['en1']['tx']['bytes'].should == "18228234970"
- @plugin['counters']['network']['interfaces']['en1']['tx']['packets'].should == "14314573"
- @plugin['counters']['network']['interfaces']['en1']['tx']['collisions'].should == "0"
- @plugin['counters']['network']['interfaces']['en1']['tx']['errors'].should == "0"
- @plugin['counters']['network']['interfaces']['en1']['tx']['carrier'].should == 0
- @plugin['counters']['network']['interfaces']['en1']['tx']['drop'].should == 0
-
- @plugin['counters']['network']['interfaces']['en1']['rx']['bytes'].should == "2530556736"
- @plugin['counters']['network']['interfaces']['en1']['rx']['packets'].should == "5921903"
- @plugin['counters']['network']['interfaces']['en1']['rx']['errors'].should == "0"
- @plugin['counters']['network']['interfaces']['en1']['rx']['overrun'].should == 0
- @plugin['counters']['network']['interfaces']['en1']['rx']['drop'].should == 0
+ expect(@plugin['counters']['network']['interfaces']['en1']['tx']['bytes']).to eq("18228234970")
+ expect(@plugin['counters']['network']['interfaces']['en1']['tx']['packets']).to eq("14314573")
+ expect(@plugin['counters']['network']['interfaces']['en1']['tx']['collisions']).to eq("0")
+ expect(@plugin['counters']['network']['interfaces']['en1']['tx']['errors']).to eq("0")
+ expect(@plugin['counters']['network']['interfaces']['en1']['tx']['carrier']).to eq(0)
+ expect(@plugin['counters']['network']['interfaces']['en1']['tx']['drop']).to eq(0)
+
+ expect(@plugin['counters']['network']['interfaces']['en1']['rx']['bytes']).to eq("2530556736")
+ expect(@plugin['counters']['network']['interfaces']['en1']['rx']['packets']).to eq("5921903")
+ expect(@plugin['counters']['network']['interfaces']['en1']['rx']['errors']).to eq("0")
+ expect(@plugin['counters']['network']['interfaces']['en1']['rx']['overrun']).to eq(0)
+ expect(@plugin['counters']['network']['interfaces']['en1']['rx']['drop']).to eq(0)
end
it "detects the loopback counters" do
- @plugin['counters']['network']['interfaces']['lo0']['tx']['bytes'].should == "25774844"
- @plugin['counters']['network']['interfaces']['lo0']['tx']['packets'].should == "174982"
- @plugin['counters']['network']['interfaces']['lo0']['tx']['collisions'].should == "0"
- @plugin['counters']['network']['interfaces']['lo0']['tx']['errors'].should == "0"
- @plugin['counters']['network']['interfaces']['lo0']['tx']['carrier'].should == 0
- @plugin['counters']['network']['interfaces']['lo0']['tx']['drop'].should == 0
-
- @plugin['counters']['network']['interfaces']['lo0']['rx']['bytes'].should == "25774844"
- @plugin['counters']['network']['interfaces']['lo0']['rx']['packets'].should == "174982"
- @plugin['counters']['network']['interfaces']['lo0']['rx']['errors'].should == "0"
- @plugin['counters']['network']['interfaces']['lo0']['rx']['overrun'].should == 0
- @plugin['counters']['network']['interfaces']['lo0']['rx']['drop'].should == 0
+ expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['bytes']).to eq("25774844")
+ expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['packets']).to eq("174982")
+ expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['collisions']).to eq("0")
+ expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['errors']).to eq("0")
+ expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['carrier']).to eq(0)
+ expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['drop']).to eq(0)
+
+ expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['bytes']).to eq("25774844")
+ expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['packets']).to eq("174982")
+ expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['errors']).to eq("0")
+ expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['overrun']).to eq(0)
+ expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['drop']).to eq(0)
end
it "finds the default interface by asking which iface has the default route" do
- @plugin['network'][:default_interface].should == 'en1'
+ expect(@plugin['network'][:default_interface]).to eq('en1')
end
it "finds the default interface by asking which iface has the default route" do
- @plugin['network'][:default_gateway].should == '10.20.10.1'
+ expect(@plugin['network'][:default_gateway]).to eq('10.20.10.1')
end
it "should detect network settings" do
- @plugin['network']['settings']['net.local.stream.sendspace'].should == '8192'
- @plugin["network"]["settings"]['net.local.stream.recvspace'].should == '8192'
- @plugin["network"]["settings"]['net.local.stream.tracemdns'].should == '0'
- @plugin["network"]["settings"]['net.local.dgram.maxdgram'].should == '2048'
- @plugin["network"]["settings"]['net.local.dgram.recvspace'].should == '4096'
- @plugin["network"]["settings"]['net.local.inflight'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.portrange.lowfirst'].should == '1023'
- @plugin["network"]["settings"]['net.inet.ip.portrange.lowlast'].should == '600'
- @plugin["network"]["settings"]['net.inet.ip.portrange.first'].should == '49152'
- @plugin["network"]["settings"]['net.inet.ip.portrange.last'].should == '65535'
- @plugin["network"]["settings"]['net.inet.ip.portrange.hifirst'].should == '49152'
- @plugin["network"]["settings"]['net.inet.ip.portrange.hilast'].should == '65535'
- @plugin["network"]["settings"]['net.inet.ip.forwarding'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.redirect'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.ttl'].should == '64'
- @plugin["network"]["settings"]['net.inet.ip.rtexpire'].should == '12'
- @plugin["network"]["settings"]['net.inet.ip.rtminexpire'].should == '10'
- @plugin["network"]["settings"]['net.inet.ip.rtmaxcache'].should == '128'
- @plugin["network"]["settings"]['net.inet.ip.sourceroute'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.intr_queue_maxlen'].should == '50'
- @plugin["network"]["settings"]['net.inet.ip.intr_queue_drops'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.accept_sourceroute'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.keepfaith'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.gifttl'].should == '30'
- @plugin["network"]["settings"]['net.inet.ip.subnets_are_local'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.mcast.maxgrpsrc'].should == '512'
- @plugin["network"]["settings"]['net.inet.ip.mcast.maxsocksrc'].should == '128'
- @plugin["network"]["settings"]['net.inet.ip.mcast.loop'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.check_route_selfref'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.use_route_genid'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.hash_size'].should == '64'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.curr_time'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.ready_heap'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.extract_heap'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.searches'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.search_steps'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.expire'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.max_chain_len'].should == '16'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.red_lookup_depth'].should == '256'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.red_avg_pkt_size'].should == '512'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.red_max_pkt_size'].should == '1500'
- @plugin["network"]["settings"]['net.inet.ip.dummynet.debug'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.fw.enable'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.fw.autoinc_step'].should == '100'
- @plugin["network"]["settings"]['net.inet.ip.fw.one_pass'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.fw.debug'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.fw.verbose'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.fw.verbose_limit'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_buckets'].should == '256'
- @plugin["network"]["settings"]['net.inet.ip.fw.curr_dyn_buckets'].should == '256'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_count'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_max'].should == '4096'
- @plugin["network"]["settings"]['net.inet.ip.fw.static_count'].should == '2'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_ack_lifetime'].should == '300'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_syn_lifetime'].should == '20'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_fin_lifetime'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_rst_lifetime'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_udp_lifetime'].should == '10'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_short_lifetime'].should == '5'
- @plugin["network"]["settings"]['net.inet.ip.fw.dyn_keepalive'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.maxfragpackets'].should == '1536'
- @plugin["network"]["settings"]['net.inet.ip.maxfragsperpacket'].should == '128'
- @plugin["network"]["settings"]['net.inet.ip.maxfrags'].should == '3072'
- @plugin["network"]["settings"]['net.inet.ip.scopedroute'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.check_interface'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.linklocal.in.allowbadttl'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.random_id'].should == '1'
- @plugin["network"]["settings"]['net.inet.ip.maxchainsent'].should == '0'
- @plugin["network"]["settings"]['net.inet.ip.select_srcif_debug'].should == '0'
- @plugin["network"]["settings"]['net.inet.icmp.maskrepl'].should == '0'
- @plugin["network"]["settings"]['net.inet.icmp.icmplim'].should == '250'
- @plugin["network"]["settings"]['net.inet.icmp.timestamp'].should == '0'
- @plugin["network"]["settings"]['net.inet.icmp.drop_redirect'].should == '0'
- @plugin["network"]["settings"]['net.inet.icmp.log_redirect'].should == '0'
- @plugin["network"]["settings"]['net.inet.icmp.bmcastecho'].should == '1'
- @plugin["network"]["settings"]['net.inet.igmp.recvifkludge'].should == '1'
- @plugin["network"]["settings"]['net.inet.igmp.sendra'].should == '1'
- @plugin["network"]["settings"]['net.inet.igmp.sendlocal'].should == '1'
- @plugin["network"]["settings"]['net.inet.igmp.v1enable'].should == '1'
- @plugin["network"]["settings"]['net.inet.igmp.v2enable'].should == '1'
- @plugin["network"]["settings"]['net.inet.igmp.legacysupp'].should == '0'
- @plugin["network"]["settings"]['net.inet.igmp.default_version'].should == '3'
- @plugin["network"]["settings"]['net.inet.igmp.gsrdelay'].should == '10'
- @plugin["network"]["settings"]['net.inet.igmp.debug'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.rfc1323'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.rfc1644'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.mssdflt'].should == '512'
- @plugin["network"]["settings"]['net.inet.tcp.keepidle'].should == '7200000'
- @plugin["network"]["settings"]['net.inet.tcp.keepintvl'].should == '75000'
- @plugin["network"]["settings"]['net.inet.tcp.sendspace'].should == '65536'
- @plugin["network"]["settings"]['net.inet.tcp.recvspace'].should == '65536'
- @plugin["network"]["settings"]['net.inet.tcp.keepinit'].should == '75000'
- @plugin["network"]["settings"]['net.inet.tcp.v6mssdflt'].should == '1024'
- @plugin["network"]["settings"]['net.inet.tcp.log_in_vain'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.blackhole'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.delayed_ack'].should == '3'
- @plugin["network"]["settings"]['net.inet.tcp.tcp_lq_overflow'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.recvbg'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.drop_synfin'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.reass.maxsegments'].should == '3072'
- @plugin["network"]["settings"]['net.inet.tcp.reass.cursegments'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.reass.overflows'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.slowlink_wsize'].should == '8192'
- @plugin["network"]["settings"]['net.inet.tcp.maxseg_unacked'].should == '8'
- @plugin["network"]["settings"]['net.inet.tcp.rfc3465'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.rfc3465_lim2'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.rtt_samples_per_slot'].should == '20'
- @plugin["network"]["settings"]['net.inet.tcp.recv_allowed_iaj'].should == '5'
- @plugin["network"]["settings"]['net.inet.tcp.acc_iaj_high_thresh'].should == '100'
- @plugin["network"]["settings"]['net.inet.tcp.rexmt_thresh'].should == '2'
- @plugin["network"]["settings"]['net.inet.tcp.path_mtu_discovery'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.slowstart_flightsize'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.local_slowstart_flightsize'].should == '8'
- @plugin["network"]["settings"]['net.inet.tcp.tso'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.ecn_initiate_out'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.ecn_negotiate_in'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.packetchain'].should == '50'
- @plugin["network"]["settings"]['net.inet.tcp.socket_unlocked_on_output'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.rfc3390'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.min_iaj_win'].should == '4'
- @plugin["network"]["settings"]['net.inet.tcp.acc_iaj_react_limit'].should == '200'
- @plugin["network"]["settings"]['net.inet.tcp.sack'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.sack_maxholes'].should == '128'
- @plugin["network"]["settings"]['net.inet.tcp.sack_globalmaxholes'].should == '65536'
- @plugin["network"]["settings"]['net.inet.tcp.sack_globalholes'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.minmss'].should == '216'
- @plugin["network"]["settings"]['net.inet.tcp.minmssoverload'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.do_tcpdrain'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.pcbcount'].should == '86'
- @plugin["network"]["settings"]['net.inet.tcp.icmp_may_rst'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.strict_rfc1948'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.isn_reseed_interval'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.background_io_enabled'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.rtt_min'].should == '100'
- @plugin["network"]["settings"]['net.inet.tcp.rexmt_slop'].should == '200'
- @plugin["network"]["settings"]['net.inet.tcp.randomize_ports'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.newreno_sockets'].should == '81'
- @plugin["network"]["settings"]['net.inet.tcp.background_sockets'].should == '-1'
- @plugin["network"]["settings"]['net.inet.tcp.tcbhashsize'].should == '4096'
- @plugin["network"]["settings"]['net.inet.tcp.background_io_trigger'].should == '5'
- @plugin["network"]["settings"]['net.inet.tcp.msl'].should == '15000'
- @plugin["network"]["settings"]['net.inet.tcp.max_persist_timeout'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.always_keepalive'].should == '0'
- @plugin["network"]["settings"]['net.inet.tcp.timer_fastmode_idlemax'].should == '20'
- @plugin["network"]["settings"]['net.inet.tcp.broken_peer_syn_rxmit_thres'].should == '7'
- @plugin["network"]["settings"]['net.inet.tcp.tcp_timer_advanced'].should == '5'
- @plugin["network"]["settings"]['net.inet.tcp.tcp_resched_timerlist'].should == '12209'
- @plugin["network"]["settings"]['net.inet.tcp.pmtud_blackhole_detection'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.pmtud_blackhole_mss'].should == '1200'
- @plugin["network"]["settings"]['net.inet.tcp.timer_fastquantum'].should == '100'
- @plugin["network"]["settings"]['net.inet.tcp.timer_slowquantum'].should == '500'
- @plugin["network"]["settings"]['net.inet.tcp.win_scale_factor'].should == '3'
- @plugin["network"]["settings"]['net.inet.tcp.sockthreshold'].should == '64'
- @plugin["network"]["settings"]['net.inet.tcp.bg_target_qdelay'].should == '100'
- @plugin["network"]["settings"]['net.inet.tcp.bg_allowed_increase'].should == '2'
- @plugin["network"]["settings"]['net.inet.tcp.bg_tether_shift'].should == '1'
- @plugin["network"]["settings"]['net.inet.tcp.bg_ss_fltsz'].should == '2'
- @plugin["network"]["settings"]['net.inet.udp.checksum'].should == '1'
- @plugin["network"]["settings"]['net.inet.udp.maxdgram'].should == '9216'
- @plugin["network"]["settings"]['net.inet.udp.recvspace'].should == '42080'
- @plugin["network"]["settings"]['net.inet.udp.log_in_vain'].should == '0'
- @plugin["network"]["settings"]['net.inet.udp.blackhole'].should == '0'
- @plugin["network"]["settings"]['net.inet.udp.pcbcount'].should == '72'
- @plugin["network"]["settings"]['net.inet.udp.randomize_ports'].should == '1'
- @plugin["network"]["settings"]['net.inet.ipsec.def_policy'].should == '1'
- @plugin["network"]["settings"]['net.inet.ipsec.esp_trans_deflev'].should == '1'
- @plugin["network"]["settings"]['net.inet.ipsec.esp_net_deflev'].should == '1'
- @plugin["network"]["settings"]['net.inet.ipsec.ah_trans_deflev'].should == '1'
- @plugin["network"]["settings"]['net.inet.ipsec.ah_net_deflev'].should == '1'
- @plugin["network"]["settings"]['net.inet.ipsec.ah_cleartos'].should == '1'
- @plugin["network"]["settings"]['net.inet.ipsec.ah_offsetmask'].should == '0'
- @plugin["network"]["settings"]['net.inet.ipsec.dfbit'].should == '0'
- @plugin["network"]["settings"]['net.inet.ipsec.ecn'].should == '0'
- @plugin["network"]["settings"]['net.inet.ipsec.debug'].should == '0'
- @plugin["network"]["settings"]['net.inet.ipsec.esp_randpad'].should == '-1'
- @plugin["network"]["settings"]['net.inet.ipsec.bypass'].should == '0'
- @plugin["network"]["settings"]['net.inet.ipsec.esp_port'].should == '4500'
- @plugin["network"]["settings"]['net.inet.raw.maxdgram'].should == '8192'
- @plugin["network"]["settings"]['net.inet.raw.recvspace'].should == '8192'
- @plugin["network"]["settings"]['net.link.generic.system.ifcount'].should == '10'
- @plugin["network"]["settings"]['net.link.generic.system.dlil_verbose'].should == '0'
- @plugin["network"]["settings"]['net.link.generic.system.multi_threaded_input'].should == '1'
- @plugin["network"]["settings"]['net.link.generic.system.dlil_input_sanity_check'].should == '0'
- @plugin["network"]["settings"]['net.link.ether.inet.prune_intvl'].should == '300'
- @plugin["network"]["settings"]['net.link.ether.inet.max_age'].should == '1200'
- @plugin["network"]["settings"]['net.link.ether.inet.host_down_time'].should == '20'
- @plugin["network"]["settings"]['net.link.ether.inet.apple_hwcksum_tx'].should == '1'
- @plugin["network"]["settings"]['net.link.ether.inet.apple_hwcksum_rx'].should == '1'
- @plugin["network"]["settings"]['net.link.ether.inet.arp_llreach_base'].should == '30'
- @plugin["network"]["settings"]['net.link.ether.inet.maxtries'].should == '5'
- @plugin["network"]["settings"]['net.link.ether.inet.useloopback'].should == '1'
- @plugin["network"]["settings"]['net.link.ether.inet.proxyall'].should == '0'
- @plugin["network"]["settings"]['net.link.ether.inet.sendllconflict'].should == '0'
- @plugin["network"]["settings"]['net.link.ether.inet.log_arp_warnings'].should == '0'
- @plugin["network"]["settings"]['net.link.ether.inet.keep_announcements'].should == '1'
- @plugin["network"]["settings"]['net.link.ether.inet.send_conflicting_probes'].should == '1'
- @plugin["network"]["settings"]['net.link.bridge.log_stp'].should == '0'
- @plugin["network"]["settings"]['net.link.bridge.debug'].should == '0'
- @plugin["network"]["settings"]['net.key.debug'].should == '0'
- @plugin["network"]["settings"]['net.key.spi_trycnt'].should == '1000'
- @plugin["network"]["settings"]['net.key.spi_minval'].should == '256'
- @plugin["network"]["settings"]['net.key.spi_maxval'].should == '268435455'
- @plugin["network"]["settings"]['net.key.int_random'].should == '60'
- @plugin["network"]["settings"]['net.key.larval_lifetime'].should == '30'
- @plugin["network"]["settings"]['net.key.blockacq_count'].should == '10'
- @plugin["network"]["settings"]['net.key.blockacq_lifetime'].should == '20'
- @plugin["network"]["settings"]['net.key.esp_keymin'].should == '256'
- @plugin["network"]["settings"]['net.key.esp_auth'].should == '0'
- @plugin["network"]["settings"]['net.key.ah_keymin'].should == '128'
- @plugin["network"]["settings"]['net.key.prefered_oldsa'].should == '0'
- @plugin["network"]["settings"]['net.key.natt_keepalive_interval'].should == '20'
- @plugin["network"]["settings"]['net.inet6.ip6.forwarding'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.redirect'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.hlim'].should == '64'
- @plugin["network"]["settings"]['net.inet6.ip6.maxfragpackets'].should == '1536'
- @plugin["network"]["settings"]['net.inet6.ip6.accept_rtadv'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.keepfaith'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.log_interval'].should == '5'
- @plugin["network"]["settings"]['net.inet6.ip6.hdrnestlimit'].should == '15'
- @plugin["network"]["settings"]['net.inet6.ip6.dad_count'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.auto_flowlabel'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.defmcasthlim'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.gifhlim'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.kame_version'].should == '2009/apple-darwin'
- @plugin["network"]["settings"]['net.inet6.ip6.use_deprecated'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.rr_prune'].should == '5'
- @plugin["network"]["settings"]['net.inet6.ip6.v6only'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.rtexpire'].should == '3600'
- @plugin["network"]["settings"]['net.inet6.ip6.rtminexpire'].should == '10'
- @plugin["network"]["settings"]['net.inet6.ip6.rtmaxcache'].should == '128'
- @plugin["network"]["settings"]['net.inet6.ip6.use_tempaddr'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.temppltime'].should == '86400'
- @plugin["network"]["settings"]['net.inet6.ip6.tempvltime'].should == '604800'
- @plugin["network"]["settings"]['net.inet6.ip6.auto_linklocal'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.prefer_tempaddr'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.use_defaultzone'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.maxfrags'].should == '12288'
- @plugin["network"]["settings"]['net.inet6.ip6.mcast_pmtu'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.neighborgcthresh'].should == '1024'
- @plugin["network"]["settings"]['net.inet6.ip6.maxifprefixes'].should == '16'
- @plugin["network"]["settings"]['net.inet6.ip6.maxifdefrouters'].should == '16'
- @plugin["network"]["settings"]['net.inet6.ip6.maxdynroutes'].should == '1024'
- @plugin["network"]["settings"]['net.inet6.ip6.fw.enable'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.fw.debug'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.fw.verbose'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.fw.verbose_limit'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.scopedroute'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.select_srcif_debug'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ip6.mcast.maxgrpsrc'].should == '512'
- @plugin["network"]["settings"]['net.inet6.ip6.mcast.maxsocksrc'].should == '128'
- @plugin["network"]["settings"]['net.inet6.ip6.mcast.loop'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ip6.only_allow_rfc4193_prefixes'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ipsec6.def_policy'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ipsec6.esp_trans_deflev'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ipsec6.esp_net_deflev'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ipsec6.ah_trans_deflev'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ipsec6.ah_net_deflev'].should == '1'
- @plugin["network"]["settings"]['net.inet6.ipsec6.ecn'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ipsec6.debug'].should == '0'
- @plugin["network"]["settings"]['net.inet6.ipsec6.esp_randpad'].should == '-1'
- @plugin["network"]["settings"]['net.inet6.icmp6.rediraccept'].should == '1'
- @plugin["network"]["settings"]['net.inet6.icmp6.redirtimeout'].should == '600'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_prune'].should == '1'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_delay'].should == '5'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_umaxtries'].should == '3'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_mmaxtries'].should == '3'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_useloopback'].should == '1'
- @plugin["network"]["settings"]['net.inet6.icmp6.nodeinfo'].should == '3'
- @plugin["network"]["settings"]['net.inet6.icmp6.errppslimit'].should == '500'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_maxnudhint'].should == '0'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_debug'].should == '0'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_accept_6to4'].should == '1'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_onlink_ns_rfc4861'].should == '0'
- @plugin["network"]["settings"]['net.inet6.icmp6.nd6_llreach_base'].should == '30'
- @plugin["network"]["settings"]['net.inet6.mld.gsrdelay'].should == '10'
- @plugin["network"]["settings"]['net.inet6.mld.v1enable'].should == '1'
- @plugin["network"]["settings"]['net.inet6.mld.use_allow'].should == '1'
- @plugin["network"]["settings"]['net.inet6.mld.debug'].should == '0'
- @plugin["network"]["settings"]['net.idle.route.expire_timeout'].should == '30'
- @plugin["network"]["settings"]['net.idle.route.drain_interval'].should == '10'
- @plugin["network"]["settings"]['net.statistics'].should == '1'
- @plugin["network"]["settings"]['net.alf.loglevel'].should == '55'
- @plugin["network"]["settings"]['net.alf.perm'].should == '0'
- @plugin["network"]["settings"]['net.alf.defaultaction'].should == '1'
- @plugin["network"]["settings"]['net.alf.mqcount'].should == '0'
- @plugin["network"]["settings"]['net.smb.fs.version'].should == '107000'
- @plugin["network"]["settings"]['net.smb.fs.loglevel'].should == '0'
- @plugin["network"]["settings"]['net.smb.fs.kern_ntlmssp'].should == '0'
- @plugin["network"]["settings"]['net.smb.fs.kern_deprecatePreXPServers'].should == '1'
- @plugin["network"]["settings"]['net.smb.fs.kern_deadtimer'].should == '60'
- @plugin["network"]["settings"]['net.smb.fs.kern_hard_deadtimer'].should == '600'
- @plugin["network"]["settings"]['net.smb.fs.kern_soft_deadtimer'].should == '30'
- @plugin["network"]["settings"]['net.smb.fs.tcpsndbuf'].should == '261120'
- @plugin["network"]["settings"]['net.smb.fs.tcprcvbuf'].should == '261120'
+ expect(@plugin['network']['settings']['net.local.stream.sendspace']).to eq('8192')
+ expect(@plugin["network"]["settings"]['net.local.stream.recvspace']).to eq('8192')
+ expect(@plugin["network"]["settings"]['net.local.stream.tracemdns']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.local.dgram.maxdgram']).to eq('2048')
+ expect(@plugin["network"]["settings"]['net.local.dgram.recvspace']).to eq('4096')
+ expect(@plugin["network"]["settings"]['net.local.inflight']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.portrange.lowfirst']).to eq('1023')
+ expect(@plugin["network"]["settings"]['net.inet.ip.portrange.lowlast']).to eq('600')
+ expect(@plugin["network"]["settings"]['net.inet.ip.portrange.first']).to eq('49152')
+ expect(@plugin["network"]["settings"]['net.inet.ip.portrange.last']).to eq('65535')
+ expect(@plugin["network"]["settings"]['net.inet.ip.portrange.hifirst']).to eq('49152')
+ expect(@plugin["network"]["settings"]['net.inet.ip.portrange.hilast']).to eq('65535')
+ expect(@plugin["network"]["settings"]['net.inet.ip.forwarding']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.redirect']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.ttl']).to eq('64')
+ expect(@plugin["network"]["settings"]['net.inet.ip.rtexpire']).to eq('12')
+ expect(@plugin["network"]["settings"]['net.inet.ip.rtminexpire']).to eq('10')
+ expect(@plugin["network"]["settings"]['net.inet.ip.rtmaxcache']).to eq('128')
+ expect(@plugin["network"]["settings"]['net.inet.ip.sourceroute']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.intr_queue_maxlen']).to eq('50')
+ expect(@plugin["network"]["settings"]['net.inet.ip.intr_queue_drops']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.accept_sourceroute']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.keepfaith']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.gifttl']).to eq('30')
+ expect(@plugin["network"]["settings"]['net.inet.ip.subnets_are_local']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.mcast.maxgrpsrc']).to eq('512')
+ expect(@plugin["network"]["settings"]['net.inet.ip.mcast.maxsocksrc']).to eq('128')
+ expect(@plugin["network"]["settings"]['net.inet.ip.mcast.loop']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.check_route_selfref']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.use_route_genid']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.hash_size']).to eq('64')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.curr_time']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.ready_heap']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.extract_heap']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.searches']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.search_steps']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.expire']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.max_chain_len']).to eq('16')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.red_lookup_depth']).to eq('256')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.red_avg_pkt_size']).to eq('512')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.red_max_pkt_size']).to eq('1500')
+ expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.enable']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.autoinc_step']).to eq('100')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.one_pass']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.verbose']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.verbose_limit']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_buckets']).to eq('256')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.curr_dyn_buckets']).to eq('256')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_count']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_max']).to eq('4096')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.static_count']).to eq('2')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_ack_lifetime']).to eq('300')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_syn_lifetime']).to eq('20')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_fin_lifetime']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_rst_lifetime']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_udp_lifetime']).to eq('10')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_short_lifetime']).to eq('5')
+ expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_keepalive']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.maxfragpackets']).to eq('1536')
+ expect(@plugin["network"]["settings"]['net.inet.ip.maxfragsperpacket']).to eq('128')
+ expect(@plugin["network"]["settings"]['net.inet.ip.maxfrags']).to eq('3072')
+ expect(@plugin["network"]["settings"]['net.inet.ip.scopedroute']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.check_interface']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.linklocal.in.allowbadttl']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.random_id']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ip.maxchainsent']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ip.select_srcif_debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.icmp.maskrepl']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.icmp.icmplim']).to eq('250')
+ expect(@plugin["network"]["settings"]['net.inet.icmp.timestamp']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.icmp.drop_redirect']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.icmp.log_redirect']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.icmp.bmcastecho']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.recvifkludge']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.sendra']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.sendlocal']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.v1enable']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.v2enable']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.legacysupp']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.default_version']).to eq('3')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.gsrdelay']).to eq('10')
+ expect(@plugin["network"]["settings"]['net.inet.igmp.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rfc1323']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rfc1644']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.mssdflt']).to eq('512')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.keepidle']).to eq('7200000')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.keepintvl']).to eq('75000')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.sendspace']).to eq('65536')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.recvspace']).to eq('65536')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.keepinit']).to eq('75000')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.v6mssdflt']).to eq('1024')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.log_in_vain']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.blackhole']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.delayed_ack']).to eq('3')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.tcp_lq_overflow']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.recvbg']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.drop_synfin']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.reass.maxsegments']).to eq('3072')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.reass.cursegments']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.reass.overflows']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.slowlink_wsize']).to eq('8192')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.maxseg_unacked']).to eq('8')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rfc3465']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rfc3465_lim2']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rtt_samples_per_slot']).to eq('20')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.recv_allowed_iaj']).to eq('5')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.acc_iaj_high_thresh']).to eq('100')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rexmt_thresh']).to eq('2')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.path_mtu_discovery']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.slowstart_flightsize']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.local_slowstart_flightsize']).to eq('8')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.tso']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.ecn_initiate_out']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.ecn_negotiate_in']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.packetchain']).to eq('50')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.socket_unlocked_on_output']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rfc3390']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.min_iaj_win']).to eq('4')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.acc_iaj_react_limit']).to eq('200')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.sack']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.sack_maxholes']).to eq('128')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.sack_globalmaxholes']).to eq('65536')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.sack_globalholes']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.minmss']).to eq('216')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.minmssoverload']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.do_tcpdrain']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.pcbcount']).to eq('86')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.icmp_may_rst']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.strict_rfc1948']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.isn_reseed_interval']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.background_io_enabled']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rtt_min']).to eq('100')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.rexmt_slop']).to eq('200')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.randomize_ports']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.newreno_sockets']).to eq('81')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.background_sockets']).to eq('-1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.tcbhashsize']).to eq('4096')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.background_io_trigger']).to eq('5')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.msl']).to eq('15000')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.max_persist_timeout']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.always_keepalive']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.timer_fastmode_idlemax']).to eq('20')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.broken_peer_syn_rxmit_thres']).to eq('7')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.tcp_timer_advanced']).to eq('5')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.tcp_resched_timerlist']).to eq('12209')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.pmtud_blackhole_detection']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.pmtud_blackhole_mss']).to eq('1200')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.timer_fastquantum']).to eq('100')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.timer_slowquantum']).to eq('500')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.win_scale_factor']).to eq('3')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.sockthreshold']).to eq('64')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.bg_target_qdelay']).to eq('100')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.bg_allowed_increase']).to eq('2')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.bg_tether_shift']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.tcp.bg_ss_fltsz']).to eq('2')
+ expect(@plugin["network"]["settings"]['net.inet.udp.checksum']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.udp.maxdgram']).to eq('9216')
+ expect(@plugin["network"]["settings"]['net.inet.udp.recvspace']).to eq('42080')
+ expect(@plugin["network"]["settings"]['net.inet.udp.log_in_vain']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.udp.blackhole']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.udp.pcbcount']).to eq('72')
+ expect(@plugin["network"]["settings"]['net.inet.udp.randomize_ports']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.def_policy']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.esp_trans_deflev']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.esp_net_deflev']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.ah_trans_deflev']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.ah_net_deflev']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.ah_cleartos']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.ah_offsetmask']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.dfbit']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.ecn']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.esp_randpad']).to eq('-1')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.bypass']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet.ipsec.esp_port']).to eq('4500')
+ expect(@plugin["network"]["settings"]['net.inet.raw.maxdgram']).to eq('8192')
+ expect(@plugin["network"]["settings"]['net.inet.raw.recvspace']).to eq('8192')
+ expect(@plugin["network"]["settings"]['net.link.generic.system.ifcount']).to eq('10')
+ expect(@plugin["network"]["settings"]['net.link.generic.system.dlil_verbose']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.link.generic.system.multi_threaded_input']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.link.generic.system.dlil_input_sanity_check']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.prune_intvl']).to eq('300')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.max_age']).to eq('1200')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.host_down_time']).to eq('20')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.apple_hwcksum_tx']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.apple_hwcksum_rx']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.arp_llreach_base']).to eq('30')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.maxtries']).to eq('5')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.useloopback']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.proxyall']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.sendllconflict']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.log_arp_warnings']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.keep_announcements']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.link.ether.inet.send_conflicting_probes']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.link.bridge.log_stp']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.link.bridge.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.key.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.key.spi_trycnt']).to eq('1000')
+ expect(@plugin["network"]["settings"]['net.key.spi_minval']).to eq('256')
+ expect(@plugin["network"]["settings"]['net.key.spi_maxval']).to eq('268435455')
+ expect(@plugin["network"]["settings"]['net.key.int_random']).to eq('60')
+ expect(@plugin["network"]["settings"]['net.key.larval_lifetime']).to eq('30')
+ expect(@plugin["network"]["settings"]['net.key.blockacq_count']).to eq('10')
+ expect(@plugin["network"]["settings"]['net.key.blockacq_lifetime']).to eq('20')
+ expect(@plugin["network"]["settings"]['net.key.esp_keymin']).to eq('256')
+ expect(@plugin["network"]["settings"]['net.key.esp_auth']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.key.ah_keymin']).to eq('128')
+ expect(@plugin["network"]["settings"]['net.key.prefered_oldsa']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.key.natt_keepalive_interval']).to eq('20')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.forwarding']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.redirect']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.hlim']).to eq('64')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.maxfragpackets']).to eq('1536')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.accept_rtadv']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.keepfaith']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.log_interval']).to eq('5')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.hdrnestlimit']).to eq('15')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.dad_count']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.auto_flowlabel']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.defmcasthlim']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.gifhlim']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.kame_version']).to eq('2009/apple-darwin')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.use_deprecated']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.rr_prune']).to eq('5')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.v6only']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.rtexpire']).to eq('3600')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.rtminexpire']).to eq('10')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.rtmaxcache']).to eq('128')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.use_tempaddr']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.temppltime']).to eq('86400')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.tempvltime']).to eq('604800')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.auto_linklocal']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.prefer_tempaddr']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.use_defaultzone']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.maxfrags']).to eq('12288')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.mcast_pmtu']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.neighborgcthresh']).to eq('1024')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.maxifprefixes']).to eq('16')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.maxifdefrouters']).to eq('16')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.maxdynroutes']).to eq('1024')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.fw.enable']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.fw.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.fw.verbose']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.fw.verbose_limit']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.scopedroute']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.select_srcif_debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.mcast.maxgrpsrc']).to eq('512')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.mcast.maxsocksrc']).to eq('128')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.mcast.loop']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ip6.only_allow_rfc4193_prefixes']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ipsec6.def_policy']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ipsec6.esp_trans_deflev']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ipsec6.esp_net_deflev']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ipsec6.ah_trans_deflev']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ipsec6.ah_net_deflev']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.ipsec6.ecn']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ipsec6.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.ipsec6.esp_randpad']).to eq('-1')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.rediraccept']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.redirtimeout']).to eq('600')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_prune']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_delay']).to eq('5')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_umaxtries']).to eq('3')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_mmaxtries']).to eq('3')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_useloopback']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nodeinfo']).to eq('3')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.errppslimit']).to eq('500')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_maxnudhint']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_accept_6to4']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_onlink_ns_rfc4861']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_llreach_base']).to eq('30')
+ expect(@plugin["network"]["settings"]['net.inet6.mld.gsrdelay']).to eq('10')
+ expect(@plugin["network"]["settings"]['net.inet6.mld.v1enable']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.mld.use_allow']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.inet6.mld.debug']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.idle.route.expire_timeout']).to eq('30')
+ expect(@plugin["network"]["settings"]['net.idle.route.drain_interval']).to eq('10')
+ expect(@plugin["network"]["settings"]['net.statistics']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.alf.loglevel']).to eq('55')
+ expect(@plugin["network"]["settings"]['net.alf.perm']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.alf.defaultaction']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.alf.mqcount']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.smb.fs.version']).to eq('107000')
+ expect(@plugin["network"]["settings"]['net.smb.fs.loglevel']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.smb.fs.kern_ntlmssp']).to eq('0')
+ expect(@plugin["network"]["settings"]['net.smb.fs.kern_deprecatePreXPServers']).to eq('1')
+ expect(@plugin["network"]["settings"]['net.smb.fs.kern_deadtimer']).to eq('60')
+ expect(@plugin["network"]["settings"]['net.smb.fs.kern_hard_deadtimer']).to eq('600')
+ expect(@plugin["network"]["settings"]['net.smb.fs.kern_soft_deadtimer']).to eq('30')
+ expect(@plugin["network"]["settings"]['net.smb.fs.tcpsndbuf']).to eq('261120')
+ expect(@plugin["network"]["settings"]['net.smb.fs.tcprcvbuf']).to eq('261120')
end
end
end
diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb
index bae1ca72..aef55edd 100644
--- a/spec/unit/plugins/darwin/platform_spec.rb
+++ b/spec/unit/plugins/darwin/platform_spec.rb
@@ -22,51 +22,51 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Darwin plugin platform" do
before(:each) do
@plugin = get_plugin("darwin/platform")
- @plugin.stub(:collect_os).and_return(:darwin)
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
@stdout = "ProductName: Mac OS X\nProductVersion: 10.5.5\nBuildVersion: 9F33"
- @plugin.stub(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run sw_vers" do
- @plugin.should_receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set platform to ProductName, downcased with _ for \\s" do
@plugin.run
- @plugin[:platform].should == "mac_os_x"
+ expect(@plugin[:platform]).to eq("mac_os_x")
end
it "should set platform_version to ProductVersion" do
@plugin.run
- @plugin[:platform_version].should == "10.5.5"
+ expect(@plugin[:platform_version]).to eq("10.5.5")
end
it "should set platform_build to BuildVersion" do
@plugin.run
- @plugin[:platform_build].should == "9F33"
+ expect(@plugin[:platform_build]).to eq("9F33")
end
it "should set platform_family to mac_os_x" do
@plugin.run
- @plugin[:platform_family].should == "mac_os_x"
+ expect(@plugin[:platform_family]).to eq("mac_os_x")
end
describe "on os x server" do
before(:each) do
@plugin[:os] = "darwin"
@stdout = "ProductName: Mac OS X Server\nProductVersion: 10.6.8\nBuildVersion: 10K549"
- @plugin.stub(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
end
it "should set platform to mac_os_x_server" do
@plugin.run
- @plugin[:platform].should == "mac_os_x_server"
+ expect(@plugin[:platform]).to eq("mac_os_x_server")
end
it "should set platform_family to mac_os_x" do
@plugin.run
- @plugin[:platform_family].should == "mac_os_x"
+ expect(@plugin[:platform_family]).to eq("mac_os_x")
end
end
end
diff --git a/spec/unit/plugins/darwin/system_profiler_spec.rb b/spec/unit/plugins/darwin/system_profiler_spec.rb
index 5efad018..af2b463d 100644
--- a/spec/unit/plugins/darwin/system_profiler_spec.rb
+++ b/spec/unit/plugins/darwin/system_profiler_spec.rb
@@ -29,7 +29,7 @@ end
describe Ohai::System, "Darwin system_profiler plugin", :unix_only do
before(:each) do
@plugin = get_plugin("darwin/system_profiler")
- @plugin.stub(:collect_os).and_return(:darwin)
+ allow(@plugin).to receive(:collect_os).and_return(:darwin)
end
it "should return the right serial number" do
@@ -39,9 +39,9 @@ describe Ohai::System, "Darwin system_profiler plugin", :unix_only do
mini_cmd += " SPPCIData SPParallelSCSIData SPPrintersSoftwareData SPPrintersData SPSASData SPSerialATAData"
mini_cmd += " SPSoftwareData SPThunderboltData SPUSBData SPWWANData SPAirPortData"
full_cmd = "system_profiler -xml -detailLevel full SPHardwareDataType"
- @plugin.stub(:shell_out).with(full_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Full, ""))
- @plugin.stub(:shell_out).with(mini_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Mini, ""))
+ allow(@plugin).to receive(:shell_out).with(full_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Full, ""))
+ allow(@plugin).to receive(:shell_out).with(mini_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Mini, ""))
@plugin.run
- @plugin['system_profile'][18]["_items"][0]["serial_number"].should == 'ABCDEFG12345'
+ expect(@plugin['system_profile'][18]["_items"][0]["serial_number"]).to eq('ABCDEFG12345')
end
end
diff --git a/spec/unit/plugins/dmi_spec.rb b/spec/unit/plugins/dmi_spec.rb
index 9d75e066..6afe3e38 100644
--- a/spec/unit/plugins/dmi_spec.rb
+++ b/spec/unit/plugins/dmi_spec.rb
@@ -95,11 +95,11 @@ describe Ohai::System, "plugin dmi" do
before(:each) do
@plugin = get_plugin("dmi")
@stdout = DMI_OUT
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run dmidecode" do
- @plugin.should_receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
@@ -121,7 +121,7 @@ describe Ohai::System, "plugin dmi" do
data.each do |attribute, value|
it "should have [:dmi][:#{id}][:#{attribute}] set" do
@plugin.run
- @plugin[:dmi][id][attribute].should eql(value)
+ expect(@plugin[:dmi][id][attribute]).to eql(value)
end
end
end
diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb
index 0997dc28..3dc90e57 100644
--- a/spec/unit/plugins/ec2_spec.rb
+++ b/spec/unit/plugins/ec2_spec.rb
@@ -24,13 +24,13 @@ describe Ohai::System, "plugin ec2" do
before(:each) do
@plugin = get_plugin("ec2")
@plugin[:network] = {:interfaces => {:eth0 => {} } }
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
end
shared_examples_for "!ec2" do
it "should NOT attempt to fetch the ec2 metadata" do
- @plugin.should_not_receive(:http_client)
+ expect(@plugin).not_to receive(:http_client)
@plugin.run
end
end
@@ -38,196 +38,196 @@ describe Ohai::System, "plugin ec2" do
shared_examples_for "ec2" do
before(:each) do
@http_client = double("Net::HTTP client")
- @plugin.stub(:http_client).and_return(@http_client)
- IO.stub(:select).and_return([[],[1],[]])
+ allow(@plugin).to receive(:http_client).and_return(@http_client)
+ allow(IO).to receive(:select).and_return([[],[1],[]])
t = double("connection")
- t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
- Socket.stub(:new).and_return(t)
- @http_client.should_receive(:get).
+ allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
+ allow(Socket).to receive(:new).and_return(t)
+ expect(@http_client).to receive(:get).
with("/").twice.
and_return(double("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
- File.stub(:exist?).and_return(false)
+ allow(File).to receive(:exist?).and_return(false)
end
it "should recursively fetch all the ec2 metadata" do
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/").
and_return(double("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/instance_type").
and_return(double("Net::HTTP Response", :body => "c1.medium", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/ami_id").
and_return(double("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/security-groups").
and_return(double("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/user-data/").
and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
- @plugin[:ec2].should_not be_nil
- @plugin[:ec2]['instance_type'].should == "c1.medium"
- @plugin[:ec2]['ami_id'].should == "ami-5d2dc934"
- @plugin[:ec2]['security_groups'].should eql ['group1', 'group2']
+ expect(@plugin[:ec2]).not_to be_nil
+ expect(@plugin[:ec2]['instance_type']).to eq("c1.medium")
+ expect(@plugin[:ec2]['ami_id']).to eq("ami-5d2dc934")
+ expect(@plugin[:ec2]['security_groups']).to eql ['group1', 'group2']
end
it "should parse ec2 network/ directory as a multi-level hash" do
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/").
and_return(double("Net::HTTP Response", :body => "network/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/network/").
and_return(double("Net::HTTP Response", :body => "interfaces/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/network/interfaces/").
and_return(double("Net::HTTP Response", :body => "macs/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/network/interfaces/macs/").
and_return(double("Net::HTTP Response", :body => "12:34:56:78:9a:bc/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/network/interfaces/macs/12:34:56:78:9a:bc/").
and_return(double("Net::HTTP Response", :body => "public_hostname", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/network/interfaces/macs/12:34:56:78:9a:bc/public_hostname").
and_return(double("Net::HTTP Response", :body => "server17.opscode.com", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/user-data/").
and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
- @plugin[:ec2].should_not be_nil
- @plugin[:ec2]['network_interfaces_macs']['12:34:56:78:9a:bc']['public_hostname'].should eql('server17.opscode.com')
+ expect(@plugin[:ec2]).not_to be_nil
+ expect(@plugin[:ec2]['network_interfaces_macs']['12:34:56:78:9a:bc']['public_hostname']).to eql('server17.opscode.com')
end
context "with ec2_iam cloud file" do
before do
if windows?
- File.stub(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/iam.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/iam.json').and_return('')
else
- File.stub(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/iam.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/iam.json').and_return('')
end
end
it "should parse ec2 iam/ directory and collect iam/security-credentials/" do
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/").
and_return(double("Net::HTTP Response", :body => "iam/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/iam/").
and_return(double("Net::HTTP Response", :body => "security-credentials/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/iam/security-credentials/").
and_return(double("Net::HTTP Response", :body => "MyRole", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/iam/security-credentials/MyRole").
and_return(double("Net::HTTP Response", :body => "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/user-data/").
and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
- @plugin[:ec2].should_not be_nil
- @plugin[:ec2]['iam']['security-credentials']['MyRole']['Code'].should eql 'Success'
- @plugin[:ec2]['iam']['security-credentials']['MyRole']['Token'].should eql '12345678'
+ expect(@plugin[:ec2]).not_to be_nil
+ expect(@plugin[:ec2]['iam']['security-credentials']['MyRole']['Code']).to eql 'Success'
+ expect(@plugin[:ec2]['iam']['security-credentials']['MyRole']['Token']).to eql '12345678'
end
end
context "without ec2_iam cloud file" do
before do
if windows?
- File.stub(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(false)
else
- File.stub(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(false)
end
end
it "should parse ec2 iam/ directory and NOT collect iam/security-credentials/" do
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/").
and_return(double("Net::HTTP Response", :body => "iam/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/iam/").
and_return(double("Net::HTTP Response", :body => "security-credentials/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/iam/security-credentials/").
and_return(double("Net::HTTP Response", :body => "MyRole", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/iam/security-credentials/MyRole").
and_return(double("Net::HTTP Response", :body => "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/user-data/").
and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
- @plugin[:ec2].should_not be_nil
- @plugin[:ec2]['iam'].should be_nil
+ expect(@plugin[:ec2]).not_to be_nil
+ expect(@plugin[:ec2]['iam']).to be_nil
end
end
it "should ignore \"./\" and \"../\" on ec2 metadata paths to avoid infinity loops" do
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/").
and_return(double("Net::HTTP Response", :body => ".\n./\n..\n../\npath1/.\npath2/./\npath3/..\npath4/../", :code => "200"))
- @http_client.should_not_receive(:get).
+ expect(@http_client).not_to receive(:get).
with("/2012-01-12/meta-data/.")
- @http_client.should_not_receive(:get).
+ expect(@http_client).not_to receive(:get).
with("/2012-01-12/meta-data/./")
- @http_client.should_not_receive(:get).
+ expect(@http_client).not_to receive(:get).
with("/2012-01-12/meta-data/..")
- @http_client.should_not_receive(:get).
+ expect(@http_client).not_to receive(:get).
with("/2012-01-12/meta-data/../")
- @http_client.should_not_receive(:get).
+ expect(@http_client).not_to receive(:get).
with("/2012-01-12/meta-data/path1/..")
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/path1/").
and_return(double("Net::HTTP Response", :body => "", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/path2/").
and_return(double("Net::HTTP Response", :body => "", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/path3/").
and_return(double("Net::HTTP Response", :body => "", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/path4/").
and_return(double("Net::HTTP Response", :body => "", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/user-data/").
and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
- @plugin[:ec2].should_not be_nil
+ expect(@plugin[:ec2]).not_to be_nil
end
it "should complete the run despite unavailable metadata" do
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/").
and_return(double("Net::HTTP Response", :body => "metrics/", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/metrics/").
and_return(double("Net::HTTP Response", :body => "vhostmd", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/metrics/vhostmd").
and_return(double("Net::HTTP Response", :body => "", :code => "404"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/user-data/").
and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
- @plugin[:ec2].should_not be_nil
- @plugin[:ec2]['metrics'].should be_nil
- @plugin[:ec2]['metrics_vhostmd'].should be_nil
+ expect(@plugin[:ec2]).not_to be_nil
+ expect(@plugin[:ec2]['metrics']).to be_nil
+ expect(@plugin[:ec2]['metrics_vhostmd']).to be_nil
end
end
@@ -235,7 +235,7 @@ describe Ohai::System, "plugin ec2" do
it_should_behave_like "ec2"
before(:each) do
- IO.stub(:select).and_return([[],[1],[]])
+ allow(IO).to receive(:select).and_return([[],[1],[]])
@plugin[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"fe:ff:ff:ff:ff:ff"}
end
end
@@ -253,11 +253,11 @@ describe Ohai::System, "plugin ec2" do
before(:each) do
if windows?
- File.should_receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
+ expect(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
else
- File.should_receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
+ expect(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
end
end
end
@@ -266,8 +266,8 @@ describe Ohai::System, "plugin ec2" do
it_should_behave_like "!ec2"
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
end
end
@@ -275,13 +275,13 @@ describe Ohai::System, "plugin ec2" do
it_should_behave_like "!ec2"
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
- File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
- File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
end
end
diff --git a/spec/unit/plugins/erlang_spec.rb b/spec/unit/plugins/erlang_spec.rb
index c017e1ce..ccda18aa 100644
--- a/spec/unit/plugins/erlang_spec.rb
+++ b/spec/unit/plugins/erlang_spec.rb
@@ -25,36 +25,36 @@ describe Ohai::System, "plugin erlang" do
@plugin = get_plugin("erlang")
@plugin[:languages] = Mash.new
@stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n"
- @plugin.stub(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr))
+ allow(@plugin).to receive(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr))
end
it "should get the erlang version from erl +V" do
- @plugin.should_receive(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr))
+ expect(@plugin).to receive(:shell_out).with("erl +V").and_return(mock_shell_out(0, "", @stderr))
@plugin.run
end
it "should set languages[:erlang][:version]" do
@plugin.run
- @plugin.languages[:erlang][:version].should eql("5.6.2")
+ expect(@plugin.languages[:erlang][:version]).to eql("5.6.2")
end
it "should set languages[:erlang][:options]" do
@plugin.run
- @plugin.languages[:erlang][:options].should eql(["ASYNC_THREADS", "SMP", "HIPE"])
+ expect(@plugin.languages[:erlang][:options]).to eql(["ASYNC_THREADS", "SMP", "HIPE"])
end
it "should set languages[:erlang][:emulator]" do
@plugin.run
- @plugin.languages[:erlang][:emulator].should eql("BEAM")
+ expect(@plugin.languages[:erlang][:emulator]).to eql("BEAM")
end
it "should not set the languages[:erlang] tree up if erlang command fails" do
@status = 1
@stdin = ""
@stderr = "Erlang (ASYNC_THREADS,SMP,HIPE) (BEAM) emulator version 5.6.2\n"
- @plugin.stub(:shell_out).with("erl +V").and_return(mock_shell_out(1, "", @stderr))
+ allow(@plugin).to receive(:shell_out).with("erl +V").and_return(mock_shell_out(1, "", @stderr))
@plugin.run
- @plugin.languages.should_not have_key(:erlang)
+ expect(@plugin.languages).not_to have_key(:erlang)
end
end
diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb
index f0dcd600..5da48780 100644
--- a/spec/unit/plugins/eucalyptus_spec.rb
+++ b/spec/unit/plugins/eucalyptus_spec.rb
@@ -27,7 +27,7 @@ describe Ohai::System, "plugin eucalyptus" do
shared_examples_for "!eucalyptus" do
it "should NOT attempt to fetch the eucalyptus metadata" do
- OpenURI.should_not_receive(:open)
+ expect(OpenURI).not_to receive(:open)
@plugin.run
end
end
@@ -35,38 +35,38 @@ describe Ohai::System, "plugin eucalyptus" do
shared_examples_for "eucalyptus" do
before(:each) do
@http_client = double("Net::HTTP client")
- @plugin.stub(:http_client).and_return(@http_client)
+ allow(@plugin).to receive(:http_client).and_return(@http_client)
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/").twice.
and_return(double("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/").
and_return(double("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/instance_type").
and_return(double("Net::HTTP Response", :body => "c1.medium", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/ami_id").
and_return(double("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/meta-data/security-groups").
and_return(double("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/2012-01-12/user-data/").
and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
end
it "should recursively fetch all the eucalyptus metadata" do
- IO.stub(:select).and_return([[],[1],[]])
+ allow(IO).to receive(:select).and_return([[],[1],[]])
t = double("connection")
- t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
- Socket.stub(:new).and_return(t)
+ allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
+ allow(Socket).to receive(:new).and_return(t)
@plugin.run
- @plugin[:eucalyptus].should_not be_nil
- @plugin[:eucalyptus]['instance_type'].should == "c1.medium"
- @plugin[:eucalyptus]['ami_id'].should == "ami-5d2dc934"
- @plugin[:eucalyptus]['security_groups'].should eql ['group1', 'group2']
+ expect(@plugin[:eucalyptus]).not_to be_nil
+ expect(@plugin[:eucalyptus]['instance_type']).to eq("c1.medium")
+ expect(@plugin[:eucalyptus]['ami_id']).to eq("ami-5d2dc934")
+ expect(@plugin[:eucalyptus]['security_groups']).to eql ['group1', 'group2']
end
end
@@ -74,7 +74,7 @@ describe Ohai::System, "plugin eucalyptus" do
it_should_behave_like "eucalyptus"
before(:each) do
- IO.stub(:select).and_return([[],[1],[]])
+ allow(IO).to receive(:select).and_return([[],[1],[]])
@plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED"=> { "family" => "lladdr" } } } } }
end
end
@@ -91,10 +91,10 @@ describe Ohai::System, "plugin eucalyptus" do
it_should_behave_like "eucalyptus"
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/eucalyptus.json').and_return('')
- File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/eucalyptus.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return('')
end
end
@@ -103,8 +103,8 @@ describe Ohai::System, "plugin eucalyptus" do
before(:each) do
@plugin[:network] = {:interfaces => {}}
- File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
end
end
@@ -114,12 +114,12 @@ describe Ohai::System, "plugin eucalyptus" do
before(:each) do
@plugin[:network] = {:interfaces => {}}
- File.stub(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
- File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
end
end
diff --git a/spec/unit/plugins/fail_spec.rb b/spec/unit/plugins/fail_spec.rb
index de77c6f2..10019f81 100644
--- a/spec/unit/plugins/fail_spec.rb
+++ b/spec/unit/plugins/fail_spec.rb
@@ -56,16 +56,16 @@ shared_examples "a v7 loading failure" do
it "should not have attribute keys" do
@loader.load_plugin("#{tmp}/plugins/fail.rb")
#@ohai.attributes.should_not have_key("fail")
- lambda { @ohai.provides_map.find_providers_for(["fail"]) }.should raise_error(Ohai::Exceptions::AttributeNotFound)
+ expect { @ohai.provides_map.find_providers_for(["fail"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound)
end
it "should not have source key" do
@loader.load_plugin("#{tmp}/plugins/fail.rb")
- @ohai.v6_dependency_solver.should_not have_key("#{tmp}/plugins/fail.rb")
+ expect(@ohai.v6_dependency_solver).not_to have_key("#{tmp}/plugins/fail.rb")
end
it "should write to Ohai::Log" do
- Ohai::Log.should_receive(:warn).once
+ expect(Ohai::Log).to receive(:warn).once
@loader.load_plugin("#{tmp}/plugins/fail.rb")
end
end
@@ -104,16 +104,16 @@ shared_examples "a v7 loading success" do
it "should have attribute keys" do
@loader.load_plugin("#{tmp}/plugins/fail.rb")
- @ohai.provides_map.should have_key("fail")
+ expect(@ohai.provides_map).to have_key("fail")
end
it "should have source key" do
@loader.load_plugin("#{tmp}/plugins/fail.rb")
- @ohai.v6_dependency_solver.should have_key("#{tmp}/plugins/fail.rb")
+ expect(@ohai.v6_dependency_solver).to have_key("#{tmp}/plugins/fail.rb")
end
it "should not write to Ohai::Log" do
- Ohai::Log.should_not_receive(:warn)
+ expect(Ohai::Log).not_to receive(:warn)
@loader.load_plugin("#{tmp}/plugins/fail.rb")
end
end
@@ -152,11 +152,11 @@ shared_examples "a v7 run failure" do
it "should not have new attribute keys" do
@loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
- @ohai.provides_map.should_not have_key("other")
+ expect(@ohai.provides_map).not_to have_key("other")
end
it "should write to Ohai::Log" do
- Ohai::Log.should_receive(:warn).once
+ expect(Ohai::Log).to receive(:warn).once
@loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
end
end
diff --git a/spec/unit/plugins/freebsd/cpu_spec.rb b/spec/unit/plugins/freebsd/cpu_spec.rb
index c988d897..e70f0cc8 100644
--- a/spec/unit/plugins/freebsd/cpu_spec.rb
+++ b/spec/unit/plugins/freebsd/cpu_spec.rb
@@ -21,10 +21,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "FreeBSD cpu plugin" do
before(:each) do
@plugin = get_plugin("freebsd/cpu")
- @plugin.stub(:collect_os).and_return(:freebsd)
- @plugin.stub(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
@double_file = double("/var/run/dmesg.boot")
- @double_file.stub(:each).
+ allow(@double_file).to receive(:each).
and_yield('CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz (3516.61-MHz K8-class CPU)').
and_yield(' Origin = "GenuineIntel" Id = 0x306a9 Family = 6 Model = 3a Stepping = 9').
and_yield(' Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>').
@@ -32,37 +32,37 @@ describe Ohai::System, "FreeBSD cpu plugin" do
and_yield(' AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>').
and_yield(' AMD Features2=0x1<LAHF>').
and_yield(' TSC: P-state invariant')
- File.stub(:open).with("/var/run/dmesg.boot").and_return(@double_file)
+ allow(File).to receive(:open).with("/var/run/dmesg.boot").and_return(@double_file)
end
it "detects all CPU flags" do
@plugin.run
- @plugin[:cpu][:flags].should == %w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 mon ssse3 syscall nx rdtscp lm lahf}
+ expect(@plugin[:cpu][:flags]).to eq(%w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 mon ssse3 syscall nx rdtscp lm lahf})
end
it "detects all CPU model_name" do
@plugin.run
- @plugin[:cpu][:model_name].should == "Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz"
+ expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz")
end
it "detects all CPU mhz" do
@plugin.run
- @plugin[:cpu][:mhz].should == "3516.61"
+ expect(@plugin[:cpu][:mhz]).to eq("3516.61")
end
it "detects all CPU vendor_id" do
@plugin.run
- @plugin[:cpu][:vendor_id].should == "GenuineIntel"
+ expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
end
it "detects all CPU stepping" do
@plugin.run
- @plugin[:cpu][:stepping].should == "9"
+ expect(@plugin[:cpu][:stepping]).to eq("9")
end
it "detects all CPU total" do
@plugin.run
- @plugin[:cpu][:total].should == 2
+ expect(@plugin[:cpu][:total]).to eq(2)
end
end
diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb
index 9e5e5a4c..cbbb82a8 100644
--- a/spec/unit/plugins/freebsd/hostname_spec.rb
+++ b/spec/unit/plugins/freebsd/hostname_spec.rb
@@ -22,10 +22,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "FreeBSD hostname plugin" do
before(:each) do
@plugin = get_plugin("hostname")
- @plugin.stub(:collect_os).and_return(:freebsd)
- @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
- @plugin.stub(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", ""))
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
+ allow(@plugin).to receive(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", ""))
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
end
it_should_check_from("freebsd::hostname", "hostname", "hostname -s", "katie")
diff --git a/spec/unit/plugins/freebsd/kernel_spec.rb b/spec/unit/plugins/freebsd/kernel_spec.rb
index ccfb19d7..cb08500e 100644
--- a/spec/unit/plugins/freebsd/kernel_spec.rb
+++ b/spec/unit/plugins/freebsd/kernel_spec.rb
@@ -22,16 +22,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "FreeBSD kernel plugin" do
before(:each) do
@plugin = get_plugin("kernel")
- @plugin.stub(:collect_os).and_return(:freebsd)
- @plugin.stub(:init_kernel).and_return({:name => "freebsd"})
- @plugin.stub(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", ""))
- @plugin.stub(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", ""))
- @plugin.stub(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(@plugin).to receive(:init_kernel).and_return({:name => "freebsd"})
+ allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", ""))
+ allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
end
it "should set the kernel_os to the kernel_name value" do
@plugin.run
- @plugin[:kernel][:os].should == @plugin[:kernel][:name]
+ expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
end
end
diff --git a/spec/unit/plugins/freebsd/os_spec.rb b/spec/unit/plugins/freebsd/os_spec.rb
index 65be7890..bbc9b6b8 100644
--- a/spec/unit/plugins/freebsd/os_spec.rb
+++ b/spec/unit/plugins/freebsd/os_spec.rb
@@ -22,12 +22,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "FreeBSD plugin os" do
before(:each) do
@plugin = get_plugin("freebsd/os")
- @plugin.stub(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
- @plugin.stub(:collect_os).and_return(:freebsd)
+ allow(@plugin).to receive(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
end
it "should set os_version to __FreeBSD_version" do
@plugin.run
- @plugin[:os_version].should == "902001"
+ expect(@plugin[:os_version]).to eq("902001")
end
end
diff --git a/spec/unit/plugins/freebsd/platform_spec.rb b/spec/unit/plugins/freebsd/platform_spec.rb
index a38db60e..281face5 100644
--- a/spec/unit/plugins/freebsd/platform_spec.rb
+++ b/spec/unit/plugins/freebsd/platform_spec.rb
@@ -22,18 +22,18 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "FreeBSD plugin platform" do
before(:each) do
@plugin = get_plugin("freebsd/platform")
- @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "FreeBSD\n", ""))
- @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", ""))
- @plugin.stub(:collect_os).and_return(:freebsd)
+ allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "FreeBSD\n", ""))
+ allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
end
it "should set platform to lowercased lsb[:id]" do
@plugin.run
- @plugin[:platform].should == "freebsd"
+ expect(@plugin[:platform]).to eq("freebsd")
end
it "should set platform_version to lsb[:release]" do
@plugin.run
- @plugin[:platform_version].should == "7.1"
+ expect(@plugin[:platform_version]).to eq("7.1")
end
end
diff --git a/spec/unit/plugins/freebsd/virtualization_spec.rb b/spec/unit/plugins/freebsd/virtualization_spec.rb
index a2c374f1..dbd0d3f8 100644
--- a/spec/unit/plugins/freebsd/virtualization_spec.rb
+++ b/spec/unit/plugins/freebsd/virtualization_spec.rb
@@ -21,28 +21,28 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "FreeBSD virtualization plugin" do
before(:each) do
@plugin = get_plugin("freebsd/virtualization")
- @plugin.stub(:collect_os).and_return(:freebsd)
- @plugin.stub(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("jls -n").and_return(mock_shell_out(0, "",""))
- @plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:freebsd)
+ allow(@plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", ""))
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("jls -n").and_return(mock_shell_out(0, "",""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", ""))
end
context "jails" do
it "detects we are in a jail" do
- @plugin.stub(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "1", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "1", ""))
@plugin.run
- @plugin[:virtualization][:system].should == "jail"
- @plugin[:virtualization][:role].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("jail")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
end
it "detects we are hosting jails" do
# from http://www.freebsd.org/doc/handbook/jails-application.html
@jails = "JID IP Address Hostname Path\n 3 192.168.3.17 ns.example.org /home/j/ns\n 2 192.168.3.18 mail.example.org /home/j/mail\n 1 62.123.43.14 www.example.org /home/j/www"
- @plugin.stub(:shell_out).with("jls -n").and_return(mock_shell_out(0, @jails, ""))
+ allow(@plugin).to receive(:shell_out).with("jls -n").and_return(mock_shell_out(0, @jails, ""))
@plugin.run
- @plugin[:virtualization][:system].should == "jail"
- @plugin[:virtualization][:role].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("jail")
+ expect(@plugin[:virtualization][:role]).to eq("host")
end
end
@@ -53,13 +53,13 @@ Id Refs Address Size Name
1 40 0xffffffff80100000 d20428 kernel
7 3 0xffffffff81055000 41e88 vboxguest.ko
OUT
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path("/sbin/kldstat")}").and_return(mock_shell_out(0, @vbox_guest, ""))
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path("/sbin/kldstat")}").and_return(mock_shell_out(0, @vbox_guest, ""))
end
it "detects we are a guest" do
@plugin.run
- @plugin[:virtualization][:system].should == "vbox"
- @plugin[:virtualization][:role].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
end
end
@@ -70,23 +70,23 @@ Id Refs Address Size Name
1 40 0xffffffff80100000 d20428 kernel
7 3 0xffffffff81055000 41e88 vboxdrv.ko
OUT
- @plugin.stub(:shell_out).with("/sbin/kldstat").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("/sbin/kldstat").and_return(mock_shell_out(0, @stdout, ""))
end
it "detects we are a host" do
@plugin.run
- @plugin[:virtualization][:system].should == "vbox"
- @plugin[:virtualization][:role].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
+ expect(@plugin[:virtualization][:role]).to eq("host")
end
end
context "when on a QEMU guest" do
it "detects we are a guest" do
[ 'Common KVM processor', 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)', 'Common 32-bit KVM processor'].each do |kvm_string|
- @plugin.stub(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, kvm_string, ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, kvm_string, ""))
@plugin.run
- @plugin[:virtualization][:system].should == "kvm"
- @plugin[:virtualization][:role].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
end
end
end
diff --git a/spec/unit/plugins/gce_spec.rb b/spec/unit/plugins/gce_spec.rb
index c3f7e117..524aa760 100644
--- a/spec/unit/plugins/gce_spec.rb
+++ b/spec/unit/plugins/gce_spec.rb
@@ -25,7 +25,7 @@ describe Ohai::System, "plugin gce" do
shared_examples_for "!gce" do
it "should NOT attempt to fetch the gce metadata" do
- @plugin.should_not_receive(:http_client)
+ expect(@plugin).not_to receive(:http_client)
@plugin.run
end
end
@@ -33,23 +33,23 @@ describe Ohai::System, "plugin gce" do
shared_examples_for "gce" do
before(:each) do
@http_client = double("Net::HTTP client")
- @plugin.stub(:http_client).and_return(@http_client)
- IO.stub(:select).and_return([[],[1],[]])
+ allow(@plugin).to receive(:http_client).and_return(@http_client)
+ allow(IO).to receive(:select).and_return([[],[1],[]])
t = double("connection")
- t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
- Socket.stub(:new).and_return(t)
- Socket.stub(:pack_sockaddr_in).and_return(nil)
+ allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
+ allow(Socket).to receive(:new).and_return(t)
+ allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
end
it "should recursively fetch and properly parse json metadata" do
- @http_client.should_receive(:get).
+ expect(@http_client).to receive(:get).
with("/computeMetadata/v1beta1/?recursive=true/").
and_return(double("Net::HTTP Response", :body => '{"instance":{"hostname":"test-host"}}', :code=>"200"))
@plugin.run
- @plugin[:gce].should_not be_nil
- @plugin[:gce]['instance'].should eq("hostname"=>"test-host")
+ expect(@plugin[:gce]).not_to be_nil
+ expect(@plugin[:gce]['instance']).to eq("hostname"=>"test-host")
end
end
@@ -58,10 +58,10 @@ describe Ohai::System, "plugin gce" do
it_should_behave_like "gce"
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/gce.json').and_return('')
- File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/gce.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/gce.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/gce.json').and_return('')
end
end
@@ -69,15 +69,15 @@ describe Ohai::System, "plugin gce" do
it_should_behave_like "!gce"
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false)
# Raise Errno::ENOENT to simulate the scenario in which metadata server
# can not be connected
t = double("connection")
- t.stub(:connect_nonblock).and_raise(Errno::ENOENT)
- Socket.stub(:new).and_return(t)
- Socket.stub(:pack_sockaddr_in).and_return(nil)
+ allow(t).to receive(:connect_nonblock).and_raise(Errno::ENOENT)
+ allow(Socket).to receive(:new).and_return(t)
+ allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
end
end
diff --git a/spec/unit/plugins/go_spec.rb b/spec/unit/plugins/go_spec.rb
index c6658d8a..cdfbb914 100644
--- a/spec/unit/plugins/go_spec.rb
+++ b/spec/unit/plugins/go_spec.rb
@@ -21,24 +21,24 @@ describe Ohai::System, "plugin go" do
@plugin = get_plugin("go")
@plugin[:languages] = Mash.new
@stdout = "go version go1.1.2 darwin/amd64\n"
- @plugin.stub(:shell_out).with("go version").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("go version").and_return(mock_shell_out(0, @stdout, ""))
end
it "should get the go version" do
- @plugin.should_receive(:shell_out).with("go version").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("go version").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set languages[:go][:version]" do
@plugin.run
- @plugin.languages[:go][:version].should eql("1.1.2")
+ expect(@plugin.languages[:go][:version]).to eql("1.1.2")
end
it "should not set the languages[:go] tree up if go command fails" do
@stdout = "go version go1.1.2 darwin/amd64\n"
- @plugin.stub(:shell_out).with("go version").and_return(mock_shell_out(1, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("go version").and_return(mock_shell_out(1, @stdout, ""))
@plugin.run
- @plugin.languages.should_not have_key(:go)
+ expect(@plugin.languages).not_to have_key(:go)
end
end
diff --git a/spec/unit/plugins/groovy_spec.rb b/spec/unit/plugins/groovy_spec.rb
index 81a1c557..cfd42e55 100644
--- a/spec/unit/plugins/groovy_spec.rb
+++ b/spec/unit/plugins/groovy_spec.rb
@@ -25,23 +25,23 @@ describe Ohai::System, "plugin groovy" do
@plugin = get_plugin("groovy")
@plugin[:languages] = Mash.new
@stdout = "Groovy Version: 1.6.3 JVM: 1.6.0_0\n"
- @plugin.stub(:shell_out).with("groovy -v").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, @stdout, ""))
end
it "should get the groovy version from running groovy -v" do
- @plugin.should_receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set languages[:groovy][:version]" do
@plugin.run
- @plugin.languages[:groovy][:version].should eql("1.6.3")
+ expect(@plugin.languages[:groovy][:version]).to eql("1.6.3")
end
it "should not set the languages[:groovy] tree up if groovy command fails" do
- @plugin.stub(:shell_out).with("groovy -v").and_return(mock_shell_out(1, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("groovy -v").and_return(mock_shell_out(1, @stdout, ""))
@plugin.run
- @plugin.languages.should_not have_key(:groovy)
+ expect(@plugin.languages).not_to have_key(:groovy)
end
end
diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb
index 09c9a33e..c46d6a99 100644
--- a/spec/unit/plugins/hostname_spec.rb
+++ b/spec/unit/plugins/hostname_spec.rb
@@ -22,95 +22,95 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
describe Ohai::System, "hostname plugin" do
before(:each) do
@plugin = get_plugin("hostname")
- @plugin.stub(:collect_os).and_return(:default)
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:default)
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
end
context "when sigar is not installed" do
before(:each) do
- @plugin.stub(:sigar_is_available?).and_return(false)
- @plugin.should_not_receive(:get_fqdn_from_sigar)
- @plugin.stub(:resolve_fqdn).and_return("katie.bethell")
+ allow(@plugin).to receive(:sigar_is_available?).and_return(false)
+ expect(@plugin).not_to receive(:get_fqdn_from_sigar)
+ allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
it "should use #resolve_fqdn to find the fqdn" do
@plugin.run
- @plugin[:fqdn].should == "katie.bethell"
+ expect(@plugin[:fqdn]).to eq("katie.bethell")
end
it "should set the domain to everything after the first dot of the fqdn" do
@plugin.run
- @plugin[:domain].should == "bethell"
+ expect(@plugin[:domain]).to eq("bethell")
end
it "should set the [short] hostname to everything before the first dot of the fqdn" do
@plugin.run
- @plugin[:hostname].should == "katie"
+ expect(@plugin[:hostname]).to eq("katie")
end
end
context "when sigar is installed" do
before(:each) do
- @plugin.stub(:sigar_is_available?).and_return(true)
- @plugin.stub(:get_fqdn_from_sigar).and_return("katie.bethell")
+ allow(@plugin).to receive(:sigar_is_available?).and_return(true)
+ allow(@plugin).to receive(:get_fqdn_from_sigar).and_return("katie.bethell")
end
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
it "should set the fqdn to the returned value from sigar" do
@plugin.run
- @plugin[:fqdn].should == "katie.bethell"
+ expect(@plugin[:fqdn]).to eq("katie.bethell")
end
it "should set the domain to everything after the first dot of the fqdn" do
@plugin.run
- @plugin[:domain].should == "bethell"
+ expect(@plugin[:domain]).to eq("bethell")
end
it "should set the [short] hostname to everything before the first dot of the fqdn" do
@plugin.run
- @plugin[:hostname].should == "katie"
+ expect(@plugin[:hostname]).to eq("katie")
end
end
context "when a system has a bare hostname without a FQDN" do
before(:each) do
- @plugin.stub(:collect_os).and_return(:default)
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:default)
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie", ""))
end
it "should correctly set the [short] hostname" do
@plugin.run
- @plugin[:hostname].should == "katie"
+ expect(@plugin[:hostname]).to eq("katie")
end
end
context "hostname --fqdn when it returns empty string" do
before(:each) do
- @plugin.stub(:collect_os).and_return(:linux)
- @plugin.stub(:shell_out).with("hostname -s").and_return(
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
mock_shell_out(0, "katie", ""))
- @plugin.stub(:shell_out).with("hostname --fqdn").and_return(
+ allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", ""))
end
it "should be called twice" do
@plugin.run
- @plugin[:fqdn].should == "katie.local"
+ expect(@plugin[:fqdn]).to eq("katie.local")
end
end
context "hostname --fqdn when it works" do
before(:each) do
- @plugin.stub(:collect_os).and_return(:linux)
- @plugin.stub(:shell_out).with("hostname -s").and_return(
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
mock_shell_out(0, "katie", ""))
- @plugin.stub(:shell_out).with("hostname --fqdn").and_return(
+ allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
mock_shell_out(0, "katie.local", ""))
end
it "should be not be called twice" do
@plugin.run
- @plugin[:fqdn].should == "katie.local"
+ expect(@plugin[:fqdn]).to eq("katie.local")
end
end
end
diff --git a/spec/unit/plugins/init_package_spec.rb b/spec/unit/plugins/init_package_spec.rb
index 0b19a664..5a64ed13 100644
--- a/spec/unit/plugins/init_package_spec.rb
+++ b/spec/unit/plugins/init_package_spec.rb
@@ -21,7 +21,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_he
describe Ohai::System, "Init package" do
let(:plugin) {
p = get_plugin("init_package")
- p.stub(:collect_os).and_return("linux")
+ allow(p).to receive(:collect_os).and_return("linux")
p
}
@@ -30,13 +30,13 @@ describe Ohai::System, "Init package" do
let(:proc_1_file) { double(proc_1_file_path, :gets => proc1_content) }
before(:each) do
- File.stub(:exists?).with(proc_1_file_path).and_return(true)
- File.stub(:open).with(proc_1_file_path).and_return(proc_1_file)
+ allow(File).to receive(:exists?).with(proc_1_file_path).and_return(true)
+ allow(File).to receive(:open).with(proc_1_file_path).and_return(proc_1_file)
end
it "should set init_package to init" do
plugin.run
- plugin[:init_package].should == "init"
+ expect(plugin[:init_package]).to eq("init")
end
describe "when init_package is systemd" do
@@ -44,7 +44,7 @@ describe Ohai::System, "Init package" do
it "should set init_package to systemd" do
plugin.run
- plugin[:init_package].should == "systemd"
+ expect(plugin[:init_package]).to eq("systemd")
end
end
end
diff --git a/spec/unit/plugins/ip_scopes_spec.rb b/spec/unit/plugins/ip_scopes_spec.rb
index 857947a3..4024c302 100644
--- a/spec/unit/plugins/ip_scopes_spec.rb
+++ b/spec/unit/plugins/ip_scopes_spec.rb
@@ -81,7 +81,7 @@ describe Ohai::System, "plugin ip_scopes" do
before do
# standin for raising on `require 'ipaddr_extensions'`
- plugin[:network][:interfaces].stub(:keys).and_raise(LoadError)
+ allow(plugin[:network][:interfaces]).to receive(:keys).and_raise(LoadError)
plugin.run
end
diff --git a/spec/unit/plugins/java_spec.rb b/spec/unit/plugins/java_spec.rb
index a56e0e1e..5e550e44 100644
--- a/spec/unit/plugins/java_spec.rb
+++ b/spec/unit/plugins/java_spec.rb
@@ -28,44 +28,44 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
shared_examples_for "when the JRE is installed" do
before do
@stderr = "java version \"1.5.0_16\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)\nJava HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)"
- @plugin.stub(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
+ allow(@plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
end
it "should run java -mx64m -version" do
- @plugin.should_receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
+ expect(@plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
@plugin.run
end
it "should set java[:version]" do
@plugin.run
- @plugin[:languages][:java][:version].should eql("1.5.0_16")
+ expect(@plugin[:languages][:java][:version]).to eql("1.5.0_16")
end
it "should set java[:runtime][:name] to runtime name" do
@plugin.run
- @plugin[:languages][:java][:runtime][:name].should eql("Java(TM) 2 Runtime Environment, Standard Edition")
+ expect(@plugin[:languages][:java][:runtime][:name]).to eql("Java(TM) 2 Runtime Environment, Standard Edition")
end
it "should set java[:runtime][:build] to runtime build" do
@plugin.run
- @plugin[:languages][:java][:runtime][:build].should eql("1.5.0_16-b06-284")
+ expect(@plugin[:languages][:java][:runtime][:build]).to eql("1.5.0_16-b06-284")
end
it "should set java[:hotspot][:name] to hotspot name" do
@plugin.run
- @plugin[:languages][:java][:hotspot][:name].should eql("Java HotSpot(TM) Client VM")
+ expect(@plugin[:languages][:java][:hotspot][:name]).to eql("Java HotSpot(TM) Client VM")
end
it "should set java[:hotspot][:build] to hotspot build" do
@plugin.run
- @plugin[:languages][:java][:hotspot][:build].should eql("1.5.0_16-133, mixed mode, sharing")
+ expect(@plugin[:languages][:java][:hotspot][:build]).to eql("1.5.0_16-133, mixed mode, sharing")
end
it "should not set the languages[:java] tree up if java command fails" do
@stderr = "Some error output here"
- @plugin.stub(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(1, "", @stderr))
+ allow(@plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(1, "", @stderr))
@plugin.run
- @plugin[:languages].should_not have_key(:java)
+ expect(@plugin[:languages]).not_to have_key(:java)
end
end
@@ -73,44 +73,44 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
before(:each) do
@stderr = "java version \"1.6.0_22\"\nJava(TM) 2 Runtime Environment (build 1.6.0_22-b04)\nJava HotSpot(TM) Server VM (build 17.1-b03, mixed mode)"
- @plugin.stub(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
+ allow(@plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
end
it "should run java -mx64m -version" do
- @plugin.should_receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
+ expect(@plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
@plugin.run
end
it "should set java[:version]" do
@plugin.run
- @plugin[:languages][:java][:version].should eql("1.6.0_22")
+ expect(@plugin[:languages][:java][:version]).to eql("1.6.0_22")
end
it "should set java[:runtime][:name] to runtime name" do
@plugin.run
- @plugin[:languages][:java][:runtime][:name].should eql("Java(TM) 2 Runtime Environment")
+ expect(@plugin[:languages][:java][:runtime][:name]).to eql("Java(TM) 2 Runtime Environment")
end
it "should set java[:runtime][:build] to runtime build" do
@plugin.run
- @plugin[:languages][:java][:runtime][:build].should eql("1.6.0_22-b04")
+ expect(@plugin[:languages][:java][:runtime][:build]).to eql("1.6.0_22-b04")
end
it "should set java[:hotspot][:name] to hotspot name" do
@plugin.run
- @plugin[:languages][:java][:hotspot][:name].should eql("Java HotSpot(TM) Server VM")
+ expect(@plugin[:languages][:java][:hotspot][:name]).to eql("Java HotSpot(TM) Server VM")
end
it "should set java[:hotspot][:build] to hotspot build" do
@plugin.run
- @plugin[:languages][:java][:hotspot][:build].should eql("17.1-b03, mixed mode")
+ expect(@plugin[:languages][:java][:hotspot][:build]).to eql("17.1-b03, mixed mode")
end
it "should not set the languages[:java] tree up if java command fails" do
@stderr = "Some error output here"
- @plugin.stub(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
+ allow(@plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", @stderr))
@plugin.run
- @plugin[:languages].should_not have_key(:java)
+ expect(@plugin[:languages]).not_to have_key(:java)
end
end
@@ -133,14 +133,14 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
end
it "detects that it is on a darwin platform" do
- @plugin.should be_on_darwin
+ expect(@plugin).to be_on_darwin
end
context "and real Java is installed" do
before do
java_home_status = double(Process::Status, :success? => true)
java_home_cmd = double(Mixlib::ShellOut, :status => java_home_status)
- @plugin.should_receive(:shell_out).with("/usr/libexec/java_home").and_return(java_home_cmd)
+ expect(@plugin).to receive(:shell_out).with("/usr/libexec/java_home").and_return(java_home_cmd)
end
context "and the client JRE is installed" do
@@ -155,13 +155,13 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do
before do
java_home_status = double(Process::Status, :success? => false)
java_home_cmd = double(Mixlib::ShellOut, :status => java_home_status)
- @plugin.should_receive(:shell_out).with("/usr/libexec/java_home").and_return(java_home_cmd)
+ expect(@plugin).to receive(:shell_out).with("/usr/libexec/java_home").and_return(java_home_cmd)
end
it "does not attempt to get java info" do
- @plugin.should_not_receive(:shell_out).with("java -mx64m -version")
+ expect(@plugin).not_to receive(:shell_out).with("java -mx64m -version")
@plugin.run
- @plugin[:languages].should_not have_key(:java)
+ expect(@plugin[:languages]).not_to have_key(:java)
end
end
end
diff --git a/spec/unit/plugins/joyent_spec.rb b/spec/unit/plugins/joyent_spec.rb
index 36838c3e..eb4a36df 100644
--- a/spec/unit/plugins/joyent_spec.rb
+++ b/spec/unit/plugins/joyent_spec.rb
@@ -8,25 +8,25 @@ describe Ohai::System, "plugin joyent" do
describe "without joyent" do
before(:each) do
- @plugin.stub(:is_smartos?).and_return(false)
+ allow(@plugin).to receive(:is_smartos?).and_return(false)
end
it "should NOT create joyent" do
@plugin.run
- @plugin[:joyent].should be_nil
+ expect(@plugin[:joyent]).to be_nil
end
end
describe "with joyent" do
before(:each) do
- @plugin.stub(:is_smartos?).and_return(true)
+ allow(@plugin).to receive(:is_smartos?).and_return(true)
@plugin[:virtualization] = Mash.new
@plugin[:virtualization][:guest_uuid] = "global"
end
it "should create joyent" do
@plugin.run
- @plugin[:joyent].should_not be_nil
+ expect(@plugin[:joyent]).not_to be_nil
end
describe "under global zone" do
@@ -35,11 +35,11 @@ describe Ohai::System, "plugin joyent" do
end
it "should ditect global zone" do
- @plugin[:joyent][:sm_uuid].should eql 'global'
+ expect(@plugin[:joyent][:sm_uuid]).to eql 'global'
end
it "should NOT create sm_id" do
- @plugin[:joyent][:sm_id].should be_nil
+ expect(@plugin[:joyent][:sm_id]).to be_nil
end
end
@@ -47,26 +47,26 @@ describe Ohai::System, "plugin joyent" do
before(:each) do
@plugin[:virtualization][:guest_uuid] = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx'
@plugin[:virtualization][:guest_id] = '30'
- @plugin.stub(:collect_product_file).and_return(["Name: Joyent Instance", "Image: base64 13.4.2", "Documentation: http://wiki.joyent.com/jpc2/SmartMachine+Base"])
- @plugin.stub(:collect_pkgsrc).and_return('http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All')
+ allow(@plugin).to receive(:collect_product_file).and_return(["Name: Joyent Instance", "Image: base64 13.4.2", "Documentation: http://wiki.joyent.com/jpc2/SmartMachine+Base"])
+ allow(@plugin).to receive(:collect_pkgsrc).and_return('http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All')
@plugin.run
end
it "should retrive zone uuid" do
- @plugin[:joyent][:sm_uuid].should eql 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx'
+ expect(@plugin[:joyent][:sm_uuid]).to eql 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx'
end
it "should collect sm_id" do
- @plugin[:joyent][:sm_id].should eql '30'
+ expect(@plugin[:joyent][:sm_id]).to eql '30'
end
it "should collect images" do
- @plugin[:joyent][:sm_image_id].should_not be_nil
- @plugin[:joyent][:sm_image_ver].should_not be_nil
+ expect(@plugin[:joyent][:sm_image_id]).not_to be_nil
+ expect(@plugin[:joyent][:sm_image_ver]).not_to be_nil
end
it "should collect pkgsrc" do
- @plugin[:joyent][:sm_pkgsrc].should eql 'http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All'
+ expect(@plugin[:joyent][:sm_pkgsrc]).to eql 'http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All'
end
end
end
diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb
index acef0b3b..37b7a3ca 100644
--- a/spec/unit/plugins/kernel_spec.rb
+++ b/spec/unit/plugins/kernel_spec.rb
@@ -22,12 +22,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
describe Ohai::System, "plugin kernel" do
before(:each) do
@plugin = get_plugin("kernel")
- @plugin.stub(:collect_os).and_return(:default) # for debugging
- @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "Darwin\n", ""))
- @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "9.5.0\n", ""))
- @plugin.stub(:shell_out).with("uname -v").and_return(mock_shell_out(0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""))
- @plugin.stub(:shell_out).with("uname -m").and_return(mock_shell_out(0, "i386\n", ""))
- @plugin.stub(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:default) # for debugging
+ allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "Darwin\n", ""))
+ allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "9.5.0\n", ""))
+ allow(@plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""))
+ allow(@plugin).to receive(:shell_out).with("uname -m").and_return(mock_shell_out(0, "i386\n", ""))
+ allow(@plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux\n", ""))
end
it_should_check_from_mash("kernel", "name", "uname -s", [0, "Darwin\n", ""])
@@ -53,15 +53,15 @@ describe Ohai::System, "plugin kernel" do
os = double( "WIN32OLE",
:properties_ => os_properties)
- os.stub(:invoke).with(build_number.name).and_return('7601')
- os.stub(:invoke).with(csd_version.name).and_return('Service Pack 1')
- os.stub(:invoke).with(os_type.name).and_return(18)
- os.stub(:invoke).with(caption.name).and_return('Microsoft Windows 7 Ultimate')
- os.stub(:invoke).with(version.name).and_return('6.1.7601')
+ allow(os).to receive(:invoke).with(build_number.name).and_return('7601')
+ allow(os).to receive(:invoke).with(csd_version.name).and_return('Service Pack 1')
+ allow(os).to receive(:invoke).with(os_type.name).and_return(18)
+ allow(os).to receive(:invoke).with(caption.name).and_return('Microsoft Windows 7 Ultimate')
+ allow(os).to receive(:invoke).with(version.name).and_return('6.1.7601')
os_wmi = WmiLite::Wmi::Instance.new(os)
- WmiLite::Wmi.any_instance.should_receive(:first_of).with('Win32_OperatingSystem').and_return(os_wmi)
+ expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with('Win32_OperatingSystem').and_return(os_wmi)
# Mock a Win32_ComputerSystem OLE32 WMI object
x64_system_type = 'x64-based PC'
@@ -69,21 +69,21 @@ describe Ohai::System, "plugin kernel" do
cs = double("WIN32OLE",
:properties_ => [ double("WIN32OLE", :name => "SystemType") ])
- cs.stub(:invoke).with('SystemType').and_return(x64_system_type)
+ allow(cs).to receive(:invoke).with('SystemType').and_return(x64_system_type)
cs_wmi = WmiLite::Wmi::Instance.new(cs)
- WmiLite::Wmi.any_instance.should_receive(:first_of).with('Win32_ComputerSystem').and_return(cs_wmi)
- WmiLite::Wmi.any_instance.should_receive(:instances_of).with('Win32_PnPSignedDriver').and_return([])
+ expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with('Win32_ComputerSystem').and_return(cs_wmi)
+ expect_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_PnPSignedDriver').and_return([])
@plugin.run
end
it "should set the corrent system information" do
- @ohai_system.data[:kernel][:name].should == "Microsoft Windows 7 Ultimate"
- @ohai_system.data[:kernel][:release].should == "6.1.7601"
- @ohai_system.data[:kernel][:version].should == "6.1.7601 Service Pack 1 Build 7601"
- @ohai_system.data[:kernel][:os].should == "WINNT"
- @ohai_system.data[:kernel][:machine].should == "x86_64"
+ expect(@ohai_system.data[:kernel][:name]).to eq("Microsoft Windows 7 Ultimate")
+ expect(@ohai_system.data[:kernel][:release]).to eq("6.1.7601")
+ expect(@ohai_system.data[:kernel][:version]).to eq("6.1.7601 Service Pack 1 Build 7601")
+ expect(@ohai_system.data[:kernel][:os]).to eq("WINNT")
+ expect(@ohai_system.data[:kernel][:machine]).to eq("x86_64")
end
end
diff --git a/spec/unit/plugins/linode_spec.rb b/spec/unit/plugins/linode_spec.rb
index b773e4ff..8da577a2 100644
--- a/spec/unit/plugins/linode_spec.rb
+++ b/spec/unit/plugins/linode_spec.rb
@@ -49,24 +49,24 @@ describe Ohai::System, "plugin linode" do
shared_examples_for "!linode" do
it "does not create the linode mash" do
@plugin.run
- @plugin[:linode].should be_nil
+ expect(@plugin[:linode]).to be_nil
end
end
shared_examples_for "linode" do
it "creates a linode mash" do
@plugin.run
- @plugin[:linode].should_not be_nil
+ expect(@plugin[:linode]).not_to be_nil
end
it "has all required attributes" do
@plugin.run
- @plugin[:linode][:public_ip].should_not be_nil
+ expect(@plugin[:linode][:public_ip]).not_to be_nil
end
it "has correct values for all attributes" do
@plugin.run
- @plugin[:linode][:public_ip].should == "1.2.3.4"
+ expect(@plugin[:linode][:public_ip]).to eq("1.2.3.4")
end
end
@@ -111,8 +111,8 @@ describe Ohai::System, "plugin linode" do
it "detects and sets the private ip" do
@plugin.run
- @plugin[:linode][:private_ip].should_not be_nil
- @plugin[:linode][:private_ip].should == "5.6.7.8"
+ expect(@plugin[:linode][:private_ip]).not_to be_nil
+ expect(@plugin[:linode][:private_ip]).to eq("5.6.7.8")
end
end
@@ -120,10 +120,10 @@ describe Ohai::System, "plugin linode" do
describe "with linode cloud file" do
before do
- File.stub(:exist?).with(hint_path_nix).and_return(true)
- File.stub(:read).with(hint_path_nix).and_return('')
- File.stub(:exist?).with(hint_path_win).and_return(true)
- File.stub(:read).with(hint_path_win).and_return('')
+ allow(File).to receive(:exist?).with(hint_path_nix).and_return(true)
+ allow(File).to receive(:read).with(hint_path_nix).and_return('')
+ allow(File).to receive(:exist?).with(hint_path_win).and_return(true)
+ allow(File).to receive(:read).with(hint_path_win).and_return('')
end
it_should_behave_like "linode"
@@ -131,8 +131,8 @@ describe Ohai::System, "plugin linode" do
describe "without cloud file" do
before do
- File.stub(:exist?).with(hint_path_nix).and_return(false)
- File.stub(:exist?).with(hint_path_win).and_return(false)
+ allow(File).to receive(:exist?).with(hint_path_nix).and_return(false)
+ allow(File).to receive(:exist?).with(hint_path_win).and_return(false)
end
it_should_behave_like "!linode"
@@ -143,13 +143,13 @@ describe Ohai::System, "plugin linode" do
let(:ec2_hint_path_win) { 'C:\chef\ohai\hints/ec2.json' }
before do
- File.stub(:exist?).with(hint_path_nix).and_return(false)
- File.stub(:exist?).with(hint_path_win).and_return(false)
+ allow(File).to receive(:exist?).with(hint_path_nix).and_return(false)
+ allow(File).to receive(:exist?).with(hint_path_win).and_return(false)
- File.stub(:exist?).with(ec2_hint_path_nix).and_return(true)
- File.stub(:read).with(ec2_hint_path_nix).and_return('')
- File.stub(:exist?).with(ec2_hint_path_win).and_return(true)
- File.stub(:read).with(ec2_hint_path_win).and_return('')
+ allow(File).to receive(:exist?).with(ec2_hint_path_nix).and_return(true)
+ allow(File).to receive(:read).with(ec2_hint_path_nix).and_return('')
+ allow(File).to receive(:exist?).with(ec2_hint_path_win).and_return(true)
+ allow(File).to receive(:read).with(ec2_hint_path_win).and_return('')
end
it_should_behave_like "!linode"
diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb
index 5f55eb5f..f40049dc 100644
--- a/spec/unit/plugins/linux/cpu_spec.rb
+++ b/spec/unit/plugins/linux/cpu_spec.rb
@@ -22,9 +22,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux cpu plugin" do
before(:each) do
@plugin = get_plugin("linux/cpu")
- @plugin.stub(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
@double_file = double("/proc/cpuinfo")
- @double_file.stub(:each).
+ allow(@double_file).to receive(:each).
and_yield("processor : 0").
and_yield("vendor_id : GenuineIntel").
and_yield("cpu family : 6").
@@ -44,84 +44,84 @@ describe Ohai::System, "Linux cpu plugin" do
and_yield("flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov").
and_yield("bogomips : 2575.86").
and_yield("clflush size : 32")
- File.stub(:open).with("/proc/cpuinfo").and_return(@double_file)
+ allow(File).to receive(:open).with("/proc/cpuinfo").and_return(@double_file)
end
it "should set cpu[:total] to 1" do
@plugin.run
- @plugin[:cpu][:total].should == 1
+ expect(@plugin[:cpu][:total]).to eq(1)
end
it "should set cpu[:real] to 0" do
@plugin.run
- @plugin[:cpu][:real].should == 0
+ expect(@plugin[:cpu][:real]).to eq(0)
end
it "should have a cpu 0" do
@plugin.run
- @plugin[:cpu].should have_key("0")
+ expect(@plugin[:cpu]).to have_key("0")
end
it "should have a vendor_id for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should have_key("vendor_id")
- @plugin[:cpu]["0"]["vendor_id"].should eql("GenuineIntel")
+ expect(@plugin[:cpu]["0"]).to have_key("vendor_id")
+ expect(@plugin[:cpu]["0"]["vendor_id"]).to eql("GenuineIntel")
end
it "should have a family for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should have_key("family")
- @plugin[:cpu]["0"]["family"].should eql("6")
+ expect(@plugin[:cpu]["0"]).to have_key("family")
+ expect(@plugin[:cpu]["0"]["family"]).to eql("6")
end
it "should have a model for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should have_key("model")
- @plugin[:cpu]["0"]["model"].should eql("23")
+ expect(@plugin[:cpu]["0"]).to have_key("model")
+ expect(@plugin[:cpu]["0"]["model"]).to eql("23")
end
it "should have a stepping for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should have_key("stepping")
- @plugin[:cpu]["0"]["stepping"].should eql("6")
+ expect(@plugin[:cpu]["0"]).to have_key("stepping")
+ expect(@plugin[:cpu]["0"]["stepping"]).to eql("6")
end
it "should not have a phyiscal_id for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should_not have_key("physical_id")
+ expect(@plugin[:cpu]["0"]).not_to have_key("physical_id")
end
it "should not have a core_id for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should_not have_key("core_id")
+ expect(@plugin[:cpu]["0"]).not_to have_key("core_id")
end
it "should not have a cores for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should_not have_key("cores")
+ expect(@plugin[:cpu]["0"]).not_to have_key("cores")
end
it "should have a model name for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should have_key("model_name")
- @plugin[:cpu]["0"]["model_name"].should eql("Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz")
+ expect(@plugin[:cpu]["0"]).to have_key("model_name")
+ expect(@plugin[:cpu]["0"]["model_name"]).to eql("Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz")
end
it "should have a mhz for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should have_key("mhz")
- @plugin[:cpu]["0"]["mhz"].should eql("1968.770")
+ expect(@plugin[:cpu]["0"]).to have_key("mhz")
+ expect(@plugin[:cpu]["0"]["mhz"]).to eql("1968.770")
end
it "should have a cache_size for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should have_key("cache_size")
- @plugin[:cpu]["0"]["cache_size"].should eql("64 KB")
+ expect(@plugin[:cpu]["0"]).to have_key("cache_size")
+ expect(@plugin[:cpu]["0"]["cache_size"]).to eql("64 KB")
end
it "should have flags for cpu 0" do
@plugin.run
- @plugin[:cpu]["0"].should have_key("flags")
- @plugin[:cpu]["0"]["flags"].should == %w{fpu pse tsc msr mce cx8 sep mtrr pge cmov}
+ expect(@plugin[:cpu]["0"]).to have_key("flags")
+ expect(@plugin[:cpu]["0"]["flags"]).to eq(%w{fpu pse tsc msr mce cx8 sep mtrr pge cmov})
end
end
diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb
index ffcc5393..9bbccc45 100644
--- a/spec/unit/plugins/linux/filesystem_spec.rb
+++ b/spec/unit/plugins/linux/filesystem_spec.rb
@@ -21,27 +21,27 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux filesystem plugin" do
before(:each) do
@plugin = get_plugin("linux/filesystem")
- @plugin.stub(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
- @plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("df -i").and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
- File.stub(:exist?).with("/bin/lsblk").and_return(false)
- @plugin.stub(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
+ allow(File).to receive(:exist?).with("/bin/lsblk").and_return(false)
+ allow(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
+ allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("lsblk -r -n -o NAME,UUID").
+ allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,UUID").
and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("lsblk -r -n -o NAME,LABEL").
+ allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,LABEL").
and_return(mock_shell_out(0, "", ""))
- File.stub(:exist?).with("/proc/mounts").and_return(false)
+ allow(File).to receive(:exist?).with("/proc/mounts").and_return(false)
%w{sdb1 sdb2 sda1 sda2 md0 md1 md2}.each do |name|
- File.stub(:exist?).with("/dev/#{name}").and_return(true)
+ allow(File).to receive(:exist?).with("/dev/#{name}").and_return(true)
end
%w{
sys.vg-root.lv
@@ -51,8 +51,8 @@ describe Ohai::System, "Linux filesystem plugin" do
sys.vg-var.lv
sys.vg-home.lv
}.each do |name|
- File.stub(:exist?).with("/dev/#{name}").and_return(false)
- File.stub(:exist?).with("/dev/mapper/#{name}").and_return(true)
+ allow(File).to receive(:exist?).with("/dev/#{name}").and_return(false)
+ allow(File).to receive(:exist?).with("/dev/mapper/#{name}").and_return(true)
end
end
@@ -71,7 +71,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm
/dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
/dev/md0 960492 36388 875312 4% /boot
DF
- @plugin.stub(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, ""))
@inode_stdout = <<-DFi
Filesystem Inodes IUsed IFree IUse% Mounted on
@@ -81,53 +81,53 @@ tmpfs 126922 273 126649 1% /run
none 126922 1 126921 1% /run/lock
none 126922 1 126921 1% /run/shm
DFi
- @plugin.stub(:shell_out).with("df -i").and_return(mock_shell_out(0, @inode_stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @inode_stdout, ""))
end
it "should run df -P and df -i" do
- @plugin.should_receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, ""))
- @plugin.should_receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @inode_stdout, ""))
+ expect(@plugin).to receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @inode_stdout, ""))
@plugin.run
end
it "should set kb_size to value from df -P" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size].should be == "97605057"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size]).to eq("97605057")
end
it "should set kb_used to value from df -P" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used].should be == "53563253"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used]).to eq("53563253")
end
it "should set kb_available to value from df -P" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available].should be == "44041805"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available]).to eq("44041805")
end
it "should set percent_used to value from df -P" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used].should be == "56%"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used]).to eq("56%")
end
it "should set mount to value from df -P" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
end
it "should set total_inodes to value from df -i" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes].should be == "124865"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865")
end
it "should set inodes_used to value from df -i" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used].should be == "380"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380")
end
it "should set inodes_available to value from df -i" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available].should be == "124485"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485")
end
end
@@ -150,27 +150,27 @@ devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
MOUNT
- @plugin.stub(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run mount" do
- @plugin.should_receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set mount to value from mount" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
end
it "should set fs_type to value from mount" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type].should be == "xfs"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs")
end
it "should set mount_options to an array of values from mount" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].should be == [ "ro", "noatime" ]
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime" ])
end
end
@@ -190,23 +190,23 @@ MOUNT
/dev/mapper/sys.vg-var.lv: TYPE=\"ext4\"
/dev/mapper/sys.vg-home.lv: TYPE=\"xfs\"
BLKID_TYPE
- @plugin.stub(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run blkid -s TYPE" do
- @plugin.should_receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set kb_size to value from blkid -s TYPE" do
@plugin.run
- @plugin[:filesystem]["/dev/md1"][:fs_type].should be == "LVM2_member"
+ expect(@plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member")
end
end
describe "when gathering filesystem type data from lsblk" do
before(:each) do
- File.stub(:exist?).with("/bin/lsblk").and_return(true)
+ allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
@stdout = <<-BLKID_TYPE
sdb1 linux_raid_member
sdb2 linux_raid_member
@@ -221,19 +221,19 @@ sys.vg-usr.lv ext4
sys.vg-var.lv ext4
sys.vg-home.lv xfs
BLKID_TYPE
- @plugin.stub(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
+ allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
and_return(mock_shell_out(0, @stdout, ""))
end
it "should run lsblk -r -n -o NAME,FSTYPE" do
- @plugin.should_receive(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
+ expect(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,FSTYPE").
and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set kb_size to value from lsblk -r -n -o NAME,FSTYPE" do
@plugin.run
- @plugin[:filesystem]["/dev/md1"][:fs_type].should be == "LVM2_member"
+ expect(@plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member")
end
end
@@ -253,23 +253,23 @@ BLKID_TYPE
/dev/mapper/sys.vg-var.lv: UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\"
/dev/mapper/sys.vg-home.lv: UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\"
BLKID_UUID
- @plugin.stub(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run blkid -s UUID" do
- @plugin.should_receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set kb_size to value from blkid -s UUID" do
@plugin.run
- @plugin[:filesystem]["/dev/sda2"][:uuid].should be == "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
+ expect(@plugin[:filesystem]["/dev/sda2"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
end
end
describe "when gathering filesystem uuid data from lsblk" do
before(:each) do
- File.stub(:exist?).with("/bin/lsblk").and_return(true)
+ allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
@stdout = <<-BLKID_UUID
sdb1 bd1197e0-6997-1f3a-e27e-7801388308b5
sdb2 e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa
@@ -284,20 +284,21 @@ sys.vg-usr.lv 26ec33c5-d00b-4f88-a550-492def013bbc
sys.vg-var.lv 6b559c35-7847-4ae2-b512-c99012d3f5b3
sys.vg-home.lv d6efda02-1b73-453c-8c74-7d8dee78fa5e
BLKID_UUID
- @plugin.stub(:shell_out).with("lsblk -r -n -o NAME,UUID").
+ allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,UUID").
and_return(mock_shell_out(0, @stdout, ""))
end
it "should run lsblk -r -n -o NAME,UUID" do
- @plugin.should_receive(:shell_out).with("lsblk -r -n -o NAME,UUID").
+ expect(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,UUID").
and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set kb_size to value from lsblk -r -n -o NAME,UUID" do
@plugin.run
- @plugin[:filesystem]["/dev/sda2"][:uuid].should be ==
+ expect(@plugin[:filesystem]["/dev/sda2"][:uuid]).to eq(
"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
+ )
end
end
@@ -315,23 +316,23 @@ BLKID_UUID
/dev/mapper/sys.vg-var.lv: LABEL=\"/var\"
/dev/mapper/sys.vg-home.lv: LABEL=\"/home\"
BLKID_LABEL
- @plugin.stub(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run blkid -s LABEL" do
- @plugin.should_receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set kb_size to value from blkid -s LABEL" do
@plugin.run
- @plugin[:filesystem]["/dev/md0"][:label].should be == "/boot"
+ expect(@plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot")
end
end
describe "when gathering filesystem label data from lsblk" do
before(:each) do
- File.stub(:exist?).with("/bin/lsblk").and_return(true)
+ allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
@stdout = <<-BLKID_LABEL
sda1 fuego:0
sda2 fuego:1
@@ -344,26 +345,26 @@ sys.vg-usr.lv /usr
sys.vg-var.lv /var
sys.vg-home.lv /home
BLKID_LABEL
- @plugin.stub(:shell_out).with("lsblk -r -n -o NAME,LABEL").
+ allow(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,LABEL").
and_return(mock_shell_out(0, @stdout, ""))
end
it "should run blkid -s LABEL" do
- @plugin.should_receive(:shell_out).with("lsblk -r -n -o NAME,LABEL").
+ expect(@plugin).to receive(:shell_out).with("lsblk -r -n -o NAME,LABEL").
and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set kb_size to value from blkid -s LABEL" do
@plugin.run
- @plugin[:filesystem]["/dev/md0"][:label].should be == "/boot"
+ expect(@plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot")
end
end
describe "when gathering data from /proc/mounts" do
before(:each) do
- File.stub(:exist?).with("/proc/mounts").and_return(true)
+ allow(File).to receive(:exist?).with("/proc/mounts").and_return(true)
@double_file = double("/proc/mounts")
@mounts = <<-MOUNTS
rootfs / rootfs rw 0 0
@@ -384,28 +385,28 @@ fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
MOUNTS
@counter = 0
- @double_file.stub(:read_nonblock) do
+ allow(@double_file).to receive(:read_nonblock) do
@counter += 1
raise EOFError if @counter == 2
@mounts
end
- @double_file.stub(:close)
- File.stub(:open).with("/proc/mounts").and_return(@double_file)
+ allow(@double_file).to receive(:close)
+ allow(File).to receive(:open).with("/proc/mounts").and_return(@double_file)
end
it "should set mount to value from /proc/mounts" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount].should be == "/special"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
end
it "should set fs_type to value from /proc/mounts" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type].should be == "xfs"
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs")
end
it "should set mount_options to an array of values from /proc/mounts" do
@plugin.run
- @plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options].should be == [ "ro", "noatime", "attr2", "noquota" ]
+ expect(@plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime", "attr2", "noquota" ])
end
end
diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb
index 904ccbb0..203f20fb 100644
--- a/spec/unit/plugins/linux/hostname_spec.rb
+++ b/spec/unit/plugins/linux/hostname_spec.rb
@@ -22,10 +22,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux hostname plugin" do
before(:each) do
@plugin = get_plugin("hostname")
- @plugin.stub(:collect_os).and_return(:linux)
- @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
- @plugin.stub(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
+ allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
end
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
@@ -36,16 +36,16 @@ describe Ohai::System, "Linux hostname plugin" do
describe "when domain name is unset" do
before(:each) do
- @plugin.should_receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
+ expect(@plugin).to receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
end
it "should not raise an error" do
- lambda { @plugin.run }.should_not raise_error
+ expect { @plugin.run }.not_to raise_error
end
it "should not set fqdn" do
@plugin.run
- @plugin.fqdn.should == nil
+ expect(@plugin.fqdn).to eq(nil)
end
end
diff --git a/spec/unit/plugins/linux/kernel_spec.rb b/spec/unit/plugins/linux/kernel_spec.rb
index 3105a4fd..262a0d04 100644
--- a/spec/unit/plugins/linux/kernel_spec.rb
+++ b/spec/unit/plugins/linux/kernel_spec.rb
@@ -32,11 +32,11 @@ virtio_balloon 13168 0
floppy 55441 0
ENV_LSMOD
@plugin = get_plugin("kernel")
- @plugin.stub(:collect_os).and_return(:linux)
- @plugin.stub(:init_kernel).and_return({})
- @plugin.stub(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux", ""))
- @plugin.stub(:shell_out).with("env lsmod").and_return(mock_shell_out(0, @env_lsmod, ""))
- @plugin.should_receive(:shell_out).with("env lsmod").at_least(1).times
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:init_kernel).and_return({})
+ allow(@plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux", ""))
+ allow(@plugin).to receive(:shell_out).with("env lsmod").and_return(mock_shell_out(0, @env_lsmod, ""))
+ expect(@plugin).to receive(:shell_out).with("env lsmod").at_least(1).times
@plugin.run
end
diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb
index c2b763ae..5e2c0c36 100644
--- a/spec/unit/plugins/linux/lsb_spec.rb
+++ b/spec/unit/plugins/linux/lsb_spec.rb
@@ -24,46 +24,46 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux lsb plugin" do
before(:each) do
@plugin = get_plugin("linux/lsb")
- @plugin.stub(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
end
describe "on systems with /etc/lsb-release" do
before(:each) do
@double_file = double("/etc/lsb-release")
- @double_file.stub(:each).
+ allow(@double_file).to receive(:each).
and_yield("DISTRIB_ID=Ubuntu").
and_yield("DISTRIB_RELEASE=8.04").
and_yield("DISTRIB_CODENAME=hardy").
and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
- File.stub(:open).with("/etc/lsb-release").and_return(@double_file)
- File.stub(:exists?).with("/etc/lsb-release").and_return(true)
+ allow(File).to receive(:open).with("/etc/lsb-release").and_return(@double_file)
+ allow(File).to receive(:exists?).with("/etc/lsb-release").and_return(true)
end
it "should set lsb[:id]" do
@plugin.run
- @plugin[:lsb][:id].should == "Ubuntu"
+ expect(@plugin[:lsb][:id]).to eq("Ubuntu")
end
it "should set lsb[:release]" do
@plugin.run
- @plugin[:lsb][:release].should == "8.04"
+ expect(@plugin[:lsb][:release]).to eq("8.04")
end
it "should set lsb[:codename]" do
@plugin.run
- @plugin[:lsb][:codename].should == "hardy"
+ expect(@plugin[:lsb][:codename]).to eq("hardy")
end
it "should set lsb[:description]" do
@plugin.run
- @plugin[:lsb][:description].should == "Ubuntu 8.04"
+ expect(@plugin[:lsb][:description]).to eq("Ubuntu 8.04")
end
end
describe "on systems with /usr/bin/lsb_release" do
before(:each) do
- File.stub(:exists?).with("/etc/lsb-release").and_return(false)
- File.stub(:exists?).with("/usr/bin/lsb_release").and_return(true)
+ allow(File).to receive(:exists?).with("/etc/lsb-release").and_return(false)
+ allow(File).to receive(:exists?).with("/usr/bin/lsb_release").and_return(true)
@stdin = double("STDIN", { :close => true })
@pid = 10
@@ -82,27 +82,27 @@ Description: CentOS release 5.4 (Final)
Release: 5.4
Codename: Final
LSB_RELEASE
- @plugin.stub(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
end
it "should set lsb[:id]" do
@plugin.run
- @plugin[:lsb][:id].should == "CentOS"
+ expect(@plugin[:lsb][:id]).to eq("CentOS")
end
it "should set lsb[:release]" do
@plugin.run
- @plugin[:lsb][:release].should == "5.4"
+ expect(@plugin[:lsb][:release]).to eq("5.4")
end
it "should set lsb[:codename]" do
@plugin.run
- @plugin[:lsb][:codename].should == "Final"
+ expect(@plugin[:lsb][:codename]).to eq("Final")
end
it "should set lsb[:description]" do
@plugin.run
- @plugin[:lsb][:description].should == "CentOS release 5.4 (Final)"
+ expect(@plugin[:lsb][:description]).to eq("CentOS release 5.4 (Final)")
end
end
@@ -115,34 +115,34 @@ Description: Fedora release 14 (Laughlin)
Release: 14
Codename: Laughlin
LSB_RELEASE
- @plugin.stub(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
end
it "should set lsb[:id]" do
@plugin.run
- @plugin[:lsb][:id].should == "Fedora"
+ expect(@plugin[:lsb][:id]).to eq("Fedora")
end
it "should set lsb[:release]" do
@plugin.run
- @plugin[:lsb][:release].should == "14"
+ expect(@plugin[:lsb][:release]).to eq("14")
end
it "should set lsb[:codename]" do
@plugin.run
- @plugin[:lsb][:codename].should == "Laughlin"
+ expect(@plugin[:lsb][:codename]).to eq("Laughlin")
end
it "should set lsb[:description]" do
@plugin.run
- @plugin[:lsb][:description].should == "Fedora release 14 (Laughlin)"
+ expect(@plugin[:lsb][:description]).to eq("Fedora release 14 (Laughlin)")
end
end
end
it "should not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist " do
- File.stub(:exists?).with("/etc/lsb-release").and_return(false)
- File.stub(:exists?).with("/usr/bin/lsb_release").and_return(false)
- @plugin.attribute?(:lsb).should be(false)
+ allow(File).to receive(:exists?).with("/etc/lsb-release").and_return(false)
+ allow(File).to receive(:exists?).with("/usr/bin/lsb_release").and_return(false)
+ expect(@plugin.attribute?(:lsb)).to be(false)
end
end
diff --git a/spec/unit/plugins/linux/mdadm_spec.rb b/spec/unit/plugins/linux/mdadm_spec.rb
index 0f0b1498..48ddd92f 100644
--- a/spec/unit/plugins/linux/mdadm_spec.rb
+++ b/spec/unit/plugins/linux/mdadm_spec.rb
@@ -54,48 +54,48 @@ Working Devices : 6
5 8 112 5 active sync /dev/sdh
MD
@plugin = get_plugin("linux/mdadm")
- @plugin.stub(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
@double_file = double("/proc/mdstat")
- @double_file.stub(:each).
+ allow(@double_file).to receive(:each).
and_yield("Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]").
and_yield("md0 : active raid10 sdh[5] sdg[4] sdf[3] sde[2] sdd[1] sdc[0]").
and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]")
- File.stub(:open).with("/proc/mdstat").and_return(@double_file)
- File.stub(:exist?).with("/proc/mdstat").and_return(true)
- @plugin.stub(:shell_out).with("mdadm --detail /dev/md0").and_return(mock_shell_out(0, @md0, ""))
+ allow(File).to receive(:open).with("/proc/mdstat").and_return(@double_file)
+ allow(File).to receive(:exist?).with("/proc/mdstat").and_return(true)
+ allow(@plugin).to receive(:shell_out).with("mdadm --detail /dev/md0").and_return(mock_shell_out(0, @md0, ""))
end
describe "gathering Mdadm information via /proc/mdstat and mdadm" do
it "should not raise an error" do
- lambda { @plugin.run }.should_not raise_error
+ expect { @plugin.run }.not_to raise_error
end
it "should detect raid level" do
@plugin.run
- @plugin[:mdadm][:md0][:level].should == 10
+ expect(@plugin[:mdadm][:md0][:level]).to eq(10)
end
it "should detect raid state" do
@plugin.run
- @plugin[:mdadm][:md0][:state].should == "clean"
+ expect(@plugin[:mdadm][:md0][:state]).to eq("clean")
end
it "should detect raid size" do
@plugin.run
- @plugin[:mdadm][:md0][:size].should == 2794.16
+ expect(@plugin[:mdadm][:md0][:size]).to eq(2794.16)
end
it "should detect raid metadata level" do
@plugin.run
- @plugin[:mdadm][:md0][:version].should == 1.2
+ expect(@plugin[:mdadm][:md0][:version]).to eq(1.2)
end
device_counts = { :raid => 6, :total => 6, :active => 6, :working => 6, :failed => 0, :spare => 0 }
device_counts.each_pair do |item, expected_value|
it "should detect device count of \"#{item}\"" do
@plugin.run
- @plugin[:mdadm][:md0][:device_counts][item].should == expected_value
+ expect(@plugin[:mdadm][:md0][:device_counts][item]).to eq(expected_value)
end
end
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index a148ecf9..eff77c11 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -23,20 +23,20 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux plugin platform" do
before(:each) do
@plugin = get_plugin("linux/platform")
- @plugin.stub(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
@plugin[:lsb] = Mash.new
- File.stub(:exists?).with("/etc/debian_version").and_return(false)
- File.stub(:exists?).with("/etc/redhat-release").and_return(false)
- File.stub(:exists?).with("/etc/gentoo-release").and_return(false)
- File.stub(:exists?).with("/etc/exherbo-release").and_return(false)
- File.stub(:exists?).with("/etc/SuSE-release").and_return(false)
- File.stub(:exists?).with("/etc/arch-release").and_return(false)
- File.stub(:exists?).with("/etc/system-release").and_return(false)
- File.stub(:exists?).with("/etc/slackware-version").and_return(false)
- File.stub(:exists?).with("/etc/enterprise-release").and_return(false)
- File.stub(:exists?).with("/etc/oracle-release").and_return(false)
- File.stub(:exists?).with("/etc/parallels-release").and_return(false)
- File.stub(:exists?).with("/usr/bin/raspi-config").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/debian_version").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/gentoo-release").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/exherbo-release").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/SuSE-release").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/arch-release").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/system-release").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/slackware-version").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/enterprise-release").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/oracle-release").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/parallels-release").and_return(false)
+ allow(File).to receive(:exists?).with("/usr/bin/raspi-config").and_return(false)
end
describe "on lsb compliant distributions" do
@@ -47,83 +47,83 @@ describe Ohai::System, "Linux plugin platform" do
it "should set platform to lowercased lsb[:id]" do
@plugin.run
- @plugin[:platform].should == "ubuntu"
+ expect(@plugin[:platform]).to eq("ubuntu")
end
it "should set platform_version to lsb[:release]" do
@plugin.run
- @plugin[:platform_version].should == "8.04"
+ expect(@plugin[:platform_version]).to eq("8.04")
end
it "should set platform to ubuntu and platform_family to debian [:lsb][:id] contains Ubuntu" do
@plugin[:lsb][:id] = "Ubuntu"
@plugin.run
- @plugin[:platform].should == "ubuntu"
- @plugin[:platform_family].should == "debian"
+ expect(@plugin[:platform]).to eq("ubuntu")
+ expect(@plugin[:platform_family]).to eq("debian")
end
it "should set platform to linuxmint and platform_family to debian [:lsb][:id] contains LinuxMint" do
@plugin[:lsb][:id] = "LinuxMint"
@plugin.run
- @plugin[:platform].should == "linuxmint"
- @plugin[:platform_family].should == "debian"
+ expect(@plugin[:platform]).to eq("linuxmint")
+ expect(@plugin[:platform_family]).to eq("debian")
end
it "should set platform to debian and platform_family to debian [:lsb][:id] contains Debian" do
@plugin[:lsb][:id] = "Debian"
@plugin.run
- @plugin[:platform].should == "debian"
- @plugin[:platform_family].should == "debian"
+ expect(@plugin[:platform]).to eq("debian")
+ expect(@plugin[:platform_family]).to eq("debian")
end
it "should set platform to redhat and platform_family to rhel when [:lsb][:id] contains Redhat" do
@plugin[:lsb][:id] = "RedHatEnterpriseServer"
@plugin[:lsb][:release] = "5.7"
@plugin.run
- @plugin[:platform].should == "redhat"
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform]).to eq("redhat")
+ expect(@plugin[:platform_family]).to eq("rhel")
end
it "should set platform to amazon and platform_family to rhel when [:lsb][:id] contains Amazon" do
@plugin[:lsb][:id] = "AmazonAMI"
@plugin[:lsb][:release] = "2011.09"
@plugin.run
- @plugin[:platform].should == "amazon"
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform]).to eq("amazon")
+ expect(@plugin[:platform_family]).to eq("rhel")
end
it "should set platform to scientific when [:lsb][:id] contains ScientificSL" do
@plugin[:lsb][:id] = "ScientificSL"
@plugin[:lsb][:release] = "5.7"
@plugin.run
- @plugin[:platform].should == "scientific"
+ expect(@plugin[:platform]).to eq("scientific")
end
it "should set platform to ibm_powerkvm and platform_family to rhel when [:lsb][:id] contains IBM_PowerKVM" do
@plugin[:lsb][:id] = "IBM_PowerKVM"
@plugin[:lsb][:release] = "2.1"
@plugin.run
- @plugin[:platform].should == "ibm_powerkvm"
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform]).to eq("ibm_powerkvm")
+ expect(@plugin[:platform_family]).to eq("rhel")
end
end
describe "on debian" do
before(:each) do
@plugin.lsb = nil
- File.should_receive(:exists?).with("/etc/debian_version").and_return(true)
+ expect(File).to receive(:exists?).with("/etc/debian_version").and_return(true)
end
it "should read the version from /etc/debian_version" do
- File.should_receive(:read).with("/etc/debian_version").and_return("5.0")
+ expect(File).to receive(:read).with("/etc/debian_version").and_return("5.0")
@plugin.run
- @plugin[:platform_version].should == "5.0"
+ expect(@plugin[:platform_version]).to eq("5.0")
end
it "should correctly strip any newlines" do
- File.should_receive(:read).with("/etc/debian_version").and_return("5.0\n")
+ expect(File).to receive(:read).with("/etc/debian_version").and_return("5.0\n")
@plugin.run
- @plugin[:platform_version].should == "5.0"
+ expect(@plugin[:platform_version]).to eq("5.0")
end
# Ubuntu has /etc/debian_version as well
@@ -131,43 +131,43 @@ describe Ohai::System, "Linux plugin platform" do
@plugin[:lsb][:id] = "Ubuntu"
@plugin[:lsb][:release] = "8.04"
@plugin.run
- @plugin[:platform].should == "ubuntu"
+ expect(@plugin[:platform]).to eq("ubuntu")
end
# Raspbian is a debian clone
it "should detect Raspbian as itself with debian as the family" do
- File.should_receive(:exists?).with("/usr/bin/raspi-config").and_return(true)
- File.should_receive(:read).with("/etc/debian_version").and_return("wheezy/sid")
+ expect(File).to receive(:exists?).with("/usr/bin/raspi-config").and_return(true)
+ expect(File).to receive(:read).with("/etc/debian_version").and_return("wheezy/sid")
@plugin.run
- @plugin[:platform].should == "raspbian"
- @plugin[:platform_family].should == "debian"
+ expect(@plugin[:platform]).to eq("raspbian")
+ expect(@plugin[:platform_family]).to eq("debian")
end
end
describe "on slackware" do
before(:each) do
@plugin.lsb = nil
- File.should_receive(:exists?).with("/etc/slackware-version").and_return(true)
+ expect(File).to receive(:exists?).with("/etc/slackware-version").and_return(true)
end
it "should set platform and platform_family to slackware" do
- File.should_receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0")
+ expect(File).to receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0")
@plugin.run
- @plugin[:platform].should == "slackware"
- @plugin[:platform_family].should == "slackware"
+ expect(@plugin[:platform]).to eq("slackware")
+ expect(@plugin[:platform_family]).to eq("slackware")
end
end
describe "on arch" do
before(:each) do
@plugin.lsb = nil
- File.should_receive(:exists?).with("/etc/arch-release").and_return(true)
+ expect(File).to receive(:exists?).with("/etc/arch-release").and_return(true)
end
it "should set platform to arch and platform_family to arch" do
@plugin.run
- @plugin[:platform].should == "arch"
- @plugin[:platform_family].should == "arch"
+ expect(@plugin[:platform]).to eq("arch")
+ expect(@plugin[:platform_family]).to eq("arch")
end
end
@@ -175,27 +175,27 @@ describe Ohai::System, "Linux plugin platform" do
describe "on gentoo" do
before(:each) do
@plugin.lsb = nil
- File.should_receive(:exists?).with("/etc/gentoo-release").and_return(true)
+ expect(File).to receive(:exists?).with("/etc/gentoo-release").and_return(true)
end
it "should set platform and platform_family to gentoo" do
- File.should_receive(:read).with("/etc/gentoo-release").and_return("Gentoo Base System release 1.20.1.1")
+ expect(File).to receive(:read).with("/etc/gentoo-release").and_return("Gentoo Base System release 1.20.1.1")
@plugin.run
- @plugin[:platform].should == "gentoo"
- @plugin[:platform_family].should == "gentoo"
+ expect(@plugin[:platform]).to eq("gentoo")
+ expect(@plugin[:platform_family]).to eq("gentoo")
end
end
describe "on exherbo" do
before(:each) do
@plugin.lsb = nil
- File.should_receive(:exists?).with("/etc/exherbo-release").and_return(true)
+ expect(File).to receive(:exists?).with("/etc/exherbo-release").and_return(true)
end
it "should set platform and platform_family to exherbo" do
@plugin.run
- @plugin[:platform].should == "exherbo"
- @plugin[:platform_family].should == "exherbo"
+ expect(@plugin[:platform]).to eq("exherbo")
+ expect(@plugin[:platform_family]).to eq("exherbo")
end
end
@@ -205,96 +205,96 @@ describe Ohai::System, "Linux plugin platform" do
@plugin[:lsb][:id] = "RedHatEnterpriseServer"
@plugin[:lsb][:release] = "6.1"
@plugin.run
- @plugin[:platform].should == "redhat"
- @plugin[:platform_version].should == "6.1"
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform]).to eq("redhat")
+ expect(@plugin[:platform_version]).to eq("6.1")
+ expect(@plugin[:platform_family]).to eq("rhel")
end
it "should set the platform to centos and platform_family to rhel" do
@plugin[:lsb][:id] = "CentOS"
@plugin[:lsb][:release] = "5.4"
@plugin.run
- @plugin[:platform].should == "centos"
- @plugin[:platform_version].should == "5.4"
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform]).to eq("centos")
+ expect(@plugin[:platform_version]).to eq("5.4")
+ expect(@plugin[:platform_family]).to eq("rhel")
end
it "should set the platform_family to rhel if the LSB name is oracle-ish" do
@plugin[:lsb][:id] = "EnterpriseEnterpriseServer"
@plugin.run
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform_family]).to eq("rhel")
end
it "should set the platform_family to rhel if the LSB name is amazon-ish" do
@plugin[:lsb][:id] = "Amazon"
@plugin.run
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform_family]).to eq("rhel")
end
it "should set the platform_family to fedora if the LSB name is fedora-ish" do
@plugin[:lsb][:id] = "Fedora"
@plugin.run
- @plugin[:platform_family].should == "fedora"
+ expect(@plugin[:platform_family]).to eq("fedora")
end
it "should set the platform_family to redhat if the LSB name is scientific-ish" do
@plugin[:lsb][:id] = "Scientific"
@plugin.run
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform_family]).to eq("rhel")
end
it "should set the platform_family to redhat if the LSB name is ibm-ish" do
@plugin[:lsb][:id] = "IBM_PowerKVM"
@plugin.run
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform_family]).to eq("rhel")
end
end
describe "without lsb_release results" do
before(:each) do
@plugin.lsb = nil
- File.should_receive(:exists?).with("/etc/redhat-release").and_return(true)
+ expect(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
end
it "should read the platform as centos and version as 5.3" do
- File.should_receive(:read).with("/etc/redhat-release").and_return("CentOS release 5.3")
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS release 5.3")
@plugin.run
- @plugin[:platform].should == "centos"
+ expect(@plugin[:platform]).to eq("centos")
end
it "may be that someone munged Red Hat to be RedHat" do
- File.should_receive(:read).with("/etc/redhat-release").and_return("RedHat release 5.3")
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("RedHat release 5.3")
@plugin.run
- @plugin[:platform].should == "redhat"
- @plugin[:platform_version].should == "5.3"
+ expect(@plugin[:platform]).to eq("redhat")
+ expect(@plugin[:platform_version]).to eq("5.3")
end
it "should read the platform as redhat and version as 5.3" do
- File.should_receive(:read).with("/etc/redhat-release").and_return("Red Hat release 5.3")
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat release 5.3")
@plugin.run
- @plugin[:platform].should == "redhat"
- @plugin[:platform_version].should == "5.3"
+ expect(@plugin[:platform]).to eq("redhat")
+ expect(@plugin[:platform_version]).to eq("5.3")
end
it "should read the platform as fedora and version as 13 (rawhide)" do
- File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)")
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)")
@plugin.run
- @plugin[:platform].should == "fedora"
- @plugin[:platform_version].should == "13 (rawhide)"
+ expect(@plugin[:platform]).to eq("fedora")
+ expect(@plugin[:platform_version]).to eq("13 (rawhide)")
end
it "should read the platform as fedora and version as 10" do
- File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 10")
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("Fedora release 10")
@plugin.run
- @plugin[:platform].should == "fedora"
- @plugin[:platform_version].should == "10"
+ expect(@plugin[:platform]).to eq("fedora")
+ expect(@plugin[:platform_version]).to eq("10")
end
it "should read the platform as fedora and version as 13 using to_i" do
- File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)")
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)")
@plugin.run
- @plugin[:platform].should == "fedora"
- @plugin[:platform_version].to_i.should == 13
+ expect(@plugin[:platform]).to eq("fedora")
+ expect(@plugin[:platform_version].to_i).to eq(13)
end
end
@@ -305,14 +305,14 @@ describe Ohai::System, "Linux plugin platform" do
it "should read the platform as parallels and version as 6.0.5" do
@plugin[:lsb][:id] = "CloudLinuxServer"
@plugin[:lsb][:release] = "6.5"
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
- File.should_receive(:exists?).with("/etc/parallels-release").and_return(true)
- File.should_receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
+ expect(File).to receive(:exists?).with("/etc/parallels-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
@plugin.run
- @plugin[:platform].should == "parallels"
- @plugin[:platform_version].should == "6.0.5"
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform]).to eq("parallels")
+ expect(@plugin[:platform_version]).to eq("6.0.5")
+ expect(@plugin[:platform_family]).to eq("rhel")
end
end
@@ -322,14 +322,14 @@ describe Ohai::System, "Linux plugin platform" do
end
it "should read the platform as parallels and version as 6.0.5" do
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
- File.should_receive(:exists?).with("/etc/parallels-release").and_return(true)
- File.should_receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)")
+ expect(File).to receive(:exists?).with("/etc/parallels-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)")
@plugin.run
- @plugin[:platform].should == "parallels"
- @plugin[:platform_version].should == "6.0.5"
- @plugin[:platform_family].should == "rhel"
+ expect(@plugin[:platform]).to eq("parallels")
+ expect(@plugin[:platform_version]).to eq("6.0.5")
+ expect(@plugin[:platform_family]).to eq("rhel")
end
end
end
@@ -339,25 +339,25 @@ describe Ohai::System, "Linux plugin platform" do
it "should read the platform as oracle and version as 5.7" do
@plugin[:lsb][:id] = "EnterpriseEnterpriseServer"
@plugin[:lsb][:release] = "5.7"
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
- File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
- File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
+ expect(File).to receive(:exists?).with("/etc/enterprise-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
@plugin.run
- @plugin[:platform].should == "oracle"
- @plugin[:platform_version].should == "5.7"
+ expect(@plugin[:platform]).to eq("oracle")
+ expect(@plugin[:platform_version]).to eq("5.7")
end
it "should read the platform as oracle and version as 6.1" do
@plugin[:lsb][:id] = "OracleServer"
@plugin[:lsb][:release] = "6.1"
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
- File.should_receive(:exists?).with("/etc/oracle-release").and_return(true)
- File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
+ expect(File).to receive(:exists?).with("/etc/oracle-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
@plugin.run
- @plugin[:platform].should == "oracle"
- @plugin[:platform_version].should == "6.1"
+ expect(@plugin[:platform]).to eq("oracle")
+ expect(@plugin[:platform_version]).to eq("6.1")
end
end
@@ -367,60 +367,60 @@ describe Ohai::System, "Linux plugin platform" do
end
it "should read the platform as oracle and version as 5" do
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
- File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
- File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
+ expect(File).to receive(:exists?).with("/etc/enterprise-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
@plugin.run
- @plugin[:platform].should == "oracle"
- @plugin[:platform_version].should == "5"
+ expect(@plugin[:platform]).to eq("oracle")
+ expect(@plugin[:platform_version]).to eq("5")
end
it "should read the platform as oracle and version as 5.1" do
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
- File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
- File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
+ expect(File).to receive(:exists?).with("/etc/enterprise-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)")
@plugin.run
- @plugin[:platform].should == "oracle"
- @plugin[:platform_version].should == "5.1"
+ expect(@plugin[:platform]).to eq("oracle")
+ expect(@plugin[:platform_version]).to eq("5.1")
end
it "should read the platform as oracle and version as 5.7" do
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
- File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
- File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)")
+ expect(File).to receive(:exists?).with("/etc/enterprise-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)")
@plugin.run
- @plugin[:platform].should == "oracle"
- @plugin[:platform_version].should == "5.7"
+ expect(@plugin[:platform]).to eq("oracle")
+ expect(@plugin[:platform_version]).to eq("5.7")
end
it "should read the platform as oracle and version as 6.0" do
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)")
- File.should_receive(:exists?).with("/etc/oracle-release").and_return(true)
- File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)")
+ expect(File).to receive(:exists?).with("/etc/oracle-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
@plugin.run
- @plugin[:platform].should == "oracle"
- @plugin[:platform_version].should == "6.0"
+ expect(@plugin[:platform]).to eq("oracle")
+ expect(@plugin[:platform_version]).to eq("6.0")
end
it "should read the platform as oracle and version as 6.1" do
- File.stub(:exists?).with("/etc/redhat-release").and_return(true)
- File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
- File.should_receive(:exists?).with("/etc/oracle-release").and_return(true)
- File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
+ expect(File).to receive(:exists?).with("/etc/oracle-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
@plugin.run
- @plugin[:platform].should == "oracle"
- @plugin[:platform_version].should == "6.1"
+ expect(@plugin[:platform]).to eq("oracle")
+ expect(@plugin[:platform_version]).to eq("6.1")
end
end
end
describe "on suse" do
before(:each) do
- File.should_receive(:exists?).with("/etc/SuSE-release").and_return(true)
+ expect(File).to receive(:exists?).with("/etc/SuSE-release").and_return(true)
end
describe "with lsb_release results" do
@@ -430,10 +430,10 @@ describe Ohai::System, "Linux plugin platform" do
it "should read the platform as opensuse on openSUSE" do
@plugin[:lsb][:release] = "12.1"
- File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
+ expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
@plugin.run
- @plugin[:platform].should == "opensuse"
- @plugin[:platform_family].should == "suse"
+ expect(@plugin[:platform]).to eq("opensuse")
+ expect(@plugin[:platform_family]).to eq("suse")
end
end
@@ -443,57 +443,57 @@ describe Ohai::System, "Linux plugin platform" do
end
it "should set platform and platform_family to suse and bogus verion to 10.0" do
- File.should_receive(:read).with("/etc/SuSE-release").at_least(:once).and_return("VERSION = 10.0")
+ expect(File).to receive(:read).with("/etc/SuSE-release").at_least(:once).and_return("VERSION = 10.0")
@plugin.run
- @plugin[:platform].should == "suse"
- @plugin[:platform_family].should == "suse"
+ expect(@plugin[:platform]).to eq("suse")
+ expect(@plugin[:platform_family]).to eq("suse")
end
it "should read the version as 10.1 for bogus SLES 10" do
- File.should_receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 10 (i586)\nVERSION = 10\nPATCHLEVEL = 1\n")
+ expect(File).to receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 10 (i586)\nVERSION = 10\nPATCHLEVEL = 1\n")
@plugin.run
- @plugin[:platform].should == "suse"
- @plugin[:platform_version].should == "10.1"
- @plugin[:platform_family].should == "suse"
+ expect(@plugin[:platform]).to eq("suse")
+ expect(@plugin[:platform_version]).to eq("10.1")
+ expect(@plugin[:platform_family]).to eq("suse")
end
it "should read the version as 11.2" do
- File.should_receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 11.2 (i586)\nVERSION = 11\nPATCHLEVEL = 2\n")
+ expect(File).to receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 11.2 (i586)\nVERSION = 11\nPATCHLEVEL = 2\n")
@plugin.run
- @plugin[:platform].should == "suse"
- @plugin[:platform_version].should == "11.2"
- @plugin[:platform_family].should == "suse"
+ expect(@plugin[:platform]).to eq("suse")
+ expect(@plugin[:platform_version]).to eq("11.2")
+ expect(@plugin[:platform_family]).to eq("suse")
end
it "[OHAI-272] should read the version as 11.3" do
- File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
+ expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
@plugin.run
- @plugin[:platform].should == "opensuse"
- @plugin[:platform_version].should == "11.3"
- @plugin[:platform_family].should == "suse"
+ expect(@plugin[:platform]).to eq("opensuse")
+ expect(@plugin[:platform_version]).to eq("11.3")
+ expect(@plugin[:platform_family]).to eq("suse")
end
it "[OHAI-272] should read the version as 9.1" do
- File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("SuSE Linux 9.1 (i586)\nVERSION = 9.1")
+ expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("SuSE Linux 9.1 (i586)\nVERSION = 9.1")
@plugin.run
- @plugin[:platform].should == "suse"
- @plugin[:platform_version].should == "9.1"
- @plugin[:platform_family].should == "suse"
+ expect(@plugin[:platform]).to eq("suse")
+ expect(@plugin[:platform_version]).to eq("9.1")
+ expect(@plugin[:platform_family]).to eq("suse")
end
it "[OHAI-272] should read the version as 11.4" do
- File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.4 (i586)\nVERSION = 11.4\nCODENAME = Celadon")
+ expect(File).to receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.4 (i586)\nVERSION = 11.4\nCODENAME = Celadon")
@plugin.run
- @plugin[:platform].should == "opensuse"
- @plugin[:platform_version].should == "11.4"
- @plugin[:platform_family].should == "suse"
+ expect(@plugin[:platform]).to eq("opensuse")
+ expect(@plugin[:platform_version]).to eq("11.4")
+ expect(@plugin[:platform_family]).to eq("suse")
end
it "should read the platform as opensuse on openSUSE" do
- File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.2 (x86_64)\nVERSION = 12.2\nCODENAME = Mantis\n")
+ expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.2 (x86_64)\nVERSION = 12.2\nCODENAME = Mantis\n")
@plugin.run
- @plugin[:platform].should == "opensuse"
- @plugin[:platform_family].should == "suse"
+ expect(@plugin[:platform]).to eq("opensuse")
+ expect(@plugin[:platform_family]).to eq("suse")
end
end
end
diff --git a/spec/unit/plugins/linux/uptime_spec.rb b/spec/unit/plugins/linux/uptime_spec.rb
index 0f17b484..de621d2a 100644
--- a/spec/unit/plugins/linux/uptime_spec.rb
+++ b/spec/unit/plugins/linux/uptime_spec.rb
@@ -22,28 +22,28 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux plugin uptime" do
before(:each) do
@plugin = get_plugin("uptime")
- @plugin.stub(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
@double_file = double("/proc/uptime", { :gets => "18423 989" })
- File.stub(:open).with("/proc/uptime").and_return(@double_file)
+ allow(File).to receive(:open).with("/proc/uptime").and_return(@double_file)
end
it "should set uptime_seconds to uptime" do
@plugin.run
- @plugin[:uptime_seconds].should == 18423
+ expect(@plugin[:uptime_seconds]).to eq(18423)
end
it "should set uptime to a human readable date" do
@plugin.run
- @plugin[:uptime].should == "5 hours 07 minutes 03 seconds"
+ expect(@plugin[:uptime]).to eq("5 hours 07 minutes 03 seconds")
end
it "should set idletime_seconds to uptime" do
@plugin.run
- @plugin[:idletime_seconds].should == 989
+ expect(@plugin[:idletime_seconds]).to eq(989)
end
it "should set idletime to a human readable date" do
@plugin.run
- @plugin[:idletime].should == "16 minutes 29 seconds"
+ expect(@plugin[:idletime]).to eq("16 minutes 29 seconds")
end
end
diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb
index 9fb3744f..4ed146ac 100644
--- a/spec/unit/plugins/linux/virtualization_spec.rb
+++ b/spec/unit/plugins/linux/virtualization_spec.rb
@@ -21,130 +21,130 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux virtualization platform" do
before(:each) do
@plugin = get_plugin("linux/virtualization")
- @plugin.stub(:collect_os).and_return(:linux)
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
# default to all requested Files not existing
- File.stub(:exists?).with("/proc/xen").and_return(false)
- File.stub(:exists?).with("/proc/xen/capabilities").and_return(false)
- File.stub(:exists?).with("/proc/modules").and_return(false)
- File.stub(:exists?).with("/proc/cpuinfo").and_return(false)
- File.stub(:exists?).with("/usr/sbin/dmidecode").and_return(false)
- File.stub(:exists?).with("/proc/self/status").and_return(false)
- File.stub(:exists?).with("/proc/bc/0").and_return(false)
- File.stub(:exists?).with("/proc/vz").and_return(false)
- File.stub(:exists?).with("/proc/self/cgroup").and_return(false)
+ allow(File).to receive(:exists?).with("/proc/xen").and_return(false)
+ allow(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(false)
+ allow(File).to receive(:exists?).with("/proc/modules").and_return(false)
+ allow(File).to receive(:exists?).with("/proc/cpuinfo").and_return(false)
+ allow(File).to receive(:exists?).with("/usr/sbin/dmidecode").and_return(false)
+ allow(File).to receive(:exists?).with("/proc/self/status").and_return(false)
+ allow(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
+ allow(File).to receive(:exists?).with("/proc/vz").and_return(false)
+ allow(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
end
describe "when we are checking for xen" do
it "should set xen guest if /proc/xen exists but /proc/xen/capabilities does not" do
- File.should_receive(:exists?).with("/proc/xen").and_return(true)
- File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(false)
+ expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
+ expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(false)
@plugin.run
- @plugin[:virtualization][:system].should == "xen"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:xen].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("xen")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:xen]).to eq("guest")
end
it "should set xen host if /proc/xen/capabilities contains control_d " do
- File.should_receive(:exists?).with("/proc/xen").and_return(true)
- File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
- File.stub(:read).with("/proc/xen/capabilities").and_return("control_d")
+ expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
+ expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(true)
+ allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("control_d")
@plugin.run
- @plugin[:virtualization][:system].should == "xen"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems][:xen].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("xen")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems][:xen]).to eq("host")
end
it "should set xen guest if /proc/xen/capabilities exists but is empty" do
- File.should_receive(:exists?).with("/proc/xen").and_return(true)
- File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
- File.stub(:read).with("/proc/xen/capabilities").and_return("")
+ expect(File).to receive(:exists?).with("/proc/xen").and_return(true)
+ expect(File).to receive(:exists?).with("/proc/xen/capabilities").and_return(true)
+ allow(File).to receive(:read).with("/proc/xen/capabilities").and_return("")
@plugin.run
- @plugin[:virtualization][:system].should == "xen"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:xen].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("xen")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:xen]).to eq("guest")
end
it "should not set virtualization if xen isn't there" do
- File.should_receive(:exists?).at_least(:once).and_return(false)
+ expect(File).to receive(:exists?).at_least(:once).and_return(false)
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
describe "when we are checking for kvm" do
it "should set kvm host if /proc/modules contains kvm" do
- File.should_receive(:exists?).with("/proc/modules").and_return(true)
- File.stub(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
+ expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
+ allow(File).to receive(:read).with("/proc/modules").and_return("kvm 165872 1 kvm_intel")
@plugin.run
- @plugin[:virtualization][:system].should == "kvm"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems][:kvm].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("host")
end
it "should set kvm guest if /proc/cpuinfo contains QEMU Virtual CPU" do
- File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
- File.stub(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
+ expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
+ allow(File).to receive(:read).with("/proc/cpuinfo").and_return("QEMU Virtual CPU")
@plugin.run
- @plugin[:virtualization][:system].should == "kvm"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:kvm].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
end
it "should set kvm guest if /proc/cpuinfo contains Common KVM processor" do
- File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
- File.stub(:read).with("/proc/cpuinfo").and_return("Common KVM processor")
+ expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
+ allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common KVM processor")
@plugin.run
- @plugin[:virtualization][:system].should == "kvm"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:kvm].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
end
it "should set kvm guest if /proc/cpuinfo contains Common 32-bit KVM processor" do
- File.should_receive(:exists?).with("/proc/cpuinfo").and_return(true)
- File.stub(:read).with("/proc/cpuinfo").and_return("Common 32-bit KVM processor")
+ expect(File).to receive(:exists?).with("/proc/cpuinfo").and_return(true)
+ allow(File).to receive(:read).with("/proc/cpuinfo").and_return("Common 32-bit KVM processor")
@plugin.run
- @plugin[:virtualization][:system].should == "kvm"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:kvm].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
end
it "should not set virtualization if kvm isn't there" do
- File.should_receive(:exists?).at_least(:once).and_return(false)
+ expect(File).to receive(:exists?).at_least(:once).and_return(false)
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
describe "when we are checking for VirtualBox" do
it "should set vbox host if /proc/modules contains vboxdrv" do
- File.should_receive(:exists?).with("/proc/modules").and_return(true)
- File.stub(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt")
+ expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
+ allow(File).to receive(:read).with("/proc/modules").and_return("vboxdrv 268268 3 vboxnetadp,vboxnetflt")
@plugin.run
- @plugin[:virtualization][:system].should == "vbox"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems][:vbox].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems][:vbox]).to eq("host")
end
it "should set vbox gues if /proc/modules contains vboxguest" do
- File.should_receive(:exists?).with("/proc/modules").and_return(true)
- File.stub(:read).with("/proc/modules").and_return("vboxguest 214901 2 vboxsf, Live 0xffffffffa00db000 (OF)")
+ expect(File).to receive(:exists?).with("/proc/modules").and_return(true)
+ allow(File).to receive(:read).with("/proc/modules").and_return("vboxguest 214901 2 vboxsf, Live 0xffffffffa00db000 (OF)")
@plugin.run
- @plugin[:virtualization][:system].should == "vbox"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:vbox].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:vbox]).to eq("guest")
end
it "should not set virtualization if vbox isn't there" do
- File.should_receive(:exists?).at_least(:once).and_return(false)
+ expect(File).to receive(:exists?).at_least(:once).and_return(false)
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
describe "when we are parsing dmidecode" do
before(:each) do
- File.should_receive(:exists?).with("/usr/sbin/dmidecode").and_return(true)
+ expect(File).to receive(:exists?).with("/usr/sbin/dmidecode").and_return(true)
end
it "should set virtualpc guest if dmidecode detects Microsoft Virtual Machine" do
@@ -157,11 +157,11 @@ System Information
UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
Wake-up Type: Power Switch
MSVPC
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_vpc_dmidecode, ""))
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, ms_vpc_dmidecode, ""))
@plugin.run
- @plugin[:virtualization][:system].should == "virtualpc"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:virtualpc].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("virtualpc")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:virtualpc]).to eq("guest")
end
it "should set vmware guest if dmidecode detects VMware Virtual Platform" do
@@ -176,11 +176,11 @@ System Information
SKU Number: Not Specified
Family: Not Specified
VMWARE
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vmware_dmidecode, ""))
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vmware_dmidecode, ""))
@plugin.run
- @plugin[:virtualization][:system].should == "vmware"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:vmware].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("vmware")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:vmware]).to eq("guest")
end
it "should set vbox guest if dmidecode detects Oracle Corporation" do
@@ -197,105 +197,105 @@ Base Board Information
Type: Motherboard
Contained Object Handles: 0
VBOX
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vbox_dmidecode, ""))
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vbox_dmidecode, ""))
@plugin.run
- @plugin[:virtualization][:system].should == "vbox"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:vbox].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("vbox")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:vbox]).to eq("guest")
end
it "should run dmidecode and not set virtualization if nothing is detected" do
- @plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
describe "when we are checking for Linux-VServer" do
it "should set Linux-VServer host if /proc/self/status contains s_context: 0" do
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
- File.stub(:read).with("/proc/self/status").and_return("s_context: 0")
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 0")
@plugin.run
- @plugin[:virtualization][:system].should == "linux-vserver"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
end
it "should set Linux-VServer host if /proc/self/status contains VxID: 0" do
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
- File.stub(:read).with("/proc/self/status").and_return("VxID: 0")
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
@plugin.run
- @plugin[:virtualization][:system].should == "linux-vserver"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
end
it "should set Linux-VServer host if /proc/self/status contains multiple space VxID: 0" do
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
- File.stub(:read).with("/proc/self/status").and_return("VxID: 0")
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 0")
@plugin.run
- @plugin[:virtualization][:system].should == "linux-vserver"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
end
it "should set Linux-VServer host if /proc/self/status contains tabbed VxID:\t0" do
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
- File.stub(:read).with("/proc/self/status").and_return("VxID:\t0")
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/status").and_return("VxID:\t0")
@plugin.run
- @plugin[:virtualization][:system].should == "linux-vserver"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems]['linux-vserver'].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("host")
end
it "should set Linux-VServer guest if /proc/self/status contains s_context > 0" do
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
- File.stub(:read).with("/proc/self/status").and_return("s_context: 2")
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/status").and_return("s_context: 2")
@plugin.run
- @plugin[:virtualization][:system].should == "linux-vserver"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems]['linux-vserver'].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("guest")
end
it "should set Linux-VServer guest if /proc/self/status contains VxID > 0" do
- File.should_receive(:exists?).with("/proc/self/status").and_return(true)
- File.stub(:read).with("/proc/self/status").and_return("VxID: 2")
+ expect(File).to receive(:exists?).with("/proc/self/status").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/status").and_return("VxID: 2")
@plugin.run
- @plugin[:virtualization][:system].should == "linux-vserver"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems]['linux-vserver'].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("linux-vserver")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems]['linux-vserver']).to eq("guest")
end
it "should not set virtualization if Linux-VServer isn't there" do
- File.should_receive(:exists?).at_least(:once).and_return(false)
+ expect(File).to receive(:exists?).at_least(:once).and_return(false)
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
describe "when we are checking for openvz" do
it "should set openvz host if /proc/bc/0 exists" do
- File.should_receive(:exists?).with("/proc/bc/0").and_return(true)
+ expect(File).to receive(:exists?).with("/proc/bc/0").and_return(true)
@plugin.run
- @plugin[:virtualization][:system].should == "openvz"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems][:openvz].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("openvz")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems][:openvz]).to eq("host")
end
it "should set openvz guest if /proc/bc/0 doesn't exist and /proc/vz exists" do
- File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
- File.should_receive(:exists?).with("/proc/vz").and_return(true)
+ expect(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
+ expect(File).to receive(:exists?).with("/proc/vz").and_return(true)
@plugin.run
- @plugin[:virtualization][:system].should == "openvz"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:openvz].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("openvz")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:openvz]).to eq("guest")
end
it "should not set virtualization if openvz isn't there" do
- File.should_receive(:exists?).with("/proc/bc/0").and_return(false)
- File.should_receive(:exists?).with("/proc/vz").and_return(false)
+ expect(File).to receive(:exists?).with("/proc/bc/0").and_return(false)
+ expect(File).to receive(:exists?).with("/proc/vz").and_return(false)
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
@@ -311,12 +311,12 @@ VBOX
2:cpu:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc
1:cpuset:/
CGROUP
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
@plugin.run
- @plugin[:virtualization][:system].should == "lxc"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:lxc].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("lxc")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
end
it "should set lxc guest if /proc/self/cgroup exist and there are /lxc/<name> mounts" do
@@ -330,12 +330,12 @@ CGROUP
2:cpu:/lxc/vanilla
1:cpuset:/lxc/vanilla
CGROUP
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
@plugin.run
- @plugin[:virtualization][:system].should == "lxc"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:lxc].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("lxc")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
end
it "should set lxc guest if /proc/self/cgroup exist and there are /docker/<name> mounts" do
@@ -351,12 +351,12 @@ CGROUP
3:cpuset:/
2:name=systemd:/system.slice/docker.service
CGROUP
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
@plugin.run
- @plugin[:virtualization][:system].should == "lxc"
- @plugin[:virtualization][:role].should == "guest"
- @plugin[:virtualization][:systems][:lxc].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("lxc")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
+ expect(@plugin[:virtualization][:systems][:lxc]).to eq("guest")
end
it "should set not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do
@@ -370,10 +370,10 @@ CGROUP
2:cpu:/Charlie
1:cpuset:/Charlie
CGROUP
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
context "/proc/self/cgroup only has / mounts" do
@@ -388,47 +388,47 @@ CGROUP
2:cpu:/
1:cpuset:/
CGROUP
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(true)
- File.stub(:read).with("/proc/self/cgroup").and_return(self_cgroup)
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(true)
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
end
it "sets lxc host if lxc-version exists" do
- @plugin.stub(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
+ allow(@plugin).to receive(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
@plugin.run
- @plugin[:virtualization][:system].should == "lxc"
- @plugin[:virtualization][:role].should == "host"
- @plugin[:virtualization][:systems][:lxc].should == "host"
+ expect(@plugin[:virtualization][:system]).to eq("lxc")
+ expect(@plugin[:virtualization][:role]).to eq("host")
+ expect(@plugin[:virtualization][:systems][:lxc]).to eq("host")
end
it "does not set the old virtualization attributes if they are already set" do
- @plugin.stub(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
+ allow(@plugin).to receive(:lxc_version_exists?).and_return("/usr/bin/lxc-version")
@plugin[:virtualization] = Mash.new
@plugin[:virtualization][:system] = "the cloud"
@plugin[:virtualization][:role] = "cumulonimbus"
@plugin.run
- @plugin[:virtualization][:system].should_not == "lxc"
- @plugin[:virtualization][:role].should_not == "host"
+ expect(@plugin[:virtualization][:system]).not_to eq("lxc")
+ expect(@plugin[:virtualization][:role]).not_to eq("host")
end
it "does not set lxc host if lxc-version does not exist" do
- @plugin.stub(:lxc_version_exists?).and_return(false)
+ allow(@plugin).to receive(:lxc_version_exists?).and_return(false)
@plugin.run
- @plugin[:virtualization][:system].should be_nil
- @plugin[:virtualization][:role].should be_nil
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization][:system]).to be_nil
+ expect(@plugin[:virtualization][:role]).to be_nil
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
it "should not set virtualization if /proc/self/cgroup isn't there" do
- File.should_receive(:exists?).with("/proc/self/cgroup").and_return(false)
+ expect(File).to receive(:exists?).with("/proc/self/cgroup").and_return(false)
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
it "should not set virtualization if no tests match" do
@plugin.run
- @plugin[:virtualization].should == {'systems' => {}}
+ expect(@plugin[:virtualization]).to eq({'systems' => {}})
end
end
diff --git a/spec/unit/plugins/lua_spec.rb b/spec/unit/plugins/lua_spec.rb
index 16b34c7a..f61a2d51 100644
--- a/spec/unit/plugins/lua_spec.rb
+++ b/spec/unit/plugins/lua_spec.rb
@@ -27,24 +27,24 @@ describe Ohai::System, "plugin lua" do
@plugin = get_plugin("lua")
@plugin[:languages] = Mash.new
@stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
- @plugin.stub(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr))
+ allow(@plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr))
end
it "should get the lua version from running lua -v" do
- @plugin.should_receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr))
+ expect(@plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr))
@plugin.run
end
it "should set languages[:lua][:version]" do
@plugin.run
- @plugin.languages[:lua][:version].should eql("5.1.2")
+ expect(@plugin.languages[:lua][:version]).to eql("5.1.2")
end
it "should not set the languages[:lua] tree up if lua command fails" do
@stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n"
- @plugin.stub(:shell_out).with("lua -v").and_return(mock_shell_out(1, "", @stderr))
+ allow(@plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(1, "", @stderr))
@plugin.run
- @plugin.languages.should_not have_key(:lua)
+ expect(@plugin.languages).not_to have_key(:lua)
end
end
diff --git a/spec/unit/plugins/mono_spec.rb b/spec/unit/plugins/mono_spec.rb
index 2d71d83e..952e00b0 100644
--- a/spec/unit/plugins/mono_spec.rb
+++ b/spec/unit/plugins/mono_spec.rb
@@ -25,24 +25,24 @@ describe Ohai::System, "plugin mono" do
@plugin = get_plugin("mono")
@plugin[:languages] = Mash.new
@stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n"
- @plugin.stub(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
end
it "should get the mono version from running mono -V" do
- @plugin.should_receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set languages[:mono][:version]" do
@plugin.run
- @plugin.languages[:mono][:version].should eql("1.2.6")
+ expect(@plugin.languages[:mono][:version]).to eql("1.2.6")
end
it "should not set the languages[:mono] tree up if mono command fails" do
@stdout = "Mono JIT compiler version 1.2.6 (tarball)\nCopyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com\n"
- @plugin.stub(:shell_out).with("mono -V").and_return(mock_shell_out(1, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("mono -V").and_return(mock_shell_out(1, @stdout, ""))
@plugin.run
- @plugin.languages.should_not have_key(:mono)
+ expect(@plugin.languages).not_to have_key(:mono)
end
end
diff --git a/spec/unit/plugins/netbsd/hostname_spec.rb b/spec/unit/plugins/netbsd/hostname_spec.rb
index d9f7b581..433d3d0c 100644
--- a/spec/unit/plugins/netbsd/hostname_spec.rb
+++ b/spec/unit/plugins/netbsd/hostname_spec.rb
@@ -22,10 +22,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "NetBSD hostname plugin" do
before(:each) do
@plugin = get_plugin("hostname")
- @plugin.stub(:collect_os).and_return(:netbsd)
- @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
- @plugin.stub(:resolve_fqdn).and_return("katie.bethell")
+ allow(@plugin).to receive(:collect_os).and_return(:netbsd)
+ allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
@@ -34,11 +34,11 @@ describe Ohai::System, "NetBSD hostname plugin" do
it "should use #resolve_fqdn to find the fqdn" do
@plugin.run
- @plugin[:fqdn].should == "katie.bethell"
+ expect(@plugin[:fqdn]).to eq("katie.bethell")
end
it "should set the domain to everything after the first dot of the fqdn" do
@plugin.run
- @plugin[:domain].should == "bethell"
+ expect(@plugin[:domain]).to eq("bethell")
end
end
diff --git a/spec/unit/plugins/netbsd/kernel_spec.rb b/spec/unit/plugins/netbsd/kernel_spec.rb
index f08f2caa..c3fa73de 100644
--- a/spec/unit/plugins/netbsd/kernel_spec.rb
+++ b/spec/unit/plugins/netbsd/kernel_spec.rb
@@ -22,15 +22,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "NetBSD kernel plugin" do
before(:each) do
@plugin = get_plugin("kernel")
- @plugin.stub(:collect_os).and_return(:netbsd)
- @plugin.stub(:init_kernel).and_return({})
- @plugin.stub(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
- @plugin.stub(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/bin/modstat" )}").and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:netbsd)
+ allow(@plugin).to receive(:init_kernel).and_return({})
+ allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/bin/modstat" )}").and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
end
it "should set the kernel_os to the kernel_name value" do
@plugin.run
- @plugin[:kernel][:os].should == @plugin[:kernel][:name]
+ expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
end
end
diff --git a/spec/unit/plugins/netbsd/platform_spec.rb b/spec/unit/plugins/netbsd/platform_spec.rb
index f1a91758..f3536090 100644
--- a/spec/unit/plugins/netbsd/platform_spec.rb
+++ b/spec/unit/plugins/netbsd/platform_spec.rb
@@ -21,18 +21,18 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "NetBSD plugin platform" do
before(:each) do
@plugin = get_plugin("netbsd/platform")
- @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "NetBSD\n", ""))
- @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
- @plugin.stub(:collect_os).and_return(:netbsd)
+ allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "NetBSD\n", ""))
+ allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:netbsd)
end
it "should set platform to lowercased lsb[:id]" do
@plugin.run
- @plugin[:platform].should == "netbsd"
+ expect(@plugin[:platform]).to eq("netbsd")
end
it "should set platform_version to lsb[:release]" do
@plugin.run
- @plugin[:platform_version].should == "4.5"
+ expect(@plugin[:platform_version]).to eq("4.5")
end
end
diff --git a/spec/unit/plugins/network_spec.rb b/spec/unit/plugins/network_spec.rb
index d088dfef..03ea6b81 100644
--- a/spec/unit/plugins/network_spec.rb
+++ b/spec/unit/plugins/network_spec.rb
@@ -20,8 +20,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
def it_doesnt_fail
it "doesnt fail" do
- Ohai::Log.stub(:warn)
- Ohai::Log.should_not_receive(:debug).with(/^Plugin network threw exception/)
+ allow(Ohai::Log).to receive(:warn)
+ expect(Ohai::Log).not_to receive(:debug).with(/^Plugin network threw exception/)
@plugin.run
end
end
@@ -32,11 +32,11 @@ def it_populates_ipaddress_attributes
it "populates ipaddress, macaddress and ip6address" do
begin
- Ohai::Log.stub(:warn)
- Ohai::Log.should_not_receive(:debug).with(/^Plugin network threw exception/)
+ allow(Ohai::Log).to receive(:warn)
+ expect(Ohai::Log).not_to receive(:debug).with(/^Plugin network threw exception/)
@plugin.run
%w{ ipaddress macaddress ip6address }.each do |attribute|
- @plugin.should have_key(attribute)
+ expect(@plugin).to have_key(attribute)
end
rescue Exception
puts "RSpec context: #{source}"
@@ -313,9 +313,9 @@ describe Ohai::System, "Network Plugin" do
it "detects {ip,ip6,mac}address" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.33"
- @plugin["macaddress"].should == "00:16:3E:2F:36:79"
- @plugin["ip6address"].should == "3ffe:1111:2222::33"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
@@ -330,18 +330,18 @@ describe Ohai::System, "Network Plugin" do
it "detects {ip,ip6}address" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.33"
- @plugin["ip6address"].should == "3ffe:1111:3333::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
it "set macaddress from the ipv4 setup" do
@plugin.run
- @plugin["macaddress"].should == "00:16:3E:2F:36:79"
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
end
it "informs about this setup" do
- Ohai::Log.should_receive(:debug).with(/^ipaddress and ip6address are set from different interfaces/)
- Ohai::Log.stub(:debug)
+ expect(Ohai::Log).to receive(:debug).with(/^ipaddress and ip6address are set from different interfaces/)
+ allow(Ohai::Log).to receive(:debug)
@plugin.run
end
end
@@ -359,19 +359,19 @@ describe Ohai::System, "Network Plugin" do
it "detects {ip,ip6}address" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.33"
- @plugin["ip6address"].should == "3ffe:1111:3333::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
it "doesn't set macaddress, ipv4 setup is valid and has precedence over ipv6" do
- Ohai::Log.should_not_receive(:warn).with(/^unable to detect macaddress/)
+ expect(Ohai::Log).not_to receive(:warn).with(/^unable to detect macaddress/)
@plugin.run
- @plugin["macaddress"].should be_nil
+ expect(@plugin["macaddress"]).to be_nil
end
it "informs about this setup" do
- Ohai::Log.should_receive(:debug).with(/^ipaddress and ip6address are set from different interfaces/)
- Ohai::Log.stub(:debug)
+ expect(Ohai::Log).to receive(:debug).with(/^ipaddress and ip6address are set from different interfaces/)
+ allow(Ohai::Log).to receive(:debug)
@plugin.run
end
end
@@ -387,16 +387,16 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "picks {ip,ip6,mac}address" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ipaddress"].should == "192.168.99.11"
- @plugin["macaddress"].should == "00:16:3E:2F:36:80"
- @plugin["ip6address"].should == "3ffe:1111:3333::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
it "warns about this conflict" do
- Ohai::Log.should_receive(:debug).with(/^\[inet\] no ipaddress\/mask on eth1/).once
- Ohai::Log.should_receive(:debug).with(/^\[inet6\] no ipaddress\/mask on eth1/).once
+ expect(Ohai::Log).to receive(:debug).with(/^\[inet\] no ipaddress\/mask on eth1/).once
+ expect(Ohai::Log).to receive(:debug).with(/^\[inet6\] no ipaddress\/mask on eth1/).once
@plugin.run
end
end
@@ -408,11 +408,11 @@ describe Ohai::System, "Network Plugin" do
end
it "picks {ip,ip6,mac}address" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.33"
- @plugin["macaddress"].should == "00:16:3E:2F:36:79"
- @plugin["ip6address"].should == "3ffe:1111:2222::33"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
@@ -425,19 +425,19 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "doesn't detect {ip,ip6,mac}address" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ipaddress"].should be_nil
- @plugin["macaddress"].should be_nil
- @plugin["ip6address"].should be_nil
+ expect(@plugin["ipaddress"]).to be_nil
+ expect(@plugin["macaddress"]).to be_nil
+ expect(@plugin["ip6address"]).to be_nil
end
it "warns about this conflict" do
- Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
- Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
- Ohai::Log.should_receive(:warn).with(/^\[inet\] no ip address on eth0/).once
- Ohai::Log.should_receive(:debug).with(/^unable to detect ip6address/).once
- Ohai::Log.should_receive(:warn).with(/^\[inet6\] no ip address on eth0/).once
+ expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once
+ expect(Ohai::Log).to receive(:warn).with(/^unable to detect macaddress/).once
+ expect(Ohai::Log).to receive(:warn).with(/^\[inet\] no ip address on eth0/).once
+ expect(Ohai::Log).to receive(:debug).with(/^unable to detect ip6address/).once
+ expect(Ohai::Log).to receive(:warn).with(/^\[inet6\] no ip address on eth0/).once
@plugin.run
end
end
@@ -456,17 +456,17 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "doesn't detect {ip,ip6,mac}address" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ipaddress"].should be_nil
- @plugin["macaddress"].should be_nil
- @plugin["ip6address"].should be_nil
+ expect(@plugin["ipaddress"]).to be_nil
+ expect(@plugin["macaddress"]).to be_nil
+ expect(@plugin["ip6address"]).to be_nil
end
it "should warn about it" do
- Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
- Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
- Ohai::Log.should_receive(:debug).with(/^unable to detect ip6address/).once
+ expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once
+ expect(Ohai::Log).to receive(:warn).with(/^unable to detect macaddress/).once
+ expect(Ohai::Log).to receive(:debug).with(/^unable to detect ip6address/).once
@plugin.run
end
end
@@ -505,9 +505,9 @@ describe Ohai::System, "Network Plugin" do
it "sets {ip,ip6,mac}address correctly" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.33"
- @plugin["macaddress"].should == "00:16:3E:2F:36:79"
- @plugin["ip6address"].should == "3ffe:1111:2222::33"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
@@ -531,9 +531,9 @@ describe Ohai::System, "Network Plugin" do
it "sets {ip,ip6,mac}address correctly" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.99"
- @plugin["macaddress"].should == "00:16:3E:2F:36:79"
- @plugin["ip6address"].should == "3ffe:1111:2222:0:4444::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.99")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222:0:4444::1")
end
end
@@ -569,9 +569,9 @@ describe Ohai::System, "Network Plugin" do
it "sets {ip,ip6,mac}address correctly" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.33"
- @plugin["macaddress"].should == "00:16:3E:2F:36:79"
- @plugin["ip6address"].should == "3ffe:1111:2222::33"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.33")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
@@ -595,9 +595,9 @@ describe Ohai::System, "Network Plugin" do
it "sets {ip,ip6,mac}address correctly" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.32"
- @plugin["macaddress"].should == "00:16:3E:2F:36:79"
- @plugin["ip6address"].should == "3ffe:1111:2222::32"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.32")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::32")
end
end
end
@@ -616,13 +616,13 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "picks {ip,mac,ip6}address from the first interface" do
- Ohai::Log.should_receive(:debug).with(/^\[inet\] no default interface/).once
- Ohai::Log.should_receive(:debug).with(/^\[inet6\] no default interface/).once
- Ohai::Log.stub(:debug)
+ expect(Ohai::Log).to receive(:debug).with(/^\[inet\] no default interface/).once
+ expect(Ohai::Log).to receive(:debug).with(/^\[inet6\] no default interface/).once
+ allow(Ohai::Log).to receive(:debug)
@plugin.run
- @plugin["ipaddress"].should == "192.168.99.11"
- @plugin["macaddress"].should == "00:16:3E:2F:36:80"
- @plugin["ip6address"].should == "3ffe:1111:3333::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
end
@@ -639,13 +639,13 @@ describe Ohai::System, "Network Plugin" do
it_populates_ipaddress_attributes
it "prefers global scope addressses to set {ip,mac,ip6}address" do
- Ohai::Log.should_receive(:debug).with(/^\[inet\] no default interface/).once
- Ohai::Log.should_receive(:debug).with(/^\[inet6\] no default interface/).once
- Ohai::Log.stub(:debug)
+ expect(Ohai::Log).to receive(:debug).with(/^\[inet\] no default interface/).once
+ expect(Ohai::Log).to receive(:debug).with(/^\[inet6\] no default interface/).once
+ allow(Ohai::Log).to receive(:debug)
@plugin.run
- @plugin["ipaddress"].should == "192.168.99.11"
- @plugin["macaddress"].should == "00:16:3E:2F:36:80"
- @plugin["ip6address"].should == "3ffe:1111:3333::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
end
end
@@ -663,9 +663,9 @@ describe Ohai::System, "Network Plugin" do
it "picks {ip,mac,ip6}address from the default interface" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.99.11"
- @plugin["macaddress"].should == "00:16:3E:2F:36:80"
- @plugin["ip6address"].should == "3ffe:1111:3333::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
end
@@ -678,7 +678,7 @@ describe Ohai::System, "Network Plugin" do
it "picks {ip,mac,ip6}address from the default interface" do
@plugin.run
- @plugin["ip6address"].should == "3ffe:1111:2222::33"
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
end
end
@@ -700,9 +700,9 @@ describe Ohai::System, "Network Plugin" do
it "picks {ip,mac,ip6}address from the default interface" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.99.11"
- @plugin["macaddress"].should == "00:16:3E:2F:36:80"
- @plugin["ip6address"].should == "3ffe:1111:3333::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.99.11")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:80")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:3333::1")
end
end
end
@@ -744,9 +744,9 @@ describe Ohai::System, "Network Plugin" do
it "picks {ip,mac,ip6}address from the default interface" do
@plugin.run
- @plugin["ipaddress"].should == "192.168.66.99"
- @plugin["macaddress"].should == "00:16:3E:2F:36:81"
- @plugin["ip6address"].should == "3ffe:1111:2222:0:4444::1"
+ expect(@plugin["ipaddress"]).to eq("192.168.66.99")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:81")
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222:0:4444::1")
end
end
@@ -762,27 +762,27 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "can't detect ipaddress" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ipaddress"].should be_nil
+ expect(@plugin["ipaddress"]).to be_nil
end
it "warns about not being able to set {ip,mac}address (ipv4)" do
- Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
- Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
+ expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once
+ expect(Ohai::Log).to receive(:warn).with(/^unable to detect macaddress/).once
@plugin.run
end
it "sets {ip6,mac}address" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ip6address"].should == "3ffe:1111:2222::33"
- @plugin["macaddress"].should == "00:16:3E:2F:36:79"
+ expect(@plugin["ip6address"]).to eq("3ffe:1111:2222::33")
+ expect(@plugin["macaddress"]).to eq("00:16:3E:2F:36:79")
end
it "informs about macaddress being set using the ipv6 setup" do
- Ohai::Log.should_receive(:debug).with(/^macaddress set to 00:16:3E:2F:36:79 from the ipv6 setup/).once
- Ohai::Log.stub(:debug)
+ expect(Ohai::Log).to receive(:debug).with(/^macaddress set to 00:16:3E:2F:36:79 from the ipv6 setup/).once
+ allow(Ohai::Log).to receive(:debug)
@plugin.run
end
end
@@ -816,13 +816,13 @@ describe Ohai::System, "Network Plugin" do
it "detects ip6address" do
@plugin.run
- @plugin["ip6address"].should == @expected_results[os]["ip6address"]
+ expect(@plugin["ip6address"]).to eq(@expected_results[os]["ip6address"])
end
it "doesn't overwrite {ip,mac}address" do
@plugin.run
- @plugin["ipaddress"].should == "10.11.12.13"
- @plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
+ expect(@plugin["ipaddress"]).to eq("10.11.12.13")
+ expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
end
end
@@ -850,13 +850,13 @@ describe Ohai::System, "Network Plugin" do
it "detects {ip,mac}address" do
@plugin.run
- @plugin["ipaddress"].should == @expected_results[os]["ipaddress"]
- @plugin["macaddress"].should == @expected_results[os]["macaddress"]
+ expect(@plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
+ expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
end
it "doesn't overwrite ip6address" do
@plugin.run
- @plugin["ip6address"].should == "3ffe:8888:9999::1"
+ expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
@@ -875,27 +875,27 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "can't detect ipaddress (ipv4)" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ipaddress"].should be_nil
+ expect(@plugin["ipaddress"]).to be_nil
end
it "can't detect macaddress either" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["macaddress"].should be_nil
+ expect(@plugin["macaddress"]).to be_nil
end
it "warns about not being able to set {ip,mac}address" do
- Ohai::Log.should_receive(:warn).with(/^unable to detect ipaddress/).once
- Ohai::Log.should_receive(:warn).with(/^unable to detect macaddress/).once
+ expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once
+ expect(Ohai::Log).to receive(:warn).with(/^unable to detect macaddress/).once
@plugin.run
end
it "doesn't overwrite ip6address" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ip6address"].should == "3ffe:8888:9999::1"
+ expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
end
@@ -925,13 +925,13 @@ describe Ohai::System, "Network Plugin" do
it "detects ipaddress and overwrite macaddress" do
@plugin.run
- @plugin["ipaddress"].should == @expected_results[os]["ipaddress"]
- @plugin["macaddress"].should == @expected_results[os]["macaddress"]
+ expect(@plugin["ipaddress"]).to eq(@expected_results[os]["ipaddress"])
+ expect(@plugin["macaddress"]).to eq(@expected_results[os]["macaddress"])
end
it "doesn't overwrite ip6address" do
@plugin.run
- @plugin["ip6address"].should == "3ffe:8888:9999::1"
+ expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
@@ -951,16 +951,16 @@ describe Ohai::System, "Network Plugin" do
it_doesnt_fail
it "can't set ipaddress" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ipaddress"].should be_nil
+ expect(@plugin["ipaddress"]).to be_nil
end
it "doesn't overwrite {ip6,mac}address" do
- Ohai::Log.stub(:warn)
+ allow(Ohai::Log).to receive(:warn)
@plugin.run
- @plugin["ip6address"].should == "3ffe:8888:9999::1"
- @plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
+ expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
+ expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
end
end
end
@@ -976,9 +976,9 @@ describe Ohai::System, "Network Plugin" do
it "doesn't overwrite {ip,mac,ip6}address" do
@plugin.run
- @plugin["ipaddress"].should == "10.11.12.13"
- @plugin["macaddress"].should == "00:AA:BB:CC:DD:EE"
- @plugin["ip6address"].should == "3ffe:8888:9999::1"
+ expect(@plugin["ipaddress"]).to eq("10.11.12.13")
+ expect(@plugin["macaddress"]).to eq("00:AA:BB:CC:DD:EE")
+ expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
@@ -992,9 +992,9 @@ describe Ohai::System, "Network Plugin" do
it "doesn't overwrite {ip,mac,ip6}address" do
@plugin.run
- @plugin["ipaddress"].should == "10.11.12.13"
- @plugin["macaddress"].should == nil
- @plugin["ip6address"].should == "3ffe:8888:9999::1"
+ expect(@plugin["ipaddress"]).to eq("10.11.12.13")
+ expect(@plugin["macaddress"]).to eq(nil)
+ expect(@plugin["ip6address"]).to eq("3ffe:8888:9999::1")
end
end
diff --git a/spec/unit/plugins/nodejs_spec.rb b/spec/unit/plugins/nodejs_spec.rb
index 14e5ae3c..32b87c0d 100644
--- a/spec/unit/plugins/nodejs_spec.rb
+++ b/spec/unit/plugins/nodejs_spec.rb
@@ -26,24 +26,24 @@ describe Ohai::System, "plugin nodejs" do
@plugin = get_plugin("nodejs")
@plugin[:languages] = Mash.new
@stdout = "v0.8.11\n"
- @plugin.stub(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
end
it "should get the nodejs version from running node -v" do
- @plugin.should_receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set languages[:nodejs][:version]" do
@plugin.run
- @plugin.languages[:nodejs][:version].should eql("0.8.11")
+ expect(@plugin.languages[:nodejs][:version]).to eql("0.8.11")
end
it "should not set the languages[:nodejs] tree up if node command fails" do
@stdout = "v0.8.11\n"
- @plugin.stub(:shell_out).with("node -v").and_return(mock_shell_out(1, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("node -v").and_return(mock_shell_out(1, @stdout, ""))
@plugin.run
- @plugin.languages.should_not have_key(:nodejs)
+ expect(@plugin.languages).not_to have_key(:nodejs)
end
end
diff --git a/spec/unit/plugins/ohai_spec.rb b/spec/unit/plugins/ohai_spec.rb
index cea24ee4..38eb907d 100644
--- a/spec/unit/plugins/ohai_spec.rb
+++ b/spec/unit/plugins/ohai_spec.rb
@@ -27,6 +27,6 @@ describe Ohai::System, "plugin ohai" do
it "should set [:chef_packages][:ohai][:version] to the current version" do
@plugin.run
- @plugin[:chef_packages][:ohai][:version].should == Ohai::VERSION
+ expect(@plugin[:chef_packages][:ohai][:version]).to eq(Ohai::VERSION)
end
end
diff --git a/spec/unit/plugins/ohai_time_spec.rb b/spec/unit/plugins/ohai_time_spec.rb
index 003f4da3..6f503f21 100644
--- a/spec/unit/plugins/ohai_time_spec.rb
+++ b/spec/unit/plugins/ohai_time_spec.rb
@@ -25,21 +25,21 @@ describe Ohai::System, "plugin ohai_time" do
end
it "should get the current time" do
- Time.should_receive(:now)
+ expect(Time).to receive(:now)
@plugin.run
end
it "should turn the time into a floating point number" do
time = Time.now
- time.should_receive(:to_f)
- Time.stub(:now).and_return(time)
+ expect(time).to receive(:to_f)
+ allow(Time).to receive(:now).and_return(time)
@plugin.run
end
it "should set ohai_time to the current time" do
time = Time.now
- Time.stub(:now).and_return(time)
+ allow(Time).to receive(:now).and_return(time)
@plugin.run
- @plugin[:ohai_time].should == time.to_f
+ expect(@plugin[:ohai_time]).to eq(time.to_f)
end
end
diff --git a/spec/unit/plugins/openbsd/hostname_spec.rb b/spec/unit/plugins/openbsd/hostname_spec.rb
index f2efc594..9a0317da 100644
--- a/spec/unit/plugins/openbsd/hostname_spec.rb
+++ b/spec/unit/plugins/openbsd/hostname_spec.rb
@@ -22,10 +22,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "OpenBSD hostname plugin" do
before(:each) do
@plugin = get_plugin("hostname")
- @plugin.stub(:collect_os).and_return(:openbsd)
- @plugin.stub(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
- @plugin.stub(:resolve_fqdn).and_return("katie.bethell")
+ allow(@plugin).to receive(:collect_os).and_return(:openbsd)
+ allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie\n", ""))
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
+ allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
end
it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
@@ -34,11 +34,11 @@ describe Ohai::System, "OpenBSD hostname plugin" do
it "should use #resolve_fqdn to find the fqdn" do
@plugin.run
- @plugin[:fqdn].should == "katie.bethell"
+ expect(@plugin[:fqdn]).to eq("katie.bethell")
end
it "should set the domain to everything after the first dot of the fqdn" do
@plugin.run
- @plugin[:domain].should == "bethell"
+ expect(@plugin[:domain]).to eq("bethell")
end
end
diff --git a/spec/unit/plugins/openbsd/kernel_spec.rb b/spec/unit/plugins/openbsd/kernel_spec.rb
index 1d1643b5..90e49140 100644
--- a/spec/unit/plugins/openbsd/kernel_spec.rb
+++ b/spec/unit/plugins/openbsd/kernel_spec.rb
@@ -22,16 +22,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "OpenBSD kernel plugin" do
before(:each) do
@plugin = get_plugin("kernel")
- @plugin.stub(:collect_os).and_return(:openbsd)
- @plugin.stub(:init_kernel).and_return({})
- @plugin.stub(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
- @plugin.stub(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
- @plugin.stub(:shell_out).with( Ohai.abs_path( "/usr/bin/modstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:openbsd)
+ allow(@plugin).to receive(:init_kernel).and_return({})
+ allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo", ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1\n", ""))
+ allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/usr/bin/modstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
end
it "should set the kernel_os to the kernel_name value" do
@plugin.run
- @plugin[:kernel][:os].should == @plugin[:kernel][:name]
+ expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
end
end
diff --git a/spec/unit/plugins/openbsd/platform_spec.rb b/spec/unit/plugins/openbsd/platform_spec.rb
index 915323ef..25dddfe1 100644
--- a/spec/unit/plugins/openbsd/platform_spec.rb
+++ b/spec/unit/plugins/openbsd/platform_spec.rb
@@ -22,13 +22,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "OpenBSD plugin platform" do
before(:each) do
@plugin = get_plugin("openbsd/platform")
- @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "OpenBSD\n", ""))
- @plugin.stub(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
- @plugin.stub(:collect_os).and_return(:openbsd)
+ allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "OpenBSD\n", ""))
+ allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "4.5\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:openbsd)
end
it "should set platform_version to lsb[:release]" do
@plugin.run
- @plugin[:platform_version].should == "4.5"
+ expect(@plugin[:platform_version]).to eq("4.5")
end
end
diff --git a/spec/unit/plugins/openstack_spec.rb b/spec/unit/plugins/openstack_spec.rb
index fa8c6fdd..a54e1217 100644
--- a/spec/unit/plugins/openstack_spec.rb
+++ b/spec/unit/plugins/openstack_spec.rb
@@ -29,8 +29,8 @@ describe "OpenStack Plugin" do
let(:openstack_plugin) do
plugin = get_plugin("openstack", ohai_system)
- plugin.stub(:hint?).with("openstack").and_return(openstack_hint)
- plugin.stub(:hint?).with("hp").and_return(hp_hint)
+ allow(plugin).to receive(:hint?).with("openstack").and_return(openstack_hint)
+ allow(plugin).to receive(:hint?).with("hp").and_return(hp_hint)
plugin
end
@@ -52,7 +52,7 @@ describe "OpenStack Plugin" do
context "and the metadata service is not available" do
before do
- openstack_plugin.should_receive(:can_metadata_connect?).
+ expect(openstack_plugin).to receive(:can_metadata_connect?).
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80).
and_return(false)
end
@@ -141,27 +141,27 @@ EOM
let(:http_client) { double("Net::HTTP", :read_timeout= => nil) }
def expect_get(url, response_body)
- http_client.should_receive(:get).
+ expect(http_client).to receive(:get).
with(url).
and_return(double("HTTP Response", :code => "200", :body => response_body))
end
def expect_get_response(url, response_body)
- http_client.should_receive(:get_response).
+ expect(http_client).to receive(:get_response).
with(url,nil,nil).
and_return(double("HTTP Response", :code => "200", :body => response_body))
end
before do
- openstack_plugin.should_receive(:can_metadata_connect?).
+ expect(openstack_plugin).to receive(:can_metadata_connect?).
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80).
and_return(true)
- Net::HTTP.stub(:start).
+ allow(Net::HTTP).to receive(:start).
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR).
and_return(http_client)
- openstack_plugin.stub(:best_api_version).and_return(metadata_version)
+ allow(openstack_plugin).to receive(:best_api_version).and_return(metadata_version)
expect_get("/#{metadata_version}/meta-data/", metadata_root)
diff --git a/spec/unit/plugins/os_spec.rb b/spec/unit/plugins/os_spec.rb
index 2f5df02f..aaf235cf 100644
--- a/spec/unit/plugins/os_spec.rb
+++ b/spec/unit/plugins/os_spec.rb
@@ -34,7 +34,7 @@ describe Ohai::System, "plugin os" do
it "should set os_version to kernel_release" do
@plugin.run
- @plugin[:os_version].should == @plugin[:kernel][:release]
+ expect(@plugin[:os_version]).to eq(@plugin[:kernel][:release])
end
describe "on linux" do
@@ -44,7 +44,7 @@ describe Ohai::System, "plugin os" do
it "should set the os to linux" do
@plugin.run
- @plugin[:os].should == "linux"
+ expect(@plugin[:os]).to eq("linux")
end
end
@@ -55,7 +55,7 @@ describe Ohai::System, "plugin os" do
it "should set the os to darwin" do
@plugin.run
- @plugin[:os].should == "darwin"
+ expect(@plugin[:os]).to eq("darwin")
end
end
@@ -66,7 +66,7 @@ describe Ohai::System, "plugin os" do
it "sets the os to solaris2" do
@plugin.run
- @plugin[:os].should == "solaris2"
+ expect(@plugin[:os]).to eq("solaris2")
end
end
@@ -77,7 +77,7 @@ describe Ohai::System, "plugin os" do
it "sets the os to the ruby 'host_os'" do
@plugin.run
- @plugin[:os].should == "tron"
+ expect(@plugin[:os]).to eq("tron")
end
end
end
diff --git a/spec/unit/plugins/passwd_spec.rb b/spec/unit/plugins/passwd_spec.rb
index 0fef63de..c12cddb4 100644
--- a/spec/unit/plugins/passwd_spec.rb
+++ b/spec/unit/plugins/passwd_spec.rb
@@ -9,42 +9,42 @@ describe Ohai::System, "plugin etc", :unix_only do
GroupEntry = Struct.new(:name, :gid, :mem)
it "should include a list of all users" do
- Etc.should_receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
+ expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
and_yield(PasswdEntry.new('www', 800, 800, '/var/www', '/bin/false', 'Serving the web since 1970'))
@plugin.run
- @plugin[:etc][:passwd]['root'].should == Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root')
- @plugin[:etc][:passwd]['www'].should == Mash.new(:shell => '/bin/false', :gecos => 'Serving the web since 1970', :gid => 800, :uid => 800, :dir => '/var/www')
+ expect(@plugin[:etc][:passwd]['root']).to eq(Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root'))
+ expect(@plugin[:etc][:passwd]['www']).to eq(Mash.new(:shell => '/bin/false', :gecos => 'Serving the web since 1970', :gid => 800, :uid => 800, :dir => '/var/www'))
end
it "should ignore duplicate users" do
- Etc.should_receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
+ expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
and_yield(PasswdEntry.new('root', 1, 1, '/', '/bin/false', 'I do not belong'))
@plugin.run
- @plugin[:etc][:passwd]['root'].should == Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root')
+ expect(@plugin[:etc][:passwd]['root']).to eq(Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root'))
end
it "should set the current user" do
- Process.should_receive(:euid).and_return('31337')
- Etc.should_receive(:getpwuid).and_return(PasswdEntry.new('chef', 31337, 31337, '/home/chef', '/bin/ksh', 'Julia Child'))
+ expect(Process).to receive(:euid).and_return('31337')
+ expect(Etc).to receive(:getpwuid).and_return(PasswdEntry.new('chef', 31337, 31337, '/home/chef', '/bin/ksh', 'Julia Child'))
@plugin.run
- @plugin[:current_user].should == 'chef'
+ expect(@plugin[:current_user]).to eq('chef')
end
it "should set the available groups" do
- Etc.should_receive(:group).and_yield(GroupEntry.new("admin", 100, ['root', 'chef'])).and_yield(GroupEntry.new('www', 800, ['www', 'deploy']))
+ expect(Etc).to receive(:group).and_yield(GroupEntry.new("admin", 100, ['root', 'chef'])).and_yield(GroupEntry.new('www', 800, ['www', 'deploy']))
@plugin.run
- @plugin[:etc][:group]['admin'].should == Mash.new(:gid => 100, :members => ['root', 'chef'])
- @plugin[:etc][:group]['www'].should == Mash.new(:gid => 800, :members => ['www', 'deploy'])
+ expect(@plugin[:etc][:group]['admin']).to eq(Mash.new(:gid => 100, :members => ['root', 'chef']))
+ expect(@plugin[:etc][:group]['www']).to eq(Mash.new(:gid => 800, :members => ['www', 'deploy']))
end
if "".respond_to?(:force_encoding)
it "sets the encoding of strings to the default external encoding" do
fields = ["root", 1, 1, '/root', '/bin/zsh', 'BOFH']
fields.each {|f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) }
- Etc.stub(:passwd).and_yield(PasswdEntry.new(*fields))
+ allow(Etc).to receive(:passwd).and_yield(PasswdEntry.new(*fields))
@plugin.run
root = @plugin[:etc][:passwd]['root']
- root['gecos'].encoding.should == Encoding.default_external
+ expect(root['gecos'].encoding).to eq(Encoding.default_external)
end
end
end
diff --git a/spec/unit/plugins/perl_spec.rb b/spec/unit/plugins/perl_spec.rb
index 0e84dfee..c4f0f15c 100644
--- a/spec/unit/plugins/perl_spec.rb
+++ b/spec/unit/plugins/perl_spec.rb
@@ -24,35 +24,35 @@ describe Ohai::System, "plugin perl" do
@plugin = get_plugin("perl")
@plugin[:languages] = Mash.new
@stdout = "version='5.8.8';#{$/}archname='darwin-thread-multi-2level';"
- @plugin.stub(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
end
it "should run perl -V:version -V:archname" do
- @plugin.should_receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set languages[:perl][:version]" do
@plugin.run
- @plugin.languages[:perl][:version].should eql("5.8.8")
+ expect(@plugin.languages[:perl][:version]).to eql("5.8.8")
end
it "should set languages[:perl][:archname]" do
@plugin.run
- @plugin.languages[:perl][:archname].should eql("darwin-thread-multi-2level")
+ expect(@plugin.languages[:perl][:archname]).to eql("darwin-thread-multi-2level")
end
it "should set languages[:perl] if perl command succeeds" do
- @plugin.stub(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
- @plugin.languages.should have_key(:perl)
+ expect(@plugin.languages).to have_key(:perl)
end
it "should not set languages[:perl] if perl command fails" do
@status = 1
- @plugin.stub(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(1, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(1, @stdout, ""))
@plugin.run
- @plugin.languages.should_not have_key(:perl)
+ expect(@plugin.languages).not_to have_key(:perl)
end
end
diff --git a/spec/unit/plugins/php_spec.rb b/spec/unit/plugins/php_spec.rb
index cced3234..9a73d413 100644
--- a/spec/unit/plugins/php_spec.rb
+++ b/spec/unit/plugins/php_spec.rb
@@ -26,31 +26,31 @@ describe Ohai::System, "plugin php" do
@plugin = get_plugin("php")
@plugin[:languages] = Mash.new
@stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n"
- @plugin.stub(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
end
it "should get the php version from running php -V" do
- @plugin.should_receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
+ expect(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end
it "should set languages[:php][:version]" do
@plugin.run
- @plugin.languages[:php][:version].should eql("5.1.6")
+ expect(@plugin.languages[:php][:version]).to eql("5.1.6")
end
it "should not set the languages[:php] tree up if php command fails" do
@stdout = "PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)\nCopyright (c) 1997-2006 The PHP Group\nZend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies\n"
- @plugin.stub(:shell_out).with("php -v").and_return(mock_shell_out(1, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(1, @stdout, ""))
@plugin.run
- @plugin.languages.should_not have_key(:php)
+ expect(@plugin.languages).not_to have_key(:php)
end
it "should parse builddate even if it's suhosin patched" do
@stdout = "PHP 5.3.27 with Suhosin-Patch (cli) (built: Aug 30 2013 04:30:30) \nCopyright (c) 1997-2013 The PHP Group\nZend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies"
- @plugin.stub(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
- @plugin.languages[:php][:builddate].should eql("Aug 30 2013 04:30:30")
+ expect(@plugin.languages[:php][:builddate]).to eql("Aug 30 2013 04:30:30")
end
end
diff --git a/spec/unit/plugins/platform_spec.rb b/spec/unit/plugins/platform_spec.rb
index 704038fc..61d167d9 100644
--- a/spec/unit/plugins/platform_spec.rb
+++ b/spec/unit/plugins/platform_spec.rb
@@ -22,45 +22,45 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
describe Ohai::System, "plugin platform" do
before(:each) do
@plugin = get_plugin("platform")
- @plugin.stub(:collect_os).and_return(:default)
+ allow(@plugin).to receive(:collect_os).and_return(:default)
@plugin[:os] = 'monkey'
@plugin[:os_version] = 'poop'
end
it "should set the platform and platform family to the os if it was not set earlier" do
@plugin.run
- @plugin[:platform].should eql("monkey")
- @plugin[:platform_family].should eql("monkey")
+ expect(@plugin[:platform]).to eql("monkey")
+ expect(@plugin[:platform_family]).to eql("monkey")
end
it "should not set the platform to the os if it was set earlier" do
@plugin[:platform] = 'lars'
@plugin.run
- @plugin[:platform].should eql("lars")
+ expect(@plugin[:platform]).to eql("lars")
end
it "should set the platform_family to the platform if platform was set earlier but not platform_family" do
@plugin[:platform] = 'lars'
@plugin[:platform_family] = 'jack'
@plugin.run
- @plugin[:platform_family].should eql("jack")
+ expect(@plugin[:platform_family]).to eql("jack")
end
it "should not set the platform_family if the platform_family was set earlier." do
@plugin[:platform] = 'lars'
@plugin.run
- @plugin[:platform].should eql("lars")
- @plugin[:platform_family].should eql("lars")
+ expect(@plugin[:platform]).to eql("lars")
+ expect(@plugin[:platform_family]).to eql("lars")
end
it "should set the platform_version to the os_version if it was not set earlier" do
@plugin.run
- @plugin[:os_version].should eql("poop")
+ expect(@plugin[:os_version]).to eql("poop")
end
it "should not set the platform to the os if it was set earlier" do
@plugin[:platform_version] = 'ulrich'
@plugin.run
- @plugin[:platform_version].should eql("ulrich")
+ expect(@plugin[:platform_version]).to eql("ulrich")
end
end
diff --git a/spec/unit/plugins/powershell_spec.rb b/spec/unit/plugins/powershell_spec.rb
index 619f1908..fd7a7829 100644
--- a/spec/unit/plugins/powershell_spec.rb
+++ b/spec/unit/plugins/powershell_spec.rb
@@ -43,15 +43,15 @@ PSRemotingProtocolVersion 2.2
END
- @plugin.stub(:shell_out).with(anything()).and_return(mock_shell_out(0, v4_output, ""))
+ allow(@plugin).to receive(:shell_out).with(anything()).and_return(mock_shell_out(0, v4_output, ""))
@plugin.run
- @plugin.languages[:powershell][:version].should eql("4.0")
- @plugin.languages[:powershell][:ws_man_stack_version].should eql("3.0")
- @plugin.languages[:powershell][:serialization_version].should eql("1.1.0.1")
- @plugin.languages[:powershell][:clr_version].should eql("4.0.30319.34014")
- @plugin.languages[:powershell][:build_version].should eql("6.3.9600.16394")
- @plugin.languages[:powershell][:compatible_versions].should eql(['1.0', '2.0', '3.0', '4.0'])
- @plugin.languages[:powershell][:remoting_protocol_version].should eql("2.2")
+ expect(@plugin.languages[:powershell][:version]).to eql("4.0")
+ expect(@plugin.languages[:powershell][:ws_man_stack_version]).to eql("3.0")
+ expect(@plugin.languages[:powershell][:serialization_version]).to eql("1.1.0.1")
+ expect(@plugin.languages[:powershell][:clr_version]).to eql("4.0.30319.34014")
+ expect(@plugin.languages[:powershell][:build_version]).to eql("6.3.9600.16394")
+ expect(@plugin.languages[:powershell][:compatible_versions]).to eql(['1.0', '2.0', '3.0', '4.0'])
+ expect(@plugin.languages[:powershell][:remoting_protocol_version]).to eql("2.2")
end
it "should not set the languages[:powershell] tree up if powershell command fails" do
@@ -60,9 +60,9 @@ END
operable program or batch file.
END
- @plugin.stub(:shell_out).with(anything).and_return(mock_shell_out(1, error_output, ""))
+ allow(@plugin).to receive(:shell_out).with(anything).and_return(mock_shell_out(1, error_output, ""))
@plugin.run
- @plugin.languages.should_not have_key(:powershell)
+ expect(@plugin.languages).not_to have_key(:powershell)
end
end
diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb
index 4e60d111..65c32368 100644
--- a/spec/unit/plugins/rackspace_spec.rb
+++ b/spec/unit/plugins/rackspace_spec.rb
@@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
describe Ohai::System, "plugin rackspace" do
before(:each) do
- Resolv.stub(:getname).and_return("1.2.3.4")
+ allow(Resolv).to receive(:getname).and_return("1.2.3.4")
@plugin = get_plugin("rackspace")
@plugin[:hostname] = "katie"
@plugin[:network] = {:interfaces => {:eth0 => {"addresses"=> {
@@ -67,13 +67,13 @@ describe Ohai::System, "plugin rackspace" do
# We need a generic stub here for the later stubs with arguments to work
# Because, magic.
- @plugin.stub(:shell_out).and_return(mock_shell_out(1, "", ""))
+ allow(@plugin).to receive(:shell_out).and_return(mock_shell_out(1, "", ""))
end
shared_examples_for "!rackspace" do
it "should NOT create rackspace" do
@plugin.run
- @plugin[:rackspace].should be_nil
+ expect(@plugin[:rackspace]).to be_nil
end
end
@@ -81,44 +81,44 @@ describe Ohai::System, "plugin rackspace" do
it "should create rackspace" do
@plugin.run
- @plugin[:rackspace].should_not be_nil
+ expect(@plugin[:rackspace]).not_to be_nil
end
it "should have all required attributes" do
@plugin.run
- @plugin[:rackspace][:public_ip].should_not be_nil
- @plugin[:rackspace][:private_ip].should_not be_nil
- @plugin[:rackspace][:public_ipv4].should_not be_nil
- @plugin[:rackspace][:local_ipv4].should_not be_nil
- @plugin[:rackspace][:public_ipv6].should_not be_nil
- @plugin[:rackspace][:local_ipv6].should be_nil
- @plugin[:rackspace][:local_hostname].should_not be_nil
- @plugin[:rackspace][:public_hostname].should_not be_nil
+ expect(@plugin[:rackspace][:public_ip]).not_to be_nil
+ expect(@plugin[:rackspace][:private_ip]).not_to be_nil
+ expect(@plugin[:rackspace][:public_ipv4]).not_to be_nil
+ expect(@plugin[:rackspace][:local_ipv4]).not_to be_nil
+ expect(@plugin[:rackspace][:public_ipv6]).not_to be_nil
+ expect(@plugin[:rackspace][:local_ipv6]).to be_nil
+ expect(@plugin[:rackspace][:local_hostname]).not_to be_nil
+ expect(@plugin[:rackspace][:public_hostname]).not_to be_nil
end
it "should resolve hostname if reverse dns is set" do
- Resolv.stub(:getname).and_return("1234.resolved.com")
+ allow(Resolv).to receive(:getname).and_return("1234.resolved.com")
@plugin.run
- @plugin[:rackspace][:public_hostname].should == "1234.resolved.com"
+ expect(@plugin[:rackspace][:public_hostname]).to eq("1234.resolved.com")
end
[Resolv::ResolvError, Resolv::ResolvTimeout].each do |exception|
it "should return ip address when reverse dns returns exception: #{exception}" do
- Resolv.stub(:getname).and_raise(exception)
+ allow(Resolv).to receive(:getname).and_raise(exception)
@plugin.run
- @plugin[:rackspace][:public_hostname].should == "1.2.3.4"
+ expect(@plugin[:rackspace][:public_hostname]).to eq("1.2.3.4")
end
end
it "should have correct values for all attributes" do
@plugin.run
- @plugin[:rackspace][:public_ip].should == "1.2.3.4"
- @plugin[:rackspace][:private_ip].should == "5.6.7.8"
- @plugin[:rackspace][:public_ipv4].should == "1.2.3.4"
- @plugin[:rackspace][:local_ipv4].should == "5.6.7.8"
- @plugin[:rackspace][:public_ipv6].should == "2a00:1a48:7805:111:e875:efaf:ff08:75"
- @plugin[:rackspace][:local_hostname].should == 'katie'
- @plugin[:rackspace][:public_hostname].should == "1.2.3.4"
+ expect(@plugin[:rackspace][:public_ip]).to eq("1.2.3.4")
+ expect(@plugin[:rackspace][:private_ip]).to eq("5.6.7.8")
+ expect(@plugin[:rackspace][:public_ipv4]).to eq("1.2.3.4")
+ expect(@plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8")
+ expect(@plugin[:rackspace][:public_ipv6]).to eq("2a00:1a48:7805:111:e875:efaf:ff08:75")
+ expect(@plugin[:rackspace][:local_hostname]).to eq('katie')
+ expect(@plugin[:rackspace][:public_hostname]).to eq("1.2.3.4")
end
it "should capture region information" do
@@ -129,9 +129,9 @@ server_id = "21301000"
created_at = "2012-12-06T22:08:16Z"
region = "dfw"
OUT
- @plugin.stub(:shell_out).with("xenstore-ls vm-data/provider_data").and_return(mock_shell_out(0, provider_data, ""))
+ allow(@plugin).to receive(:shell_out).with("xenstore-ls vm-data/provider_data").and_return(mock_shell_out(0, provider_data, ""))
@plugin.run
- @plugin[:rackspace][:region].should == "dfw"
+ expect(@plugin[:rackspace][:region]).to eq("dfw")
end
end
@@ -139,13 +139,13 @@ OUT
it_should_behave_like "rackspace"
before(:each) do
- Resolv.stub(:getname).and_raise(Resolv::ResolvError)
- File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
- File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
- File.stub(:exist?).with('/etc/resolv.conf').and_return(true)
- File.stub(:read).with('/etc/resolv.conf').and_return('')
+ allow(Resolv).to receive(:getname).and_raise(Resolv::ResolvError)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/resolv.conf').and_return(true)
+ allow(File).to receive(:read).with('/etc/resolv.conf').and_return('')
end
describe 'with no public interfaces (empty eth0)' do
@@ -157,22 +157,22 @@ OUT
it "should have all required attributes" do
@plugin.run
# expliticly nil
- @plugin[:rackspace][:public_ip].should be_nil
- @plugin[:rackspace][:public_ipv4].should be_nil
- @plugin[:rackspace][:public_ipv6].should be_nil
- @plugin[:rackspace][:public_hostname].should be_nil
+ expect(@plugin[:rackspace][:public_ip]).to be_nil
+ expect(@plugin[:rackspace][:public_ipv4]).to be_nil
+ expect(@plugin[:rackspace][:public_ipv6]).to be_nil
+ expect(@plugin[:rackspace][:public_hostname]).to be_nil
# per normal
- @plugin[:rackspace][:private_ip].should_not be_nil
- @plugin[:rackspace][:local_ipv4].should_not be_nil
- @plugin[:rackspace][:local_ipv6].should be_nil
- @plugin[:rackspace][:local_hostname].should_not be_nil
+ expect(@plugin[:rackspace][:private_ip]).not_to be_nil
+ expect(@plugin[:rackspace][:local_ipv4]).not_to be_nil
+ expect(@plugin[:rackspace][:local_ipv6]).to be_nil
+ expect(@plugin[:rackspace][:local_hostname]).not_to be_nil
end
it "should have correct values for all attributes" do
@plugin.run
- @plugin[:rackspace][:private_ip].should == "5.6.7.8"
- @plugin[:rackspace][:local_ipv4].should == "5.6.7.8"
- @plugin[:rackspace][:local_hostname].should == 'katie'
+ expect(@plugin[:rackspace][:private_ip]).to eq("5.6.7.8")
+ expect(@plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8")
+ expect(@plugin[:rackspace][:local_hostname]).to eq('katie')
end
end
end
@@ -181,8 +181,8 @@ OUT
it_should_behave_like "!rackspace"
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
end
end
@@ -190,13 +190,13 @@ OUT
it_should_behave_like "!rackspace"
before(:each) do
- File.stub(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
- File.stub(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
- File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false)
- File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false)
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false)
end
end
@@ -205,7 +205,7 @@ OUT
before(:each) do
stdout = "Rackspace\n"
- @plugin.stub(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
+ allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
end
end
@@ -214,26 +214,26 @@ OUT
before(:each) do
stdout = "cumulonimbus\n"
- @plugin.stub(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
+ allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
end
end
describe "does not have private networks" do
before do
stdout = 'BC764E20422B = "{"label": "public"}"\n'
- @plugin.stub(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
+ allow(@plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
stdout = '{"label": "public", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}'
- @plugin.stub(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
+ allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
- File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
- File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
end
it "should not have private_networks object" do
@plugin.run
- @plugin[:rackspace][:private_networks].should == []
+ expect(@plugin[:rackspace][:private_networks]).to eq([])
end
end
@@ -255,26 +255,26 @@ OUT
}
}}
stdout = 'BC764E20422B = "{"label": "private-network"}"\n'
- @plugin.stub(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
+ allow(@plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
stdout = '{"label": "private-network", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}'
- @plugin.stub(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
+ allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
- File.stub(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
- File.stub(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
- File.stub(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
- File.stub(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
end
it "should private_networks object" do
@plugin.run
- @plugin[:rackspace][:private_networks].should_not be_nil
+ expect(@plugin[:rackspace][:private_networks]).not_to be_nil
end
it "should have correct values for all attributes" do
@plugin.run
- @plugin[:rackspace][:private_networks][0][:label].should == "private-network"
- @plugin[:rackspace][:private_networks][0][:broadcast].should == "9.10.11.255"
- @plugin[:rackspace][:private_networks][0][:mac].should == "BC:76:4E:20:42:2B"
+ expect(@plugin[:rackspace][:private_networks][0][:label]).to eq("private-network")
+ expect(@plugin[:rackspace][:private_networks][0][:broadcast]).to eq("9.10.11.255")
+ expect(@plugin[:rackspace][:private_networks][0][:mac]).to eq("BC:76:4E:20:42:2B")
end
end
diff --git a/spec/unit/plugins/root_group_spec.rb b/spec/unit/plugins/root_group_spec.rb
index 452ff16d..13d04b41 100644
--- a/spec/unit/plugins/root_group_spec.rb
+++ b/spec/unit/plugins/root_group_spec.rb
@@ -30,49 +30,49 @@ describe Ohai::System, 'root_group' do
# apparently didn't apply to this api. we're just trying to fake
# Etc.getgrgid(Etc.getpwnam('root').gid).name
@pwnam = Object.new
- @pwnam.stub(:gid).and_return(0)
- Etc.stub(:getpwnam).with('root').and_return(@pwnam)
+ allow(@pwnam).to receive(:gid).and_return(0)
+ allow(Etc).to receive(:getpwnam).with('root').and_return(@pwnam)
@grgid = Object.new
- Etc.stub(:getgrgid).and_return(@grgid)
+ allow(Etc).to receive(:getgrgid).and_return(@grgid)
end
describe 'with wheel group' do
before(:each) do
- @grgid.stub(:name).and_return('wheel')
+ allow(@grgid).to receive(:name).and_return('wheel')
end
it 'should have a root_group of wheel' do
@plugin.run
- @plugin[:root_group].should == 'wheel'
+ expect(@plugin[:root_group]).to eq('wheel')
end
end
describe 'with root group' do
before(:each) do
- @grgid.stub(:name).and_return('root')
+ allow(@grgid).to receive(:name).and_return('root')
end
it 'should have a root_group of root' do
@plugin.run
- @plugin[:root_group].should == 'root'
+ expect(@plugin[:root_group]).to eq('root')
end
end
describe 'platform hpux with sys group' do
before(:each) do
- @pwnam.stub(:gid).and_return(3)
- @grgid.stub(:name).and_return('sys')
+ allow(@pwnam).to receive(:gid).and_return(3)
+ allow(@grgid).to receive(:name).and_return('sys')
end
it 'should have a root_group of sys' do
@plugin.run
- @plugin[:root_group].should == 'sys'
+ expect(@plugin[:root_group]).to eq('sys')
end
end
describe 'platform aix with system group' do
before(:each) do
- @grgid.stub(:name).and_return('system')
+ allow(@grgid).to receive(:name).and_return('system')
end
it 'should have a root_group of system' do
@plugin.run
- @plugin[:root_group].should == 'system'
+ expect(@plugin[:root_group]).to eq('system')
end
end
end
@@ -80,9 +80,9 @@ describe Ohai::System, 'root_group' do
describe 'windows platform' do
it 'should return the group administrators' do
stub_const('::RbConfig::CONFIG', { 'host_os' => 'windows'} )
- Ohai::Util::Win32::GroupHelper.should_receive(:windows_root_group_name).and_return('administrators')
+ expect(Ohai::Util::Win32::GroupHelper).to receive(:windows_root_group_name).and_return('administrators')
@plugin.run
- @plugin[:root_group].should == 'administrators'
+ expect(@plugin[:root_group]).to eq('administrators')
end
end
end
diff --git a/spec/unit/plugins/ruby_spec.rb b/spec/unit/plugins/ruby_spec.rb
index 6c3a3def..cf8d82bc 100644
--- a/spec/unit/plugins/ruby_spec.rb
+++ b/spec/unit/plugins/ruby_spec.rb
@@ -53,7 +53,7 @@ describe Ohai::System, "plugin ruby" do
:ruby_bin => ruby_bin
}.each do |attribute, value|
it "should have #{attribute} set" do
- @ruby_ohai_data[attribute].should eql(value)
+ expect(@ruby_ohai_data[attribute]).to eql(value)
end
end
diff --git a/spec/unit/plugins/sigar/network_route_spec.rb b/spec/unit/plugins/sigar/network_route_spec.rb
index 6d71798c..638f6961 100644
--- a/spec/unit/plugins/sigar/network_route_spec.rb
+++ b/spec/unit/plugins/sigar/network_route_spec.rb
@@ -34,7 +34,7 @@ describe Ohai::System, "Sigar network route plugin" do
before(:each) do
@ohai = Ohai::System.new
@plugin = get_plugin("sigar/network", @ohai)
- @plugin.stub(:collect_os).and_return(:sigar)
+ allow(@plugin).to receive(:collect_os).and_return(:sigar)
@sigar = double("Sigar")
@net_info_conf={
:default_gateway => "192.168.1.254",
@@ -45,7 +45,7 @@ describe Ohai::System, "Sigar network route plugin" do
}
net_info=double("Sigar::NetInfo")
@net_info_conf.each_pair do |k,v|
- net_info.stub(k).and_return(v)
+ allow(net_info).to receive(k).and_return(v)
end
@net_route_conf={
:destination => "192.168.1.0",
@@ -62,7 +62,7 @@ describe Ohai::System, "Sigar network route plugin" do
}
net_route=double("Sigar::NetRoute")
@net_route_conf.each_pair do |k,v|
- net_route.stub(k).and_return(v)
+ allow(net_route).to receive(k).and_return(v)
end
@net_interface_conf={
:flags => 2115,
@@ -79,7 +79,7 @@ describe Ohai::System, "Sigar network route plugin" do
}
net_conf=double("Sigar::NetConf")
@net_interface_conf.each_pair do |k,v|
- net_conf.stub(k).and_return(v)
+ allow(net_conf).to receive(k).and_return(v)
end
@net_interface_stat={
:rx_bytes=>1369035618,
@@ -99,7 +99,7 @@ describe Ohai::System, "Sigar network route plugin" do
}
net_stat=double("Sigar::NetStat")
@net_interface_stat.each_pair do |k,v|
- net_stat.stub(k).and_return(v)
+ allow(net_stat).to receive(k).and_return(v)
end
@net_arp_conf={
:address => "192.168.1.5",
@@ -110,24 +110,24 @@ describe Ohai::System, "Sigar network route plugin" do
}
net_arp=double("Sigar::NetArp")
@net_arp_conf.each_pair do |k,v|
- net_arp.stub(k).and_return(v)
+ allow(net_arp).to receive(k).and_return(v)
end
- @sigar.stub(:fqdn).and_return("localhost.localdomain")
- @sigar.should_receive(:net_info).once.times.and_return(net_info)
- @sigar.should_receive(:net_interface_list).once.and_return(["eth0"])
- @sigar.should_receive(:net_interface_config).with("eth0").and_return(net_conf)
- @sigar.should_receive(:net_interface_stat).with("eth0").and_return(net_stat)
- @sigar.should_receive(:arp_list).once.and_return([net_arp])
+ allow(@sigar).to receive(:fqdn).and_return("localhost.localdomain")
+ expect(@sigar).to receive(:net_info).once.times.and_return(net_info)
+ expect(@sigar).to receive(:net_interface_list).once.and_return(["eth0"])
+ expect(@sigar).to receive(:net_interface_config).with("eth0").and_return(net_conf)
+ expect(@sigar).to receive(:net_interface_stat).with("eth0").and_return(net_stat)
+ expect(@sigar).to receive(:arp_list).once.and_return([net_arp])
# Since we double net_route_list here, flags never gets called
- @sigar.should_receive(:net_route_list).once.and_return([net_route])
- Sigar.should_receive(:new).once.and_return(@sigar)
+ expect(@sigar).to receive(:net_route_list).once.and_return([net_route])
+ expect(Sigar).to receive(:new).once.and_return(@sigar)
@plugin.run
end
it "should set the routes" do
- @plugin[:network][:interfaces][:eth0].should have_key(:route)
+ expect(@plugin[:network][:interfaces][:eth0]).to have_key(:route)
end
it "should set the route details" do
@@ -137,8 +137,8 @@ describe Ohai::System, "Sigar network route plugin" do
v="U"
@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k] = v
end
- @plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"].should have_key(k)
- @plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k].should eql(v)
+ expect(@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"]).to have_key(k)
+ expect(@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k]).to eql(v)
end
end
diff --git a/spec/unit/plugins/solaris2/cpu_spec.rb b/spec/unit/plugins/solaris2/cpu_spec.rb
index 1d472179..7886215f 100644
--- a/spec/unit/plugins/solaris2/cpu_spec.rb
+++ b/spec/unit/plugins/solaris2/cpu_spec.rb
@@ -19,9 +19,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Solaris2.X cpu plugin" do
before(:each) do
@plugin = get_plugin("solaris2/cpu")
- @plugin.stub(:collect_os).and_return("solaris2")
- @plugin.stub(:shell_out).with("psrinfo | wc -l").and_return(mock_shell_out(0, "32\n", ""))
- @plugin.stub(:shell_out).with("psrinfo -p").and_return(mock_shell_out(0, "4\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return("solaris2")
+ allow(@plugin).to receive(:shell_out).with("psrinfo | wc -l").and_return(mock_shell_out(0, "32\n", ""))
+ allow(@plugin).to receive(:shell_out).with("psrinfo -p").and_return(mock_shell_out(0, "4\n", ""))
psrinfo_output = <<-END.strip
x86 (GenuineIntel 206D7 family 6 model 45 step 7 clock 2600 MHz)
@@ -29,54 +29,54 @@ describe Ohai::System, "Solaris2.X cpu plugin" do
x86 (CrazyTown 206D7 family 12 model 93 step 9 clock 2900 MHz)
Intel(r) Xeon(r) CPU E5-2690 0 @ 2.90GHz
END
- @plugin.stub(:shell_out).with('psrinfo -v -p | grep Hz').and_return(mock_shell_out(0, psrinfo_output, ""))
+ allow(@plugin).to receive(:shell_out).with('psrinfo -v -p | grep Hz').and_return(mock_shell_out(0, psrinfo_output, ""))
end
it "should get the total virtual processor count" do
@plugin.run
- @plugin['cpu']['total'].should eql(32)
+ expect(@plugin['cpu']['total']).to eql(32)
end
it 'should get the total processor count' do
@plugin.run
- @plugin['cpu']['real'].should eql(4)
+ expect(@plugin['cpu']['real']).to eql(4)
end
describe 'per-cpu information' do
it "should include vendor_id for processors" do
@plugin.run
- @plugin['cpu']['0']['vendor_id'].should eql('GenuineIntel')
- @plugin['cpu']['1']['vendor_id'].should eql('CrazyTown')
+ expect(@plugin['cpu']['0']['vendor_id']).to eql('GenuineIntel')
+ expect(@plugin['cpu']['1']['vendor_id']).to eql('CrazyTown')
end
it "should include family for processors" do
@plugin.run
- @plugin['cpu']["0"]["family"].should eql("6")
- @plugin['cpu']["1"]["family"].should eql("12")
+ expect(@plugin['cpu']["0"]["family"]).to eql("6")
+ expect(@plugin['cpu']["1"]["family"]).to eql("12")
end
it "should include model for processors" do
@plugin.run
- @plugin['cpu']["0"]["model"].should eql("45")
- @plugin['cpu']["1"]["model"].should eql("93")
+ expect(@plugin['cpu']["0"]["model"]).to eql("45")
+ expect(@plugin['cpu']["1"]["model"]).to eql("93")
end
it "should include stepping for processors" do
@plugin.run
- @plugin['cpu']["0"]["stepping"].should eql("7")
- @plugin['cpu']["1"]["stepping"].should eql("9")
+ expect(@plugin['cpu']["0"]["stepping"]).to eql("7")
+ expect(@plugin['cpu']["1"]["stepping"]).to eql("9")
end
it "should include model name for processors" do
@plugin.run
- @plugin['cpu']["0"]["model_name"].should eql("Intel(r) Xeon(r) CPU E5-2670 0 @ 2.60GHz")
- @plugin['cpu']["1"]["model_name"].should eql("Intel(r) Xeon(r) CPU E5-2690 0 @ 2.90GHz")
+ expect(@plugin['cpu']["0"]["model_name"]).to eql("Intel(r) Xeon(r) CPU E5-2670 0 @ 2.60GHz")
+ expect(@plugin['cpu']["1"]["model_name"]).to eql("Intel(r) Xeon(r) CPU E5-2690 0 @ 2.90GHz")
end
it "should include mhz name for processors" do
@plugin.run
- @plugin['cpu']["0"]["mhz"].should eql("2600")
- @plugin['cpu']["1"]["mhz"].should eql("2900")
+ expect(@plugin['cpu']["0"]["mhz"]).to eql("2600")
+ expect(@plugin['cpu']["1"]["mhz"]).to eql("2900")
end
end
end
diff --git a/spec/unit/plugins/solaris2/hostname_spec.rb b/spec/unit/plugins/solaris2/hostname_spec.rb
index df5c7add..00c2936c 100644
--- a/spec/unit/plugins/solaris2/hostname_spec.rb
+++ b/spec/unit/plugins/solaris2/hostname_spec.rb
@@ -21,9 +21,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Solaris2.X hostname plugin" do
before(:each) do
@plugin = get_plugin("hostname")
- @plugin.stub(:collect_os).and_return(:solaris2)
- @plugin.stub(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz")
- @plugin.stub(:shell_out).with("hostname").and_return(mock_shell_out(0, "kitteh\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
+ allow(@plugin).to receive(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz")
+ allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "kitteh\n", ""))
# Socket.stub(:getaddrinfo).and_return( [["AF_INET", 0, "kitteh.inurfridge.eatinurfoodz", "10.1.2.3", 2, 0, 0]] );
end
@@ -31,7 +31,7 @@ describe Ohai::System, "Solaris2.X hostname plugin" do
it "should get the fqdn value from #resolve_fqdn" do
@plugin.run
- @plugin["fqdn"].should == "kitteh.inurfridge.eatinurfoodz"
+ expect(@plugin["fqdn"]).to eq("kitteh.inurfridge.eatinurfoodz")
end
end
diff --git a/spec/unit/plugins/solaris2/kernel_spec.rb b/spec/unit/plugins/solaris2/kernel_spec.rb
index d252441a..729b20a3 100644
--- a/spec/unit/plugins/solaris2/kernel_spec.rb
+++ b/spec/unit/plugins/solaris2/kernel_spec.rb
@@ -135,10 +135,10 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
before(:each) do
@plugin = get_plugin("kernel")
- @plugin.stub(:collect_os).and_return(:solaris2)
- @plugin.stub(:init_kernel).and_return({})
- @plugin.stub(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
- @plugin.stub(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
+ allow(@plugin).to receive(:init_kernel).and_return({})
+ allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "SunOS\n", ""))
+ allow(@plugin).to receive(:shell_out).with("modinfo").and_return(mock_shell_out(0, MODINFO, ""))
end
it_should_check_from_deep_mash("solaris2::kernel", "kernel", "os", "uname -s", [0, "SunOS\n", ""])
@@ -146,15 +146,15 @@ describe Ohai::System, "Solaris2.X kernel plugin" do
it "gives excruciating detail about kernel modules" do
@plugin.run
- @plugin[:kernel][:modules].should have(107).modules
+ expect(@plugin[:kernel][:modules]).to have(107).modules
# Teh daterz
# Id Loadaddr Size Info Rev Module Name
# 6 1180000 4623 1 1 specfs (filesystem for specfs)
teh_daterz = { "id" => 6, "loadaddr" => "1180000", "size" => 17955, "description" => "filesystem for specfs"}
- @plugin[:kernel][:modules].keys.should include("specfs")
- @plugin[:kernel][:modules].keys.should_not include("Module")
- @plugin[:kernel][:modules]["specfs"].should == teh_daterz
+ expect(@plugin[:kernel][:modules].keys).to include("specfs")
+ expect(@plugin[:kernel][:modules].keys).not_to include("Module")
+ expect(@plugin[:kernel][:modules]["specfs"]).to eq(teh_daterz)
end
end
diff --git a/spec/unit/plugins/solaris2/memory_spec.rb b/spec/unit/plugins/solaris2/memory_spec.rb
index fca1a914..29bf3089 100644
--- a/spec/unit/plugins/solaris2/memory_spec.rb
+++ b/spec/unit/plugins/solaris2/memory_spec.rb
@@ -19,12 +19,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Solaris2.X memory plugin" do
before(:each) do
@plugin = get_plugin("solaris2/memory")
- @plugin.stub(:collect_os).and_return("solaris2")
- @plugin.stub(:shell_out).with("prtconf -m").and_return(mock_shell_out(0, "8194\n", ""))
+ allow(@plugin).to receive(:collect_os).and_return("solaris2")
+ allow(@plugin).to receive(:shell_out).with("prtconf -m").and_return(mock_shell_out(0, "8194\n", ""))
end
it "should get the total memory" do
@plugin.run
- @plugin['memory']['total'].should eql(8194)
+ expect(@plugin['memory']['total']).to eql(8194)
end
end
diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb
index c895aa60..8313fc26 100644
--- a/spec/unit/plugins/solaris2/network_spec.rb
+++ b/spec/unit/plugins/solaris2/network_spec.rb
@@ -112,40 +112,40 @@ ROUTE_GET
@ifconfig_lines = @solaris_ifconfig.split("\n")
@plugin = get_plugin("solaris2/network")
- @plugin.stub(:collect_os).and_return(:solaris2)
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
@plugin[:network] = Mash.new
- @plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_route_get, ""))
- @plugin.stub(:shell_out).with("arp -an").and_return(mock_shell_out(0, @solaris_arp_rn, ""))
- @plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @soalris_route_get, ""))
+ allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_route_get, ""))
+ allow(@plugin).to receive(:shell_out).with("arp -an").and_return(mock_shell_out(0, @solaris_arp_rn, ""))
+ allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @soalris_route_get, ""))
end
describe "gathering IP layer address info" do
before do
@stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
- @plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
- @plugin.stub(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
+ allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
+ allow(@plugin).to receive(:shell_out).with("ifconfig -a").and_return(mock_shell_out(0, @solaris_ifconfig, ""))
@plugin.run
end
it "completes the run" do
- @plugin['network'].should_not be_nil
+ expect(@plugin['network']).not_to be_nil
end
it "detects the interfaces" do
- @plugin['network']['interfaces'].keys.sort.should == ["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "lo0", "lo0:3","net0", "qfe1"]
+ expect(@plugin['network']['interfaces'].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "lo0", "lo0:3","net0", "qfe1"])
end
it "detects the ip addresses of the interfaces" do
- @plugin['network']['interfaces']['e1000g0:3']['addresses'].keys.should include('72.2.115.28')
+ expect(@plugin['network']['interfaces']['e1000g0:3']['addresses'].keys).to include('72.2.115.28')
end
it "detects the encapsulation type of the interfaces" do
- @plugin['network']['interfaces']['e1000g0:3']['encapsulation'].should == 'Ethernet'
+ expect(@plugin['network']['interfaces']['e1000g0:3']['encapsulation']).to eq('Ethernet')
end
it "detects the L3PROTECT network flag" do
- @plugin['network']['interfaces']['net0']['flags'].should include('L3PROTECT')
+ expect(@plugin['network']['interfaces']['net0']['flags']).to include('L3PROTECT')
end
end
@@ -154,12 +154,12 @@ ROUTE_GET
describe "setting the node's default IP address attribute" do
before do
@stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
- @plugin.stub(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
+ allow(@plugin).to receive(:shell_out).with("route -n get default").and_return(mock_shell_out(0, @solaris_route_get, ""))
@plugin.run
end
it "finds the default interface by asking which iface has the default route" do
- @plugin[:network][:default_interface].should == 'e1000g0'
+ expect(@plugin[:network][:default_interface]).to eq('e1000g0')
end
end
end
diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb
index 6fae7b95..b52fa664 100644
--- a/spec/unit/plugins/solaris2/platform_spec.rb
+++ b/spec/unit/plugins/solaris2/platform_spec.rb
@@ -21,8 +21,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Solaris plugin platform" do
before(:each) do
@plugin = get_plugin("solaris2/platform")
- @plugin.stub(:collect_os).and_return(:solaris2)
- @plugin.stub(:shell_out).with("/sbin/uname -X")
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
+ allow(@plugin).to receive(:shell_out).with("/sbin/uname -X")
end
describe "on SmartOS" do
@@ -41,26 +41,26 @@ Origin# = 1
NumCPU = 16
UNAME_X
- File.stub(:exists?).with("/sbin/uname").and_return(true)
- @plugin.stub(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
+ allow(File).to receive(:exists?).with("/sbin/uname").and_return(true)
+ allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
@release = StringIO.new(" SmartOS 20120130T201844Z x86_64\n")
- File.stub(:open).with("/etc/release").and_yield(@release)
+ allow(File).to receive(:open).with("/etc/release").and_yield(@release)
end
it "should run uname and set platform and build" do
@plugin.run
- @plugin[:platform_build].should == "joyent_20120130T201844Z"
+ expect(@plugin[:platform_build]).to eq("joyent_20120130T201844Z")
end
it "should set the platform" do
@plugin.run
- @plugin[:platform].should == "smartos"
+ expect(@plugin[:platform]).to eq("smartos")
end
it "should set the platform_version" do
@plugin.run
- @plugin[:platform_version].should == "5.11"
+ expect(@plugin[:platform_version]).to eq("5.11")
end
end
@@ -81,26 +81,26 @@ Origin# = 1
NumCPU = 1
UNAME_X
- File.stub(:exists?).with("/sbin/uname").and_return(true)
- @plugin.stub(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
+ allow(File).to receive(:exists?).with("/sbin/uname").and_return(true)
+ allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
@release = StringIO.new(" Oracle Solaris 11.1 X86\n")
- File.stub(:open).with("/etc/release").and_yield(@release)
+ allow(File).to receive(:open).with("/etc/release").and_yield(@release)
end
it "should run uname and set platform and build" do
@plugin.run
- @plugin[:platform_build].should == "11.1"
+ expect(@plugin[:platform_build]).to eq("11.1")
end
it "should set the platform" do
@plugin.run
- @plugin[:platform].should == "solaris2"
+ expect(@plugin[:platform]).to eq("solaris2")
end
it "should set the platform_version" do
@plugin.run
- @plugin[:platform_version].should == "5.11"
+ expect(@plugin[:platform_version]).to eq("5.11")
end
end
diff --git a/spec/unit/plugins/solaris2/virtualization_spec.rb b/spec/unit/plugins/solaris2/virtualization_spec.rb
index 9e884931..ebe749fb 100644
--- a/spec/unit/plugins/solaris2/virtualization_spec.rb
+++ b/spec/unit/plugins/solaris2/virtualization_spec.rb
@@ -27,47 +27,47 @@ The physical processor has 1 virtual processor (0)
PSRINFO_PV
@plugin = get_plugin("solaris2/virtualization")
- @plugin.stub(:collect_os).and_return(:solaris2)
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
# default to all requested Files not existing
- File.stub(:exists?).with("/usr/sbin/psrinfo").and_return(false)
- File.stub(:exists?).with("/usr/sbin/smbios").and_return(false)
- File.stub(:exists?).with("/usr/sbin/zoneadm").and_return(false)
- @plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, "", ""))
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", ""))
+ allow(File).to receive(:exists?).with("/usr/sbin/psrinfo").and_return(false)
+ allow(File).to receive(:exists?).with("/usr/sbin/smbios").and_return(false)
+ allow(File).to receive(:exists?).with("/usr/sbin/zoneadm").and_return(false)
+ allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, "", ""))
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", ""))
end
describe "when we are checking for kvm" do
before(:each) do
- File.should_receive(:exists?).with("/usr/sbin/psrinfo").and_return(true)
+ expect(File).to receive(:exists?).with("/usr/sbin/psrinfo").and_return(true)
end
it "should run psrinfo -pv" do
- @plugin.should_receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv")
+ expect(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv")
@plugin.run
end
it "Should set kvm guest if psrinfo -pv contains QEMU Virtual CPU" do
- @plugin.stub(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "QEMU Virtual CPU", ""))
+ allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "QEMU Virtual CPU", ""))
@plugin.run
- @plugin[:virtualization][:system].should == "kvm"
- @plugin[:virtualization][:role].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("kvm")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
end
it "should not set virtualization if kvm isn't there" do
- @plugin.should_receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, ""))
+ expect(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, ""))
@plugin.run
- @plugin[:virtualization].should == {}
+ expect(@plugin[:virtualization]).to eq({})
end
end
describe "when we are parsing smbios" do
before(:each) do
- File.should_receive(:exists?).with("/usr/sbin/smbios").and_return(true)
+ expect(File).to receive(:exists?).with("/usr/sbin/smbios").and_return(true)
end
it "should run smbios" do
- @plugin.should_receive(:shell_out).with("/usr/sbin/smbios")
+ expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios")
@plugin.run
end
@@ -84,10 +84,10 @@ ID SIZE TYPE
UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
Wake-Up Event: 0x6 (power switch)
MSVPC
- @plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, ms_vpc_smbios, ""))
+ allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, ms_vpc_smbios, ""))
@plugin.run
- @plugin[:virtualization][:system].should == "virtualpc"
- @plugin[:virtualization][:role].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("virtualpc")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
end
it "should set vmware guest if smbios detects VMware Virtual Platform" do
@@ -103,22 +103,22 @@ ID SIZE TYPE
UUID: a86cc405-e1b9-447b-ad05-6f8db39d876a
Wake-Up Event: 0x6 (power switch)
VMWARE
- @plugin.stub(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, vmware_smbios, ""))
+ allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, vmware_smbios, ""))
@plugin.run
- @plugin[:virtualization][:system].should == "vmware"
- @plugin[:virtualization][:role].should == "guest"
+ expect(@plugin[:virtualization][:system]).to eq("vmware")
+ expect(@plugin[:virtualization][:role]).to eq("guest")
end
it "should run smbios and not set virtualization if nothing is detected" do
- @plugin.should_receive(:shell_out).with("/usr/sbin/smbios")
+ expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios")
@plugin.run
- @plugin[:virtualization].should == {}
+ expect(@plugin[:virtualization]).to eq({})
end
end
it "should not set virtualization if no tests match" do
@plugin.run
- @plugin[:virtualization].should == {}
+ expect(@plugin[:virtualization]).to eq({})
end
end
diff --git a/spec/unit/plugins/solaris2/zpools_spec.rb b/spec/unit/plugins/solaris2/zpools_spec.rb
index 7dd8b8f7..9ddb48b7 100644
--- a/spec/unit/plugins/solaris2/zpools_spec.rb
+++ b/spec/unit/plugins/solaris2/zpools_spec.rb
@@ -18,7 +18,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Solaris 2.x zpool plugin" do
before(:each) do
@plugin = get_plugin("solaris2/zpools")
- @plugin.stub(:collect_os).and_return(:solaris2)
+ allow(@plugin).to receive(:collect_os).and_return(:solaris2)
@zpool_status_rpool = <<-EOSR
pool: rpool
@@ -62,9 +62,9 @@ EOST
rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34
tank 130T 4.91M 130T 0% 1.00x ONLINE 34
EOZO
- @plugin.stub(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
- @plugin.stub(:shell_out).with("su adm -c \"zpool status rpool\"").and_return(mock_shell_out(0,@zpool_status_rpool,""))
- @plugin.stub(:shell_out).with("su adm -c \"zpool status tank\"").and_return(mock_shell_out(0,@zpool_status_tank,""))
+ allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
+ allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status rpool\"").and_return(mock_shell_out(0,@zpool_status_rpool,""))
+ allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status tank\"").and_return(mock_shell_out(0,@zpool_status_tank,""))
end
describe "On Solaris2 Common" do
@@ -123,7 +123,7 @@ EOZO
rpool 109G 66.2G 42.8G 60% 1.00x ONLINE -
tank 130T 4.91M 130T 0% 1.00x ONLINE -
EOZO
- @plugin.stub(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
+ allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
end
it "Won't have a version number" do
@@ -140,7 +140,7 @@ EOZO
rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34
tank 130T 4.91M 130T 0% 1.00x ONLINE 34
EOZO
- @plugin.stub(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
+ allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,""))
end
it "Should have a version number" do
diff --git a/spec/unit/plugins/ssh_host_keys_spec.rb b/spec/unit/plugins/ssh_host_keys_spec.rb
index c5279f1a..647599a1 100644
--- a/spec/unit/plugins/ssh_host_keys_spec.rb
+++ b/spec/unit/plugins/ssh_host_keys_spec.rb
@@ -24,43 +24,43 @@ describe Ohai::System, "ssh_host_key plugin" do
@plugin = get_plugin("ssh_host_key")
@plugin[:keys] = Mash.new
- File.stub(:exists?).with("/etc/ssh/sshd_config").and_return(true)
- File.stub(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
- File.stub(:exists?).and_return(true)
- File.stub(:exists?).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(true)
- File.stub(:exists?).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(true)
- File.stub(:exists?).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(true)
+ allow(File).to receive(:exists?).with("/etc/ssh/sshd_config").and_return(true)
+ allow(File).to receive(:open).with("/etc/ssh/sshd_config").and_yield(sshd_config_file)
+ allow(File).to receive(:exists?).and_return(true)
+ allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(true)
+ allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(true)
+ allow(File).to receive(:exists?).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(true)
# Ensure we can still use IO.read
io_read = IO.method(:read)
- IO.stub(:read) { |file| io_read.call(file) }
+ allow(IO).to receive(:read) { |file| io_read.call(file) }
# Return fake public key files so we don't have to go digging for them in unit tests
@dsa_key = "ssh-dss AAAAB3NzaC1kc3MAAACBAMHlT02xN8kietxPfhcb98xHueTzKCOTz6dZlP/dmKILHrQOAExuSEeNiA2uvmhHNVQvs/cBsRiDxgSKux3ie2q8+MB6vHCiSpSkoPjrL75iT57YDilCB4/sytt6IJpj+H42wRDWTX0/QRybMHUvmnmEL0cwZXykSvrIum0BKB6hAAAAFQDsi6WUCClhtZIiTY9uh8eAre+SbQAAAIEAgNnuw0uEuqtcVif+AYd/bCZvL9FPqg7DrmTkamNEcVinhUGwsPGJTLJf+o5ens1X4RzQoi1R6Y6zCTL2FN/hZgINJNO0z9BN402wWrZmQd+Vb1U5DyDtveuvipqyQS+fm9neRwdLuv36Fc9f9nkZ7YHpkGPJp+yJpG4OoeREhwgAAACBAIf9kKLf2XiXnlByzlJ2Naa55d/hp2E059VKCRsBS++xFKYKvSqjnDQBFiMtAUhb8EdTyBGyalqOgqogDQVtwHfTZWZwqHAhry9aM06y92Eu/xSey4tWjKeknOsnRe640KC4zmKDBRTrjjkuAdrKPN9k3jl+OCc669JHlIfo6kqf oppa"
@rsa_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuhcVXV+nNapkyUC5p4TH1ymRxUjtMBKqYWmwyI29gVFnUNeHkKFHWon0KFeGJP2Rm8BfTiZa9ER9e8pRr4Nd+z1C1o0kVoxEEfB9tpSdTlpk1GG83D94l57fij8THRVIwuCEosViUlg1gDgC4SpxbqfdBkUN2qyf6JDOh7t2QpYh7berpDEWeBpb7BKdLEDT57uw7ijKzSNyaXqq8KkB9I+UFrRwpuos4W7ilX+PQ+mWLi2ZZJfTYZMxxVS+qJwiDtNxGCRwTOQZG03kI7eLBZG+igupr0uD4o6qeftPOr0kxgjoPU4nEKvYiGq8Rqd2vYrhiaJHLk9QB6xStQvS3Q== oppa"
@ecdsa_key = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBx8VgvxmHxs/sIn/ATh0iUcuz1I2Xc0e1ejXCGHBMZ98IE3FBt1ezlqCpNMcHVV2skQQ8vyLbKxzweyZuNSDU8= oppa"
- IO.stub(:read).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(@dsa_key)
- IO.stub(:read).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(@rsa_key)
- IO.stub(:read).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(@ecdsa_key)
+ allow(IO).to receive(:read).with("/etc/ssh/ssh_host_dsa_key.pub").and_return(@dsa_key)
+ allow(IO).to receive(:read).with("/etc/ssh/ssh_host_rsa_key.pub").and_return(@rsa_key)
+ allow(IO).to receive(:read).with("/etc/ssh/ssh_host_ecdsa_key.pub").and_return(@ecdsa_key)
end
shared_examples "loads keys" do
it "reads the key and sets the dsa attribute correctly" do
@plugin.run
- @plugin[:keys][:ssh][:host_dsa_public].should eql(@dsa_key.split[1])
- @plugin[:keys][:ssh][:host_dsa_type].should be_nil
+ expect(@plugin[:keys][:ssh][:host_dsa_public]).to eql(@dsa_key.split[1])
+ expect(@plugin[:keys][:ssh][:host_dsa_type]).to be_nil
end
it "reads the key and sets the rsa attribute correctly" do
@plugin.run
- @plugin[:keys][:ssh][:host_rsa_public].should eql(@rsa_key.split[1])
- @plugin[:keys][:ssh][:host_rsa_type].should be_nil
+ expect(@plugin[:keys][:ssh][:host_rsa_public]).to eql(@rsa_key.split[1])
+ expect(@plugin[:keys][:ssh][:host_rsa_type]).to be_nil
end
it "reads the key and sets the ecdsa attribute correctly" do
@plugin.run
- @plugin[:keys][:ssh][:host_ecdsa_public].should eql(@ecdsa_key.split[1])
- @plugin[:keys][:ssh][:host_ecdsa_type].should eql(@ecdsa_key.split[0])
+ expect(@plugin[:keys][:ssh][:host_ecdsa_public]).to eql(@ecdsa_key.split[1])
+ expect(@plugin[:keys][:ssh][:host_ecdsa_type]).to eql(@ecdsa_key.split[0])
end
end
@@ -93,8 +93,8 @@ EOS
nil
end
before do
- File.stub(:exists?).with("/etc/ssh/sshd_config").and_return(false)
- File.stub(:exists?).with("/etc/sshd_config").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/ssh/sshd_config").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/sshd_config").and_return(false)
end
it_behaves_like "loads keys"
diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb
index 1fe20661..6c04650c 100644
--- a/spec/unit/runner_spec.rb
+++ b/spec/unit/runner_spec.rb
@@ -29,7 +29,7 @@ describe Ohai::Runner, "run_plugin" do
describe "when running an invalid plugin" do
it "should raise error" do
- lambda { @runner.run_plugin(double("Ohai::NotPlugin")) }.should raise_error(Ohai::Exceptions::InvalidPlugin)
+ expect { @runner.run_plugin(double("Ohai::NotPlugin")) }.to raise_error(Ohai::Exceptions::InvalidPlugin)
end
end
@@ -40,7 +40,7 @@ describe Ohai::Runner, "run_plugin" do
describe "version 7" do
it "should call run_v7_plugin" do
- @runner.should_receive(:run_v7_plugin)
+ expect(@runner).to receive(:run_v7_plugin)
@runner.run_plugin(plugin)
end
@@ -48,7 +48,7 @@ describe Ohai::Runner, "run_plugin" do
let(:has_run) { true }
it "should not run the plugin" do
- plugin.should_not_receive(:safe_run)
+ expect(plugin).not_to receive(:safe_run)
@runner.run_plugin(plugin)
end
end
@@ -58,14 +58,14 @@ describe Ohai::Runner, "run_plugin" do
let(:version) { :version6 }
it "should call run_v6_plugin" do
- @runner.should_receive(:run_v6_plugin)
+ expect(@runner).to receive(:run_v6_plugin)
@runner.run_plugin(plugin)
end
describe "if the plugin has not run before" do
describe "if safe_run is not set" do
it "safe_run should be called" do
- plugin.should_receive(:safe_run)
+ expect(plugin).to receive(:safe_run)
@runner.run_plugin(plugin)
end
end
@@ -74,7 +74,7 @@ describe Ohai::Runner, "run_plugin" do
let(:safe_run) { false }
it "run should be called" do
- plugin.should_receive(:run)
+ expect(plugin).to receive(:run)
@runner.run_plugin(plugin)
end
end
@@ -84,7 +84,7 @@ describe Ohai::Runner, "run_plugin" do
let(:has_run) { true }
it "should not run" do
- plugin.should_not_receive(:safe_run)
+ expect(plugin).not_to receive(:safe_run)
@runner.run_plugin(plugin)
end
@@ -95,7 +95,7 @@ describe Ohai::Runner, "run_plugin" do
let(:version) { :versionBla }
it "should raise error" do
- lambda { @runner.run_plugin(plugin) }.should raise_error(Ohai::Exceptions::InvalidPlugin)
+ expect { @runner.run_plugin(plugin) }.to raise_error(Ohai::Exceptions::InvalidPlugin)
end
end
end
@@ -113,13 +113,13 @@ describe Ohai::Runner, "run_plugin" do
it "should run the plugin" do
@runner.run_plugin(plugin)
- plugin.has_run?.should be true
+ expect(plugin.has_run?).to be true
end
it "should add plugin data to Ohai::System.data" do
@runner.run_plugin(plugin)
- @ohai.data.should have_key(:thing)
- @ohai.data[:thing].should eql({})
+ expect(@ohai.data).to have_key(:thing)
+ expect(@ohai.data[:thing]).to eql({})
end
end
@@ -142,7 +142,7 @@ describe Ohai::Runner, "run_plugin" do
it "should not run the plugin" do
expect{ @runner.run_plugin(@plugin) }.to raise_error
- @plugin.has_run?.should be false
+ expect(@plugin.has_run?).to be false
end
end
@@ -174,7 +174,7 @@ describe Ohai::Runner, "run_plugin" do
it "should run the plugins" do
@runner.run_plugin(@plugin2)
@plugins.each do |plugin|
- plugin.has_run?.should be true
+ expect(plugin.has_run?).to be true
end
end
end
@@ -208,7 +208,7 @@ describe Ohai::Runner, "run_plugin" do
it "should run the plugins" do
@runner.run_plugin(@plugin3)
@plugins.each do |plugin|
- plugin.has_run?.should be true
+ expect(plugin.has_run?).to be true
end
end
end
@@ -251,7 +251,7 @@ describe Ohai::Runner, "run_plugin" do
it "should run the plugins" do
@runner.run_plugin(@plugin3)
@plugins.each do |plugin|
- plugin.has_run?.should be true
+ expect(plugin.has_run?).to be true
end
end
end
@@ -306,8 +306,8 @@ describe Ohai::Runner, "run_plugin" do
end
it "should raise Ohai::Exceptions::DependencyCycle" do
- runner.stub(:fetch_plugins).with(["thing"]).and_return([@plugin1])
- runner.stub(:fetch_plugins).with(["other"]).and_return([@plugin2])
+ allow(runner).to receive(:fetch_plugins).with(["thing"]).and_return([@plugin1])
+ allow(runner).to receive(:fetch_plugins).with(["other"]).and_return([@plugin2])
expected_error_string = "Dependency cycle detected. Please refer to the following plugins: Thing, Other"
expect { runner.run_plugin(@plugin1) }.to raise_error(Ohai::Exceptions::DependencyCycle, expected_error_string)
end
@@ -346,11 +346,11 @@ describe Ohai::Runner, "run_plugin" do
@ohai.provides_map.set_providers_for(@pluginB, ["B"])
@ohai.provides_map.set_providers_for(@pluginC, ["C"])
- Ohai::Log.should_not_receive(:error).with(/DependencyCycleError/)
+ expect(Ohai::Log).not_to receive(:error).with(/DependencyCycleError/)
@runner.run_plugin(@pluginA)
@plugins.each do |plugin|
- plugin.has_run?.should be true
+ expect(plugin.has_run?).to be true
end
end
@@ -359,11 +359,11 @@ describe Ohai::Runner, "run_plugin" do
@ohai.provides_map.set_providers_for(@pluginC, ["C"])
@ohai.provides_map.set_providers_for(@pluginB, ["B"])
- Ohai::Log.should_not_receive(:error).with(/DependencyCycleError/)
+ expect(Ohai::Log).not_to receive(:error).with(/DependencyCycleError/)
@runner.run_plugin(@pluginA)
@plugins.each do |plugin|
- plugin.has_run?.should be true
+ expect(plugin.has_run?).to be true
end
end
end
@@ -382,7 +382,7 @@ describe Ohai::Runner, "fetch_plugins" do
@ohai.provides_map.set_providers_for(plugin, ["top/middle/bottom"])
dependency_providers = @runner.fetch_plugins(["top/middle/bottom"])
- dependency_providers.should eql([plugin])
+ expect(dependency_providers).to eql([plugin])
end
describe "when the attribute is not provided by any plugin" do
@@ -390,7 +390,7 @@ describe Ohai::Runner, "fetch_plugins" do
it "should return the providers for the parent" do
plugin = Ohai::DSL::Plugin.new(@ohai.data)
@provides_map.set_providers_for(plugin, ["test/attribute"])
- @runner.fetch_plugins(["test/attribute/too_far"]).should eql([plugin])
+ expect(@runner.fetch_plugins(["test/attribute/too_far"])).to eql([plugin])
end
end
@@ -405,7 +405,7 @@ describe Ohai::Runner, "fetch_plugins" do
it "should return unique providers" do
plugin = Ohai::DSL::Plugin.new(@ohai.data)
@provides_map.set_providers_for(plugin, ["test", "test/too_far/way_too_far"])
- @runner.fetch_plugins(["test", "test/too_far/way_too_far"]).should eql([plugin])
+ expect(@runner.fetch_plugins(["test", "test/too_far/way_too_far"])).to eql([plugin])
end
end
@@ -448,7 +448,7 @@ describe Ohai::Runner, "#get_cycle" do
cycle_start = @plugin1
cycle_names = @runner.get_cycle(cycle, cycle_start)
- cycle_names.should eql([@plugin1.name, @plugin2.name])
+ expect(cycle_names).to eql([@plugin1.name, @plugin2.name])
end
it "should return the sources for only the plugins in the cycle, when there are plugins before the cycle begins" do
@@ -456,6 +456,6 @@ describe Ohai::Runner, "#get_cycle" do
cycle_start = @plugin1
cycle_names = @runner.get_cycle(cycle, cycle_start)
- cycle_names.should eql([@plugin1.name, @plugin2.name])
+ expect(cycle_names).to eql([@plugin1.name, @plugin2.name])
end
end
diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb
index cd729410..0830e499 100644
--- a/spec/unit/system_spec.rb
+++ b/spec/unit/system_spec.rb
@@ -27,15 +27,15 @@ describe "Ohai::System" do
describe "#initialize" do
it "should return an Ohai::System object" do
- ohai.should be_a_kind_of(Ohai::System)
+ expect(ohai).to be_a_kind_of(Ohai::System)
end
it "should set @attributes to a ProvidesMap" do
- ohai.provides_map.should be_a_kind_of(Ohai::ProvidesMap)
+ expect(ohai.provides_map).to be_a_kind_of(Ohai::ProvidesMap)
end
it "should set @v6_dependency_solver to a Hash" do
- ohai.v6_dependency_solver.should be_a_kind_of(Hash)
+ expect(ohai.v6_dependency_solver).to be_a_kind_of(Hash)
end
end
@@ -57,9 +57,9 @@ EOF
it "load_plugins() should load all the plugins" do
ohai.load_plugins
- ohai.provides_map.map.keys.should include("seals")
- ohai.v6_dependency_solver.keys.should include("lake.rb")
- Ohai::NamedPlugin.const_get(:Zoo).should == Ohai::NamedPlugin::Zoo
+ expect(ohai.provides_map.map.keys).to include("seals")
+ expect(ohai.v6_dependency_solver.keys).to include("lake.rb")
+ expect(Ohai::NamedPlugin.const_get(:Zoo)).to eq(Ohai::NamedPlugin::Zoo)
end
end
@@ -95,12 +95,12 @@ EOF
it "load_plugins() should load all the plugins" do
ohai.load_plugins
- ohai.provides_map.map.keys.should include("seals")
- ohai.provides_map.map.keys.should include("crabs")
- ohai.v6_dependency_solver.keys.should include("lake.rb")
- ohai.v6_dependency_solver.keys.should include("mountain.rb")
- Ohai::NamedPlugin.const_get(:Zoo).should == Ohai::NamedPlugin::Zoo
- Ohai::NamedPlugin.const_get(:Nature).should == Ohai::NamedPlugin::Nature
+ expect(ohai.provides_map.map.keys).to include("seals")
+ expect(ohai.provides_map.map.keys).to include("crabs")
+ expect(ohai.v6_dependency_solver.keys).to include("lake.rb")
+ expect(ohai.v6_dependency_solver.keys).to include("mountain.rb")
+ expect(Ohai::NamedPlugin.const_get(:Zoo)).to eq(Ohai::NamedPlugin::Zoo)
+ expect(Ohai::NamedPlugin.const_get(:Nature)).to eq(Ohai::NamedPlugin::Nature)
end
end
@@ -128,8 +128,8 @@ EOF
it "should collect data from all the plugins" do
Ohai::Config[:plugin_path] = [ path_to(".") ]
ohai.all_plugins
- ohai.data[:zoo].should == "animals"
- ohai.data[:park].should == "plants"
+ expect(ohai.data[:zoo]).to eq("animals")
+ expect(ohai.data[:park]).to eq("plants")
end
describe "when using :disabled_plugins" do
@@ -144,8 +144,8 @@ EOF
it "shouldn't run disabled version 6 plugins" do
Ohai::Config[:plugin_path] = [ path_to(".") ]
ohai.all_plugins
- ohai.data[:zoo].should be_nil
- ohai.data[:park].should == "plants"
+ expect(ohai.data[:zoo]).to be_nil
+ expect(ohai.data[:park]).to eq("plants")
end
end
@@ -193,7 +193,7 @@ EOF
let(:v6_plugin) { v6_plugin_class.new(ohai_system, "/v6_plugin.rb", "/") }
before do
- ohai_system.stub(:load_plugins) # TODO: temporary hack - don't run unrelated plugins...
+ allow(ohai_system).to receive(:load_plugins) # TODO: temporary hack - don't run unrelated plugins...
[ primary_plugin, dependency_plugin_one, dependency_plugin_two, unrelated_plugin].each do |plugin|
plugin_provides = plugin.class.provides_attrs
ohai_system.provides_map.set_providers_for(plugin, plugin_provides)
@@ -247,7 +247,7 @@ EOF
it "should collect platform specific" do
Ohai::Config[:plugin_path] = [ path_to(".") ]
ohai.all_plugins
- ohai.data[:message].should == "platform_specific_message"
+ expect(ohai.data[:message]).to eq("platform_specific_message")
end
end
@@ -274,16 +274,16 @@ EOF
it "should collect data from all the plugins" do
Ohai::Config[:plugin_path] = [ path_to(".") ]
ohai.all_plugins
- ohai.data[:zoo].should == "animals"
- ohai.data[:park].should == "plants"
+ expect(ohai.data[:zoo]).to eq("animals")
+ expect(ohai.data[:park]).to eq("plants")
end
it "should write an error to Ohai::Log" do
Ohai::Config[:plugin_path] = [ path_to(".") ]
# Make sure the stubbing of runner is not overriden with reset_system during test
- ohai.stub(:reset_system)
- ohai.instance_variable_get("@runner").stub(:run_plugin).and_raise(Ohai::Exceptions::AttributeNotFound)
- Ohai::Log.should_receive(:error).with(/Encountered error while running plugins/)
+ allow(ohai).to receive(:reset_system)
+ allow(ohai.instance_variable_get("@runner")).to receive(:run_plugin).and_raise(Ohai::Exceptions::AttributeNotFound)
+ expect(Ohai::Log).to receive(:error).with(/Encountered error while running plugins/)
expect { ohai.all_plugins }.to raise_error(Ohai::Exceptions::AttributeNotFound)
end
@@ -299,8 +299,8 @@ EOF
it "shouldn't run disabled plugins" do
Ohai::Config[:plugin_path] = [ path_to(".") ]
ohai.all_plugins
- ohai.data[:zoo].should be_nil
- ohai.data[:park].should == "plants"
+ expect(ohai.data[:zoo]).to be_nil
+ expect(ohai.data[:park]).to eq("plants")
end
end
end
@@ -348,10 +348,10 @@ EOF
it "shouldn't run disabled plugins" do
Ohai::Config[:plugin_path] = [ path_to(".") ]
ohai.all_plugins
- ohai.data[:zoo].should be_nil
- ohai.data[:nature].should == "cougars"
- ohai.data[:park].should be_nil
- ohai.data[:home].should == "dog"
+ expect(ohai.data[:zoo]).to be_nil
+ expect(ohai.data[:nature]).to eq("cougars")
+ expect(ohai.data[:park]).to be_nil
+ expect(ohai.data[:home]).to eq("dog")
end
end
end
@@ -395,14 +395,14 @@ EOF
it "should collect all data" do
ohai.all_plugins
[:v6message, :v7message, :messages].each do |attribute|
- ohai.data.should have_key(attribute)
+ expect(ohai.data).to have_key(attribute)
end
- ohai.data[:v6message].should eql("update me!")
- ohai.data[:v7message].should eql("v7 plugins are awesome!")
+ expect(ohai.data[:v6message]).to eql("update me!")
+ expect(ohai.data[:v7message]).to eql("v7 plugins are awesome!")
[:v6message, :v7message].each do |subattr|
- ohai.data[:messages].should have_key(subattr)
- ohai.data[:messages][subattr].should eql(ohai.data[subattr])
+ expect(ohai.data[:messages]).to have_key(subattr)
+ expect(ohai.data[:messages][subattr]).to eql(ohai.data[subattr])
end
end
end
@@ -438,7 +438,7 @@ EOF
it "version 6 should run" do
ohai.load_plugins
ohai.require_plugin("message")
- ohai.data[:message].should eql("From Version 6")
+ expect(ohai.data[:message]).to eql("From Version 6")
end
end
@@ -485,10 +485,10 @@ EOF
it "should collect all the data properly" do
ohai.all_plugins
- ohai.data[:v7message].should == "Hellos from 7: animals"
- ohai.data[:zoo].should == "animals"
- ohai.data[:message][:v6message].should == "Hellos from 6"
- ohai.data[:message][:copy_message].should == "Hellos from 7: animals"
+ expect(ohai.data[:v7message]).to eq("Hellos from 7: animals")
+ expect(ohai.data[:zoo]).to eq("animals")
+ expect(ohai.data[:message][:v6message]).to eq("Hellos from 6")
+ expect(ohai.data[:message][:copy_message]).to eq("Hellos from 7: animals")
end
end
@@ -511,7 +511,7 @@ EOF
end
it "should raise DependencyNotFound" do
- lambda { ohai.all_plugins }.should raise_error(Ohai::Exceptions::DependencyNotFound)
+ expect { ohai.all_plugins }.to raise_error(Ohai::Exceptions::DependencyNotFound)
end
end
end
@@ -535,7 +535,7 @@ EOF
it "reloads only the v6 plugin when given a specific plugin to load" do
ohai.all_plugins
- lambda { ohai.all_plugins("a_v6plugin") }.should_not raise_error
+ expect { ohai.all_plugins("a_v6plugin") }.not_to raise_error
end
end
@@ -565,7 +565,7 @@ EOF
initial_value = ohai.data["random"]
ohai.all_plugins
updated_value = ohai.data["random"]
- initial_value.should_not == updated_value
+ expect(initial_value).not_to eq(updated_value)
end
end
@@ -623,21 +623,21 @@ EOF
end
it "should rerun the plugin providing the desired attributes" do
- ohai.data[:desired_attr_count].should == 1
+ expect(ohai.data[:desired_attr_count]).to eq(1)
ohai.refresh_plugins("desired_attr")
- ohai.data[:desired_attr_count].should == 2
+ expect(ohai.data[:desired_attr_count]).to eq(2)
end
it "should not re-run dependencies of the plugin providing the desired attributes" do
- ohai.data[:depended_attr_count].should == 1
+ expect(ohai.data[:depended_attr_count]).to eq(1)
ohai.refresh_plugins("desired_attr")
- ohai.data[:depended_attr_count].should == 1
+ expect(ohai.data[:depended_attr_count]).to eq(1)
end
it "should not re-run plugins unrelated to the plugin providing the desired attributes" do
- ohai.data[:other_attr_count].should == 1
+ expect(ohai.data[:other_attr_count]).to eq(1)
ohai.refresh_plugins("desired_attr")
- ohai.data[:other_attr_count].should == 1
+ expect(ohai.data[:other_attr_count]).to eq(1)
end
end
@@ -692,20 +692,20 @@ EOF
it "should run all the plugins when a top level attribute is specified" do
ohai.all_plugins("languages")
- ohai.data[:languages][:english][:version].should == 2014
- ohai.data[:languages][:french][:version].should == 2012
+ expect(ohai.data[:languages][:english][:version]).to eq(2014)
+ expect(ohai.data[:languages][:french][:version]).to eq(2012)
end
it "should run the first parent when a non-existent child is specified" do
ohai.all_plugins("languages/english/version")
- ohai.data[:languages][:english][:version].should == 2014
- ohai.data[:languages][:french].should be_nil
+ expect(ohai.data[:languages][:english][:version]).to eq(2014)
+ expect(ohai.data[:languages][:french]).to be_nil
end
it "should be able to run multiple plugins" do
ohai.all_plugins(["languages/english", "languages/french"])
- ohai.data[:languages][:english][:version].should == 2014
- ohai.data[:languages][:french][:version].should == 2012
+ expect(ohai.data[:languages][:english][:version]).to eq(2014)
+ expect(ohai.data[:languages][:french][:version]).to eq(2012)
end
end
diff --git a/spec/unit/util/file_helper_spec.rb b/spec/unit/util/file_helper_spec.rb
index 2838ff5c..b5137d1e 100644
--- a/spec/unit/util/file_helper_spec.rb
+++ b/spec/unit/util/file_helper_spec.rb
@@ -28,12 +28,12 @@ describe "Ohai::Util::FileHelper" do
let(:file_helper) { FileHelperMock.new }
before(:each) do
- File.stub(:executable?).and_return(false)
+ allow(File).to receive(:executable?).and_return(false)
end
describe "which" do
it "returns the path to an executable that is in the path" do
- File.stub(:executable?).with('/usr/bin/skyhawk').and_return(true)
+ allow(File).to receive(:executable?).with('/usr/bin/skyhawk').and_return(true)
expect(file_helper.which('skyhawk')).to eql "/usr/bin/skyhawk"
end