diff options
author | Tim Smith <tsmith@chef.io> | 2016-11-18 12:00:47 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2016-12-01 10:58:06 -0800 |
commit | 3b65f582afe867180573313db3eb6450abf1da9b (patch) | |
tree | 4eadf04c5959ad39cb56e150f7fa510925b32168 | |
parent | 5f43d30a38cee0a87c479988283a6bd934c07d01 (diff) | |
download | ohai-rubocop_rspec.tar.gz |
rspec-rubocop autofix the specsrubocop_rspec
Signed-off-by: Tim Smith <tsmith@chef.io>
129 files changed, 804 insertions, 804 deletions
diff --git a/spec/functional/application_spec.rb b/spec/functional/application_spec.rb index 79e8c3ed..127abaee 100644 --- a/spec/functional/application_spec.rb +++ b/spec/functional/application_spec.rb @@ -26,12 +26,12 @@ RSpec.describe "Ohai::Application" do let(:argv) { [] } let(:stderr) { StringIO.new } - before(:each) do + before do @original_argv = ARGV.dup ARGV.replace(argv) end - after(:each) do + after do ARGV.replace(@original_argv) end @@ -41,13 +41,13 @@ RSpec.describe "Ohai::Application" do let(:config_dir) { Dir.mktmpdir(".chef") } let(:config_location) { File.join(config_dir, "config.rb") } - before(:each) do + before do File.open(config_location, "w+") do |f| f.write(config_content) end end - after(:each) do + after do FileUtils.rm_rf(config_dir) end @@ -75,7 +75,7 @@ RSpec.describe "Ohai::Application" do # https://github.com/chef/chef/blob/master/chef-config/lib/chef-config/workstation_config_loader.rb#L102 let(:env) { { "KNIFE_HOME" => config_dir } } - before(:each) do + before do allow_any_instance_of(ChefConfig::WorkstationConfigLoader). to receive(:env).and_return(env) end diff --git a/spec/functional/loader_spec.rb b/spec/functional/loader_spec.rb index def45b3e..2d98a91a 100644 --- a/spec/functional/loader_spec.rb +++ b/spec/functional/loader_spec.rb @@ -25,7 +25,7 @@ RSpec.describe "Ohai::Loader" do let(:plugin_directory) { Dir.mktmpdir("plugins") } let(:plugin_path) { plugin_directory.tr("/", "\\") } - before(:each) do + before do Ohai.config[:plugin_path] = plugin_path plugin_content = <<-EOF @@ -38,7 +38,7 @@ EOF end end - after(:each) do + after do FileUtils.rm_rf(plugin_directory) end diff --git a/spec/functional/plugins/powershell_spec.rb b/spec/functional/plugins/powershell_spec.rb index 865bb850..affc2ed9 100644 --- a/spec/functional/plugins/powershell_spec.rb +++ b/spec/functional/plugins/powershell_spec.rb @@ -22,10 +22,10 @@ describe Ohai::System, "languages plugin" do VERSION_MATCHING_REGEX = /^(?:[\d]+\.)+[\d]+$/ describe "powershell plugin", :windows_only do RSpec.shared_examples "a version looking thing" do - it "should be present" do + it "is present" do expect(subject).not_to be_nil end - it "should look like a version" do + it "looks like a version" do expect(subject).to match(VERSION_MATCHING_REGEX) end end @@ -37,7 +37,7 @@ describe Ohai::System, "languages plugin" do subject { @plugin[:languages][:powershell] } - it "should have information about powershell" do + it "has information about powershell" do expect(subject).not_to be_nil end diff --git a/spec/functional/plugins/root_group_spec.rb b/spec/functional/plugins/root_group_spec.rb index 781582d8..2c7c8b8d 100644 --- a/spec/functional/plugins/root_group_spec.rb +++ b/spec/functional/plugins/root_group_spec.rb @@ -26,7 +26,7 @@ describe Ohai::System, "root_group plugin" do describe "windows platform", :windows_only do let (:wmi) { wmi = WmiLite::Wmi.new } - it 'should return the system\'s administrators (root) group' do + it 'returns the system\'s administrators (root) group' do # Notethat the Win32_Group WMI provider can be slow if your # system is domain-joined and has hundreds of thousands of # groups in Active Directory -- not a typical test scenario, but diff --git a/spec/functional/plugins/windows/uptime_spec.rb b/spec/functional/plugins/windows/uptime_spec.rb index d1abd681..3f093363 100644 --- a/spec/functional/plugins/windows/uptime_spec.rb +++ b/spec/functional/plugins/windows/uptime_spec.rb @@ -33,18 +33,18 @@ describe Ohai::System, "Windows plugin uptime" do }) end - before(:each) do + before do allow(uptime_plugin).to receive(:collect_os).and_return(:windows) allow(WmiLite::Wmi).to receive(:new).and_return(wmi) allow(Time).to receive_message_chain(:new, :to_i).and_return(1473756619) end - it "should set uptime_seconds to uptime" do + it "sets uptime_seconds to uptime" do uptime_plugin.run expect(uptime_plugin[:uptime_seconds]).to be == 80331 end - it "should set uptime to a human readable value" do + it "sets uptime to a human readable value" do uptime_plugin.run expect(uptime_plugin[:uptime]).to eq("22 hours 18 minutes 51 seconds") end @@ -63,17 +63,17 @@ describe Ohai::System, "Windows plugin uptime" do }) end - before(:each) do + before do allow(uptime_plugin).to receive(:collect_os).and_return(:windows) allow(WmiLite::Wmi).to receive(:new).and_return(wmi) end - it "should set uptime_seconds to uptime" do + it "sets uptime_seconds to uptime" do uptime_plugin.run expect(uptime_plugin[:uptime_seconds]).to be == 785345 end - it "should set uptime to a human readable value" do + it "sets uptime to a human readable value" do uptime_plugin.run expect(uptime_plugin[:uptime]).to eq("9 days 02 hours 09 minutes 05 seconds") end diff --git a/spec/ohai_spec.rb b/spec/ohai_spec.rb index 376356b0..f4d091d2 100644 --- a/spec/ohai_spec.rb +++ b/spec/ohai_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/spec_helper.rb") describe Ohai do - it "should have a version constant defined" do + it "has a version constant defined" do expect(Ohai::VERSION).to be_a_kind_of(String) end diff --git a/spec/support/integration_helper.rb b/spec/support/integration_helper.rb index 38554e40..873cd75d 100644 --- a/spec/support/integration_helper.rb +++ b/spec/support/integration_helper.rb @@ -4,11 +4,11 @@ module IntegrationSupport def when_plugins_directory(description, &block) context "When the plugins directory #{description}" do - before(:each) do + before do @plugins_directory = Dir.mktmpdir("ohai-plugins") end - after(:each) do + after do if @plugins_directory begin FileUtils.remove_entry_secure(@plugins_directory) @@ -32,7 +32,7 @@ module IntegrationSupport end def self.with_plugin(plugin_path, contents) # rubocop:disable Lint/NestedMethodDefinition - before :each do + before do with_plugin(plugin_path, contents) end end diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index e815063f..e714ab30 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -25,12 +25,12 @@ RSpec.describe "Ohai::Application" do let(:argv) { [] } let(:app) { Ohai::Application.new } - before(:each) do + before do @original_argv = ARGV ARGV.replace(argv) end - after(:each) do + after do ARGV.replace(@original_argv) end @@ -42,7 +42,7 @@ RSpec.describe "Ohai::Application" do context "when specified on the command line" do let(:argv) { [ "-c", config_file ] } - before(:each) do + before do if windows? expect(ChefConfig::WorkstationConfigLoader).to receive(:new). with("C:#{config_file}", Ohai::Log). @@ -69,7 +69,7 @@ RSpec.describe "Ohai::Application" do end context "when a local workstation config exists" do - before(:each) do + before do expect(ChefConfig::WorkstationConfigLoader).to receive(:new). with(nil, Ohai::Log). and_return(config_loader) @@ -87,7 +87,7 @@ RSpec.describe "Ohai::Application" do let(:directory) { "/some/fantastic/plugins" } it "does not generate deprecated config warnings for cli options" do - expect(Ohai::Log).to_not receive(:warn). + expect(Ohai::Log).not_to receive(:warn). with(/Ohai::Config\[:directory\] is deprecated/) app.configure_ohai end diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 4be23ce8..64f3cb01 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -27,16 +27,16 @@ RSpec.describe Ohai::Config do it "logs a deprecation warning and sets the value" do expect(Ohai::Log).to receive(:warn). with(/Ohai::Config\[:#{option}\] is deprecated/) - Ohai::Config[option] = value - expect(Ohai::Config[option]).to eq(value) + described_class[option] = value + expect(described_class[option]).to eq(value) end end shared_examples_for "appendable option" do it "sets the value" do - expect(Ohai::Log).to_not receive(:warn) - Ohai::Config[option] << value - expect(Ohai::Config[option]).to include(value) + expect(Ohai::Log).not_to receive(:warn) + described_class[option] << value + expect(described_class[option]).to include(value) end end @@ -93,33 +93,33 @@ RSpec.describe Ohai::Config do describe "config_context :ohai" do describe "option :plugin" do it "gets configured with a value" do - Ohai::Config.ohai[:plugin][:foo] = true - expect(Ohai::Config.ohai[:plugin]).to have_key(:foo) - expect(Ohai::Config.ohai[:plugin][:foo]).to be true + described_class.ohai[:plugin][:foo] = true + expect(described_class.ohai[:plugin]).to have_key(:foo) + expect(described_class.ohai[:plugin][:foo]).to be true end it "gets configured with a Hash" do value = { :bar => true, :baz => true } - Ohai::Config.ohai[:plugin][:foo] = value - expect(Ohai::Config.ohai[:plugin]).to have_key(:foo) - expect(Ohai::Config.ohai[:plugin][:foo]).to eq(value) + described_class.ohai[:plugin][:foo] = value + expect(described_class.ohai[:plugin]).to have_key(:foo) + expect(described_class.ohai[:plugin][:foo]).to eq(value) end it "raises an error if the plugin name is not a symbol" do - expect { Ohai::Config.ohai[:plugin]["foo"] = false }. + expect { described_class.ohai[:plugin]["foo"] = false }. to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/) end it "raises an error if the value Hash has non-Symbol key" do value = { :bar => true, "baz" => true } - expect { Ohai::Config.ohai[:plugin][:foo] = value }. + expect { described_class.ohai[:plugin][:foo] = value }. to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/) end end end describe "::merge_deprecated_config" do - before(:each) do + before do allow(Ohai::Log).to receive(:warn) configure_ohai end @@ -131,17 +131,17 @@ RSpec.describe Ohai::Config do end it "merges top-level config values into the ohai config context" do - Ohai::Config.merge_deprecated_config - expect(Ohai::Config.ohai.configuration).to eq (Ohai::Config.configuration) + described_class.merge_deprecated_config + expect(described_class.ohai.configuration).to eq (described_class.configuration) end shared_examples_for "delayed warn" do it "logs a deprecation warning and merges the value" do expect(Ohai::Log).to receive(:warn). with(/Ohai::Config\[:#{option}\] is deprecated/) - Ohai::Config[option] << value - Ohai::Config.merge_deprecated_config - expect(Ohai::Config.ohai[option]).to include(value) + described_class[option] << value + described_class.merge_deprecated_config + expect(described_class.ohai[option]).to include(value) end end @@ -162,7 +162,7 @@ RSpec.describe Ohai::Config do describe "Ohai.config" do it "returns the ohai config context" do - expect(Ohai.config).to eq(Ohai::Config.ohai) + expect(Ohai.config).to eq(described_class.ohai) end end end diff --git a/spec/unit/dsl/plugin_spec.rb b/spec/unit/dsl/plugin_spec.rb index a5f99920..72772443 100644 --- a/spec/unit/dsl/plugin_spec.rb +++ b/spec/unit/dsl/plugin_spec.rb @@ -155,7 +155,7 @@ shared_examples "Ohai::DSL::Plugin" do end context "when getting attributes" do - before(:each) do + before do plugin.set_attribute(:tea, "is soothing") end @@ -170,7 +170,7 @@ shared_examples "Ohai::DSL::Plugin" do end describe "a top-level attribute" do - before(:each) do + before do plugin.set_attribute(:tea, "is soothing") end @@ -196,7 +196,7 @@ shared_examples "Ohai::DSL::Plugin" do end describe "a nested attribute" do - before(:each) do + before do plugin.set_attribute(:the_monarch, { arch_rival: "dr_venture" }) end @@ -282,12 +282,12 @@ shared_examples "Ohai::DSL::Plugin" do describe "a top-level attribute" do describe "as a string" do it "returns false when the attribute does not exist" do - expect(plugin.attribute?("alice in chains")).to eql(false) + expect(plugin.attribute?("alice in chains")).to be(false) end it "returns true if an attribute exists with the given name" do plugin.metallica("death magnetic") - expect(plugin.attribute?("metallica")).to eql(true) + expect(plugin.attribute?("metallica")).to be(true) end end @@ -304,7 +304,7 @@ shared_examples "Ohai::DSL::Plugin" do end describe "a nested attribute" do - before(:each) do + before do plugin.set_attribute(:the_monarch, { arch_rival: "dr_venture" }) end @@ -384,7 +384,7 @@ end describe Ohai::DSL::Plugin::VersionVII do it "does not modify the plugin name when the plugin is named correctly" do plugin = Ohai.plugin(:FunkyVALIDpluginName) {}.new({}) - expect(plugin.name).to eql(:FunkyVALIDpluginName) + expect(plugin.name).to be(:FunkyVALIDpluginName) end describe "when the plugin is named incorrectly" do @@ -410,7 +410,7 @@ describe Ohai::DSL::Plugin::VersionVII do describe "#version" do it "saves the plugin version as :version7" do plugin = Ohai.plugin(:Test) {} - expect(plugin.version).to eql(:version7) + expect(plugin.version).to be(:version7) end end @@ -538,7 +538,7 @@ describe Ohai::DSL::Plugin::VersionVII do describe "#provides (deprecated)" do it "logs a warning" do - plugin = Ohai::DSL::Plugin::VersionVII.new(Mash.new) + plugin = described_class.new(Mash.new) expect(Ohai::Log).to receive(:warn).with(/\[UNSUPPORTED OPERATION\]/) plugin.provides("attribute") end @@ -546,7 +546,7 @@ describe Ohai::DSL::Plugin::VersionVII do describe "#require_plugin (deprecated)" do it "logs a warning" do - plugin = Ohai::DSL::Plugin::VersionVII.new(Mash.new) + plugin = described_class.new(Mash.new) expect(Ohai::Log).to receive(:warn).with(/\[UNSUPPORTED OPERATION\]/) plugin.require_plugin("plugin") end @@ -575,7 +575,7 @@ describe Ohai::DSL::Plugin::VersionVII do it "does not auto-vivify an un-configured plugin" do plugin.configuration(:foo) - expect(Ohai.config[:plugin]).to_not have_key(:test) + expect(Ohai.config[:plugin]).not_to have_key(:test) end it "returns nil when the option is not configured" do @@ -627,7 +627,7 @@ describe Ohai::DSL::Plugin::VersionVII do it_behaves_like "Ohai::DSL::Plugin" do let(:ohai) { Ohai::System.new } - let(:plugin) { Ohai::DSL::Plugin::VersionVII.new(ohai.data) } + let(:plugin) { described_class.new(ohai.data) } let(:version) { :version7 } end end @@ -636,7 +636,7 @@ describe Ohai::DSL::Plugin::VersionVI do describe "#version" do it "saves the plugin version as :version6" do plugin = Class.new(Ohai::DSL::Plugin::VersionVI) {} - expect(plugin.version).to eql(:version6) + expect(plugin.version).to be(:version6) end end @@ -646,12 +646,12 @@ describe Ohai::DSL::Plugin::VersionVI do it "logs a debug message when provides is used" do allow(Ohai::Log).to receive(:debug) expect(Ohai::Log).to receive(:debug).with(/Skipping provides/) - plugin = Ohai::DSL::Plugin::VersionVI.new(ohai, "/some/plugin/path.rb", "/some/plugin") + plugin = described_class.new(ohai, "/some/plugin/path.rb", "/some/plugin") plugin.provides("attribute") end it "does not update the provides map for version 6 plugins." do - plugin = Ohai::DSL::Plugin::VersionVI.new(ohai, "/some/plugin/path.rb", "/some/plugin") + plugin = described_class.new(ohai, "/some/plugin/path.rb", "/some/plugin") plugin.provides("attribute") expect(ohai.provides_map.map).to be_empty end @@ -660,7 +660,7 @@ describe Ohai::DSL::Plugin::VersionVI do it_behaves_like "Ohai::DSL::Plugin" do let(:ohai) { Ohai::System.new } - let(:plugin) { Ohai::DSL::Plugin::VersionVI.new(ohai, "/some/plugin/path.rb", "/some/plugin") } + let(:plugin) { described_class.new(ohai, "/some/plugin/path.rb", "/some/plugin") } let(:version) { :version6 } end end diff --git a/spec/unit/loader_spec.rb b/spec/unit/loader_spec.rb index bfe2aa83..3de0ecf6 100644 --- a/spec/unit/loader_spec.rb +++ b/spec/unit/loader_spec.rb @@ -22,14 +22,14 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb") describe Ohai::Loader do extend IntegrationSupport - let(:loader) { Ohai::Loader.new(ohai) } + let(:loader) { described_class.new(ohai) } let(:ohai) { double("Ohai::System", :data => Mash.new, :provides_map => provides_map) } let(:provides_map) { Ohai::ProvidesMap.new } describe "#initialize" do it "returns an Ohai::Loader object" do - loader = Ohai::Loader.new(ohai) - expect(loader).to be_a_kind_of(Ohai::Loader) + loader = described_class.new(ohai) + expect(loader).to be_a_kind_of(described_class) end end @@ -73,7 +73,7 @@ EOF describe "when loading a v6 plugin" do let(:plugin) { loader.load_plugin(path_to("lake.rb"), path_to(".")) } - before(:each) do + before do expect(Ohai::Log).to receive(:warn).with(/\[DEPRECATION\]/) end diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb index fb4ce87f..d12f65b2 100644 --- a/spec/unit/mixin/command_spec.rb +++ b/spec/unit/mixin/command_spec.rb @@ -22,14 +22,14 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::Mixin::Command, "popen4" do break if RUBY_PLATFORM =~ /(win|w)32$/ - it "should default all commands to be run in the POSIX standard C locale" do + it "defaults 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 expect(stdout.read.strip).to eq("C") end end - it "should respect locale when specified explicitly" do + it "respects locale when specified explicitly" do Ohai::Mixin::Command.popen4("echo $LC_ALL", :environment => { "LC_ALL" => "es" }) do |pid, stdin, stdout, stderr| stdin.close expect(stdout.read.strip).to eq("es") @@ -50,14 +50,14 @@ describe Ohai::Mixin::Command, "popen4" do Encoding.default_internal = @saved_default_internal end - it "should force encode the string to UTF-8" do + it "forces encode the string to UTF-8" do extend Ohai::Mixin::Command snowy = run_command(:command => ("echo '" + ("☃" * 8096) + "'"))[1] expect(snowy.encoding).to eq(Encoding::UTF_8) end end - it "should force encode the string to UTF-8" do + it "forces encode the string to UTF-8" do extend Ohai::Mixin::Command snowy = run_command(:command => ("echo '" + ("☃" * 8096) + "'"))[1] expect(snowy.encoding).to eq(Encoding::UTF_8) @@ -94,7 +94,7 @@ describe Ohai::Mixin::Command, "shell_out" do let(:plugin_name) { :OSSparkleDream } - before(:each) do + before do allow(Ohai::Mixin::Command).to receive(:name).and_return(plugin_name) end diff --git a/spec/unit/mixin/ec2_metadata_spec.rb b/spec/unit/mixin/ec2_metadata_spec.rb index 2bd867d0..f8fda843 100644 --- a/spec/unit/mixin/ec2_metadata_spec.rb +++ b/spec/unit/mixin/ec2_metadata_spec.rb @@ -21,7 +21,7 @@ require "ohai/mixin/ec2_metadata" describe Ohai::Mixin::Ec2Metadata do let(:mixin) do - metadata_object = Object.new.extend(Ohai::Mixin::Ec2Metadata) + metadata_object = Object.new.extend(described_class) http_client = double("Net::HTTP client") allow(http_client).to receive(:get).and_return(response) allow(metadata_object).to receive(:http_client).and_return(http_client) diff --git a/spec/unit/mixin/softlayer_metadata_spec.rb b/spec/unit/mixin/softlayer_metadata_spec.rb index a4719685..655fdc34 100644 --- a/spec/unit/mixin/softlayer_metadata_spec.rb +++ b/spec/unit/mixin/softlayer_metadata_spec.rb @@ -23,7 +23,7 @@ require "ohai/mixin/softlayer_metadata" describe ::Ohai::Mixin::SoftlayerMetadata do let(:mixin) do - mixin = Object.new.extend(::Ohai::Mixin::SoftlayerMetadata) + mixin = Object.new.extend(described_class) mixin end diff --git a/spec/unit/plugins/abort_spec.rb b/spec/unit/plugins/abort_spec.rb index 6140419e..27048107 100644 --- a/spec/unit/plugins/abort_spec.rb +++ b/spec/unit/plugins/abort_spec.rb @@ -38,13 +38,13 @@ describe "a plug-in that aborts execution" do end end - before(:each) do + before do fail_file = File.open("#{tmp}/plugins/abort.rb", "w+") fail_file.write(abortstr) fail_file.close end - after(:each) do + after do File.delete("#{tmp}/plugins/abort.rb") end @@ -56,13 +56,13 @@ describe "a plug-in that aborts execution" do end end - before(:each) do + before do @ohai = Ohai::System.new @loader = Ohai::Loader.new(@ohai) @runner = Ohai::Runner.new(@ohai) end - it "should raise SystemExit" do + it "raises SystemExit" do @plugin = @loader.load_plugin("#{tmp}/plugins/abort.rb") expect { @runner.run_plugin(@plugin) }.to raise_error(SystemExit) end diff --git a/spec/unit/plugins/aix/cpu_spec.rb b/spec/unit/plugins/aix/cpu_spec.rb index 5cafedc8..cefd7d3e 100644 --- a/spec/unit/plugins/aix/cpu_spec.rb +++ b/spec/unit/plugins/aix/cpu_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX cpu plugin" do - before(:each) do + before do @lsdev_cc_processor = <<-LSDEV_CC_PROCESSOR proc0 Available 00-00 Processor proc4 Defined 00-04 Processor diff --git a/spec/unit/plugins/aix/filesystem_spec.rb b/spec/unit/plugins/aix/filesystem_spec.rb index 33d63af7..4b457da7 100644 --- a/spec/unit/plugins/aix/filesystem_spec.rb +++ b/spec/unit/plugins/aix/filesystem_spec.rb @@ -18,7 +18,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX filesystem plugin" do - before(:each) do + before do @df_pk_lpar = <<-DF_PK Filesystem 1024-blocks Used Available Capacity Mounted on /dev/hd4 2097152 219796 1877356 11% / diff --git a/spec/unit/plugins/aix/hostname_spec.rb b/spec/unit/plugins/aix/hostname_spec.rb index b378dd0a..56b76dd4 100644 --- a/spec/unit/plugins/aix/hostname_spec.rb +++ b/spec/unit/plugins/aix/hostname_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") allow(@plugin).to receive(:collect_os).and_return(:aix) allow(@plugin).to receive(:from_cmd).with("hostname -s").and_return("aix_admin") @@ -27,7 +27,7 @@ describe Ohai::System, "AIX hostname plugin" do @plugin.run end - it "should set the machinename" do + it "sets the machinename" do 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 a63023d6..fde6d135 100644 --- a/spec/unit/plugins/aix/kernel_spec.rb +++ b/spec/unit/plugins/aix/kernel_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX kernel plugin" do - before(:each) do + before do @plugin = get_plugin("aix/kernel") 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)) diff --git a/spec/unit/plugins/aix/memory_spec.rb b/spec/unit/plugins/aix/memory_spec.rb index cfe9862f..be652626 100644 --- a/spec/unit/plugins/aix/memory_spec.rb +++ b/spec/unit/plugins/aix/memory_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX memory plugin" do - before(:each) do + before do @plugin = get_plugin("aix/memory") allow(@plugin).to receive(:collect_os).and_return(:aix) allow(@plugin).to receive(:shell_out).with("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").and_return(mock_shell_out(0, " 513280.00 340034.17 173245.83 62535.17 230400.05 276950.14 70176.00\n", nil)) @@ -27,22 +27,22 @@ describe Ohai::System, "AIX memory plugin" do allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, nil)) end - it "should get total memory" do + it "gets total memory" do @plugin.run expect(@plugin["memory"]["total"]).to eql("#{513280 * 1024}kB") end - it "should get free memory" do + it "gets free memory" do @plugin.run expect(@plugin["memory"]["free"]).to eql("#{173245.83.to_i * 1024}kB") end - it "should get total swap" do + it "gets total swap" do @plugin.run expect(@plugin["memory"]["swap"]["total"]).to eql( "#{23887872 * 4}kB") end - it "should get free swap" do + it "gets free swap" do @plugin.run expect(@plugin["memory"]["swap"]["free"]).to eql( "#{23598960 * 4}kB") end diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb index 1007a868..ca19df77 100644 --- a/spec/unit/plugins/aix/network_spec.rb +++ b/spec/unit/plugins/aix/network_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX network plugin" do - before(:each) do + before do @netstat_rn_grep_default = <<-NETSTAT_RN_GREP_DEFAULT default 172.31.8.1 UG 2 121789 en0 - - NETSTAT_RN_GREP_DEFAULT diff --git a/spec/unit/plugins/aix/os_spec.rb b/spec/unit/plugins/aix/os_spec.rb index 6cc2227d..ded3335f 100644 --- a/spec/unit/plugins/aix/os_spec.rb +++ b/spec/unit/plugins/aix/os_spec.rb @@ -18,18 +18,18 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX os plugin" do - before(:each) do + before do @plugin = get_plugin("aix/os") allow(@plugin).to receive(:collect_os).and_return(:aix) allow(@plugin).to receive(:shell_out).with("oslevel -s").and_return(mock_shell_out(0, "7200-00-01-1543\n", nil)) @plugin.run end - it "should set the top-level os attribute" do - expect(@plugin[:os]).to eql(:aix) + it "sets the top-level os attribute" do + expect(@plugin[:os]).to be(:aix) end - it "should set the top-level os_level attribute" do + it "sets the top-level os_level attribute" do expect(@plugin[:os_version]).to eql("7200-00-01-1543") end end diff --git a/spec/unit/plugins/aix/platform_spec.rb b/spec/unit/plugins/aix/platform_spec.rb index 318bc427..2f3199e5 100644 --- a/spec/unit/plugins/aix/platform_spec.rb +++ b/spec/unit/plugins/aix/platform_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Aix plugin platform" do - before(:each) do + before do @plugin = get_plugin("aix/platform") allow(@plugin).to receive(:collect_os).and_return(:aix) kernel = Mash.new @@ -30,15 +30,15 @@ describe Ohai::System, "Aix plugin platform" do @plugin.run end - it "should set platform to aix" do + it "sets platform to aix" do expect(@plugin[:platform]).to eq("aix") end - it "should set the platform_version" do + it "sets the platform_version" do expect(@plugin[:platform_version]).to eq("7.1") end - it "should set platform_family" do + it "sets platform_family" do 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 071e561b..0520cb55 100644 --- a/spec/unit/plugins/aix/uptime_spec.rb +++ b/spec/unit/plugins/aix/uptime_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Aix plugin uptime" do - before(:each) do + before do @plugin = get_plugin("aix/uptime") allow(@plugin).to receive(:collect_os).and_return(:aix) allow(Time).to receive_message_chain(:now, :to_i).and_return(1412072511) @@ -31,11 +31,11 @@ describe Ohai::System, "Aix plugin uptime" do @plugin.run end - it "should set uptime_seconds to uptime" do + it "sets uptime_seconds to uptime" do expect(@plugin[:uptime_seconds]).to eq(511191) end - it "should set uptime to a human readable date" do + it "sets uptime to a human readable date" do 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 4d07f814..3ca71eea 100644 --- a/spec/unit/plugins/aix/virtualization_spec.rb +++ b/spec/unit/plugins/aix/virtualization_spec.rb @@ -31,7 +31,7 @@ describe Ohai::System, "AIX virtualization plugin" do p end - before(:each) do + before do @lswpar_l = <<-LSWPAR_L ================================================================= applejack-541ba3 - Active diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb index 63238114..257032f6 100644 --- a/spec/unit/plugins/azure_spec.rb +++ b/spec/unit/plugins/azure_spec.rb @@ -46,7 +46,7 @@ describe Ohai::System, "plugin azure" do end describe "with azure hint file" do - before(:each) do + before do allow(plugin).to receive(:hint?).with("azure").and_return(hint) end @@ -62,7 +62,7 @@ describe Ohai::System, "plugin azure" do end describe "without azure hint file or agent or dhcp options" do - before(:each) do + before do allow(plugin).to receive(:hint?).with("azure").and_return(false) allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false) @@ -95,7 +95,7 @@ describe Ohai::System, "plugin azure" do end describe "with rackspace hint file, no agent, and no dhcp lease" do - before(:each) do + before do allow(plugin).to receive(:hint?).with("rackspace").and_return(true) allow(plugin).to receive(:hint?).with("azure").and_return(false) allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false) @@ -107,7 +107,7 @@ describe Ohai::System, "plugin azure" do end describe "without azure hint file but with agent on linux" do - before(:each) do + before do allow(plugin).to receive(:hint?).with("azure").and_return(false) allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(true) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false) @@ -117,7 +117,7 @@ describe Ohai::System, "plugin azure" do end describe "without azure hint file but with agent on windows" do - before(:each) do + before do allow(plugin).to receive(:hint?).with("azure").and_return(false) allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(true) @@ -127,7 +127,7 @@ describe Ohai::System, "plugin azure" do end describe "without azure hint or agent but with dhcp option" do - before(:each) do + before do allow(plugin).to receive(:hint?).with("azure").and_return(false) allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false) diff --git a/spec/unit/plugins/bsd/filesystem_spec.rb b/spec/unit/plugins/bsd/filesystem_spec.rb index d337cf79..8a9077fc 100644 --- a/spec/unit/plugins/bsd/filesystem_spec.rb +++ b/spec/unit/plugins/bsd/filesystem_spec.rb @@ -21,7 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "BSD filesystem plugin" do let(:plugin) { get_plugin("bsd/filesystem") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:freebsd) allow(plugin).to receive(:shell_out).with("df").and_return(mock_shell_out(0, "", "")) @@ -30,7 +30,7 @@ describe Ohai::System, "BSD filesystem plugin" do end describe "when gathering filesystem usage data from df" do - before(:each) do + before do @stdout = <<-DF Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ada0p2 9637788 3313504 5553264 37% / @@ -46,55 +46,55 @@ DFi allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) end - it "should run df and df -iP" do + it "runs df and df -iP" do expect(plugin).to receive(:shell_out).ordered.with("df").and_return(mock_shell_out(0, @stdout, "")) expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) plugin.run end - it "should set kb_size to value from df" do + it "sets kb_size to value from df" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:kb_size]).to eq("9637788") end - it "should set kb_used to value from df" do + it "sets kb_used to value from df" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:kb_used]).to eq("3313504") end - it "should set kb_available to value from df" do + it "sets kb_available to value from df" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:kb_available]).to eq("5553264") end - it "should set percent_used to value from df" do + it "sets percent_used to value from df" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:percent_used]).to eq("37%") end - it "should set mount to value from df" do + it "sets mount to value from df" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/") end - it "should set total_inodes to value from df -iP" do + it "sets total_inodes to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:total_inodes]).to eq("1043326") end - it "should set inodes_used to value from df -iP" do + it "sets inodes_used to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_used]).to eq("252576") end - it "should set inodes_available to value from df -iP" do + it "sets inodes_available to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_available]).to eq("790750") end end describe "when gathering mounted filesystem data from mount" do - before(:each) do + before do @stdout = <<-MOUNT /dev/ada0p2 on / (ufs, local, journaled soft-updates) devfs on /dev (devfs, local, multilabel) @@ -102,22 +102,22 @@ MOUNT allow(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, "")) end - it "should run mount" do + it "runs mount" do expect(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set mount to value from mount" do + it "sets mount to value from mount" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/") end - it "should set fs_type to value from mount" do + it "sets fs_type to value from mount" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:fs_type]).to eq("ufs") end - it "should set mount_options to an array of values from mount" do + it "sets mount_options to an array of values from mount" do plugin.run expect(plugin[:filesystem]["/dev/ada0p2"][:mount_options]).to eq(["local", "journaled soft-updates"]) end diff --git a/spec/unit/plugins/bsd/virtualization_spec.rb b/spec/unit/plugins/bsd/virtualization_spec.rb index 1f2c273f..39e4ed37 100644 --- a/spec/unit/plugins/bsd/virtualization_spec.rb +++ b/spec/unit/plugins/bsd/virtualization_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "BSD virtualization plugin" do - before(:each) do + before do @plugin = get_plugin("bsd/virtualization") 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", "")) diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb index 322d396f..504a82ee 100644 --- a/spec/unit/plugins/c_spec.rb +++ b/spec/unit/plugins/c_spec.rb @@ -104,7 +104,7 @@ describe Ohai::System, "plugin c" do let(:plugin) { get_plugin("c") } - before(:each) do + before do plugin[:languages] = Mash.new #gcc diff --git a/spec/unit/plugins/chef_spec.rb b/spec/unit/plugins/chef_spec.rb index 952edbad..3de7a8b8 100644 --- a/spec/unit/plugins/chef_spec.rb +++ b/spec/unit/plugins/chef_spec.rb @@ -24,11 +24,11 @@ begin require "chef/version" describe Ohai::System, "plugin chef" do - before(:each) do + before do @plugin = get_plugin("chef") end - it "should set [:chef_packages][:chef][:version] to the current chef version", :if => defined?(Chef) do + it "sets [:chef_packages][:chef][:version] to the current chef version", :if => defined?(Chef) do @plugin.run expect(@plugin[:chef_packages][:chef][:version]).to eq(Chef::VERSION) end diff --git a/spec/unit/plugins/cloud_spec.rb b/spec/unit/plugins/cloud_spec.rb index d90465b1..4fc58c82 100644 --- a/spec/unit/plugins/cloud_spec.rb +++ b/spec/unit/plugins/cloud_spec.rb @@ -18,7 +18,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin cloud" do - before(:each) do + before do @plugin = get_plugin("cloud") end @@ -188,7 +188,7 @@ describe Ohai::System, "plugin cloud" do 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 + it "does not populate cloud public_ssh_port when winrm is used" do @plugin[:azure]["public_winrm_port"] = "5985" @plugin.run expect(@plugin[:cloud][:public_ssh_port]).to be_nil @@ -217,7 +217,7 @@ describe Ohai::System, "plugin cloud" do { "ip_address" => "fdf8:f53b:82e4::53", "type" => "private" }] end - before(:each) do + before do @plugin.run end diff --git a/spec/unit/plugins/cloud_v2_spec.rb b/spec/unit/plugins/cloud_v2_spec.rb index e08e519d..5c024e1d 100644 --- a/spec/unit/plugins/cloud_v2_spec.rb +++ b/spec/unit/plugins/cloud_v2_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") require "ipaddr" describe "CloudAttrs object" do - before(:each) do + before do @plugin = get_plugin("cloud_v2") end @@ -73,7 +73,7 @@ describe "CloudAttrs object" do end describe Ohai::System, "plugin cloud" do - before(:each) do + before do @plugin = get_plugin("cloud_v2") end @@ -302,7 +302,7 @@ describe Ohai::System, "plugin cloud" do expect(@plugin[:cloud_v2][:public_ssh_port]).to be_nil end - it "should not populate cloud public_ssh_port when winrm is used" do + it "does not populate cloud public_ssh_port when winrm is used" do @plugin[:azure]["public_winrm_port"] = "5985" @plugin.run expect(@plugin[:cloud_v2][:public_ssh_port]).to be_nil @@ -331,7 +331,7 @@ describe Ohai::System, "plugin cloud" do { "ip_address" => "fdf8:f53b:82e4::53", "type" => "private" }] end - before(:each) do + before do @plugin.run end diff --git a/spec/unit/plugins/darwin/cpu_spec.rb b/spec/unit/plugins/darwin/cpu_spec.rb index d6930c80..f11fd48a 100644 --- a/spec/unit/plugins/darwin/cpu_spec.rb +++ b/spec/unit/plugins/darwin/cpu_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin cpu plugin" do - before(:each) do + before do @plugin = get_plugin("darwin/cpu") allow(@plugin).to receive(:collect_os).and_return(:darwin) allow(@plugin).to receive(:shell_out).with("sysctl -n hw.packages").and_return(mock_shell_out(0, "1", "")) @@ -35,43 +35,43 @@ describe Ohai::System, "Darwin cpu plugin" do @plugin.run end - it "should set cpu[:cores] to 4" do + it "sets cpu[:cores] to 4" do expect(@plugin[:cpu][:cores]).to eq(4) end - it "should set cpu[:total] to 8" do + it "sets cpu[:total] to 8" do expect(@plugin[:cpu][:total]).to eq(8) end - it "should set cpu[:real] to 1" do + it "sets cpu[:real] to 1" do expect(@plugin[:cpu][:real]).to eq(1) end - it "should set cpu[:mhz] to 2300" do + it "sets cpu[:mhz] to 2300" do expect(@plugin[:cpu][:mhz]).to eq(2300) end - it "should set cpu[:vendor_id] to GenuineIntel" do + it "sets cpu[:vendor_id] to GenuineIntel" do 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 + it "sets cpu[:model_name] to Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz" do 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 + it "sets cpu[:model] to 58" do expect(@plugin[:cpu][:model]).to eq(58) end - it "should set cpu[:family] to 6" do + it "sets cpu[:family] to 6" do expect(@plugin[:cpu][:family]).to eq(6) end - it "should set cpu[:stepping] to 9" do + it "sets cpu[:stepping] to 9" do expect(@plugin[:cpu][:stepping]).to eq(9) end - it "should set cpu[:flags] to array of flags" do + it "sets cpu[:flags] to array of flags" do 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/filesystem2_spec.rb b/spec/unit/plugins/darwin/filesystem2_spec.rb index 2a652593..10091682 100644 --- a/spec/unit/plugins/darwin/filesystem2_spec.rb +++ b/spec/unit/plugins/darwin/filesystem2_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "darwin filesystem2 plugin" do let (:plugin) { get_plugin("darwin/filesystem2") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:darwin) allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", "")) @@ -28,7 +28,7 @@ describe Ohai::System, "darwin filesystem2 plugin" do end describe "when gathering filesystem usage data from df" do - before(:each) do + before do @stdout = <<-DF Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% / @@ -41,12 +41,12 @@ DF allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, "")) end - it "should run df -i" do + it "runs df -i" do expect(plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set size to value from df -i" do + it "sets size to value from df -i" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_size]).to eq("244277768") expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:kb_used]).to eq("156848224") @@ -54,13 +54,13 @@ DF expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:percent_used]).to eq("65%") end - it "should set device and mount to value from df -i" do + it "sets device and mount to value from df -i" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2") end - it "should set inode info to value from df -i" do + it "sets inode info to value from df -i" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440") expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:inodes_used]).to eq("39276054") @@ -69,7 +69,7 @@ DF end describe "when gathering mounted filesystem data from mount" do - before(:each) do + before do @stdout = <<-MOUNT /dev/disk0s2 on / (hfs, local, journaled) devfs on /dev (devfs, local, nobrowse) @@ -81,12 +81,12 @@ MOUNT allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) end - it "should run mount" do + it "runs mount" do expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set values from mount" do + it "sets values from mount" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs") @@ -95,7 +95,7 @@ MOUNT end describe "when gathering filesystem data with devices mounted more than once" do - before(:each) do + before do @dfstdout = <<-DF Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% / @@ -109,14 +109,14 @@ DF allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, "")) end - it "should provide a devices view with all mountpoints" do + it "provides a devices view with all mountpoints" do plugin.run expect(plugin[:filesystem2]["by_device"]["/dev/disk0s2"][:mounts]).to eq(["/", "/another/mountpoint"]) end end describe "when gathering filesystem data with double-mounts" do - before(:each) do + before do @dfstdout = <<-DF Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% / @@ -131,7 +131,7 @@ DF allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @dfstdout, "")) end - it "should provide a mounts view with all devices" do + it "provides a mounts view with all devices" do plugin.run expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/disk0s3", "/dev/disk0s4"]) end diff --git a/spec/unit/plugins/darwin/filesystem_spec.rb b/spec/unit/plugins/darwin/filesystem_spec.rb index b703bce9..14645eaa 100644 --- a/spec/unit/plugins/darwin/filesystem_spec.rb +++ b/spec/unit/plugins/darwin/filesystem_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "darwin filesystem plugin" do let (:plugin) { get_plugin("darwin/filesystem") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:darwin) allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, "", "")) @@ -28,7 +28,7 @@ describe Ohai::System, "darwin filesystem plugin" do end describe "when gathering filesystem usage data from df" do - before(:each) do + before do @stdout = <<-DF Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk0s2 488555536 313696448 174347088 65% 39276054 21793386 64% / @@ -41,12 +41,12 @@ DF allow(plugin).to receive(:shell_out).with("df -i").and_return(mock_shell_out(0, @stdout, "")) end - it "should run df -i" do + it "runs df -i" do expect(plugin).to receive(:shell_out).ordered.with("df -i").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set size to value from df -i" do + it "sets size to value from df -i" do plugin.run expect(plugin[:filesystem]["/dev/disk0s2"][:kb_size]).to eq(244277768) expect(plugin[:filesystem]["/dev/disk0s2"][:kb_used]).to eq(156848224) @@ -54,12 +54,12 @@ DF expect(plugin[:filesystem]["/dev/disk0s2"][:percent_used]).to eq("65%") end - it "should set mount to value from df -i" do + it "sets mount to value from df -i" do plugin.run expect(plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/") end - it "should set inode info to value from df -i" do + it "sets inode info to value from df -i" do plugin.run expect(plugin[:filesystem]["/dev/disk0s2"][:total_inodes]).to eq("61069440") expect(plugin[:filesystem]["/dev/disk0s2"][:inodes_used]).to eq("39276054") @@ -68,7 +68,7 @@ DF end describe "when gathering mounted filesystem data from mount" do - before(:each) do + before do @stdout = <<-MOUNT /dev/disk0s2 on / (hfs, local, journaled) devfs on /dev (devfs, local, nobrowse) @@ -80,12 +80,12 @@ MOUNT allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) end - it "should run mount" do + it "runs mount" do expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set values from mount" do + it "sets values from mount" do plugin.run expect(plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/") expect(plugin[:filesystem]["/dev/disk0s2"][:fs_type]).to eq("hfs") diff --git a/spec/unit/plugins/darwin/hardware_spec.rb b/spec/unit/plugins/darwin/hardware_spec.rb index de69f3ee..e35fbb36 100644 --- a/spec/unit/plugins/darwin/hardware_spec.rb +++ b/spec/unit/plugins/darwin/hardware_spec.rb @@ -21,7 +21,7 @@ require File.expand_path("#{File.dirname(__FILE__)}/hardware_system_profiler_out describe Ohai::System, "Darwin hardware plugin", :unix_only do let (:plugin) { get_plugin("darwin/hardware") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:darwin) # Make sure it always runs correct commands and mock the data as it calls them allow(plugin).to receive(:shell_out).with( diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb index b95c8f8a..563b1914 100644 --- a/spec/unit/plugins/darwin/hostname_spec.rb +++ b/spec/unit/plugins/darwin/hostname_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") 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", "")) @@ -31,12 +31,12 @@ describe Ohai::System, "Darwin hostname plugin" do it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local") - it "should use #resolve_fqdn to find the fqdn" do + it "uses #resolve_fqdn to find the fqdn" do @plugin.run expect(@plugin[:fqdn]).to eq("katie.bethell") end - it "should set the domain to everything after the first dot of the fqdn" do + it "sets the domain to everything after the first dot of the fqdn" do @plugin.run expect(@plugin[:domain]).to eq("bethell") end diff --git a/spec/unit/plugins/darwin/kernel_spec.rb b/spec/unit/plugins/darwin/kernel_spec.rb index 54cdb7b4..497a40fb 100644 --- a/spec/unit/plugins/darwin/kernel_spec.rb +++ b/spec/unit/plugins/darwin/kernel_spec.rb @@ -19,13 +19,13 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin kernel plugin" do - before(:each) do + before do @plugin = get_plugin("kernel") 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 + it "populates kernel[:modules] from `kextstat -k -l`" do 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> @@ -42,21 +42,21 @@ EOF expect(@plugin[:kernel][:modules]).to eql(modules) end - it "should not set kernel_machine to x86_64" do + it "does not set kernel_machine to x86_64" do 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 expect(@plugin[:kernel][:machine]).not_to eq("x86_64") end - it "should set kernel_machine to x86_64" do + it "sets kernel_machine to x86_64" do 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 expect(@plugin[:kernel][:machine]).to eq("x86_64") end - it "should set the kernel_os to the kernel_name value" do + it "sets the kernel_os to the kernel_name value" do 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 diff --git a/spec/unit/plugins/darwin/memory_spec.rb b/spec/unit/plugins/darwin/memory_spec.rb index b089fb87..b15d8fe2 100644 --- a/spec/unit/plugins/darwin/memory_spec.rb +++ b/spec/unit/plugins/darwin/memory_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin Memory Plugin" do - before(:each) do + before do darwin_memsize = <<-DARWIN_MEMSIZE 17179869184 DARWIN_MEMSIZE @@ -46,19 +46,19 @@ Object cache: 12 hits of 139872 lookups (0% hit rate) @plugin.run end - it "should set memory[:total] to 16384MB" do + it "sets memory[:total] to 16384MB" do expect(@plugin[:memory][:total]).to eq("16384MB") end - it "should set memory[:active] to 5140MB" do + it "sets memory[:active] to 5140MB" do expect(@plugin[:memory][:active]).to eq("5140MB") end - it "should set memory[:inactive] to 738MB" do + it "sets memory[:inactive] to 738MB" do expect(@plugin[:memory][:inactive]).to eq("738MB") end - it "should set memory[:free] to 10504MB" do + it "sets memory[:free] to 10504MB" do 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 7b549dea..e5be6869 100644 --- a/spec/unit/plugins/darwin/network_spec.rb +++ b/spec/unit/plugins/darwin/network_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin Network Plugin" do - before(:each) do + before do @darwin_ifconfig = <<-DARWIN_IFCONFIG lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=3<RXCSUM,TXCSUM> @@ -430,7 +430,7 @@ net.smb.fs.tcprcvbuf: 261120 end describe "gathering IP layer address info" do - before(:each) do + before do 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, "")) @@ -549,7 +549,7 @@ net.smb.fs.tcprcvbuf: 261120 expect(@plugin["network"][:default_gateway]).to eq("10.20.10.1") end - it "should detect network settings" do + it "detects network settings" do 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") diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb index 53a8ff21..052c1d90 100644 --- a/spec/unit/plugins/darwin/platform_spec.rb +++ b/spec/unit/plugins/darwin/platform_spec.rb @@ -19,51 +19,51 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin plugin platform" do - before(:each) do + before do @plugin = get_plugin("darwin/platform") allow(@plugin).to receive(:collect_os).and_return(:darwin) @stdout = "ProductName: Mac OS X\nProductVersion: 10.5.5\nBuildVersion: 9F33" 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 + it "runs sw_vers" do 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 + it "sets platform to ProductName, downcased with _ for \\s" do @plugin.run expect(@plugin[:platform]).to eq("mac_os_x") end - it "should set platform_version to ProductVersion" do + it "sets platform_version to ProductVersion" do @plugin.run expect(@plugin[:platform_version]).to eq("10.5.5") end - it "should set platform_build to BuildVersion" do + it "sets platform_build to BuildVersion" do @plugin.run expect(@plugin[:platform_build]).to eq("9F33") end - it "should set platform_family to mac_os_x" do + it "sets platform_family to mac_os_x" do @plugin.run expect(@plugin[:platform_family]).to eq("mac_os_x") end describe "on os x server" do - before(:each) do + before do @plugin[:os] = "darwin" @stdout = "ProductName: Mac OS X Server\nProductVersion: 10.6.8\nBuildVersion: 10K549" 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 + it "sets platform to mac_os_x_server" do @plugin.run expect(@plugin[:platform]).to eq("mac_os_x_server") end - it "should set platform_family to mac_os_x" do + it "sets platform_family to mac_os_x" do @plugin.run expect(@plugin[:platform_family]).to eq("mac_os_x") end diff --git a/spec/unit/plugins/darwin/system_profiler_spec.rb b/spec/unit/plugins/darwin/system_profiler_spec.rb index 98b6c845..99089e13 100644 --- a/spec/unit/plugins/darwin/system_profiler_spec.rb +++ b/spec/unit/plugins/darwin/system_profiler_spec.rb @@ -27,12 +27,12 @@ rescue LoadError => e end describe Ohai::System, "Darwin system_profiler plugin", :unix_only do - before(:each) do + before do @plugin = get_plugin("darwin/system_profiler") allow(@plugin).to receive(:collect_os).and_return(:darwin) end - it "should return the right serial number" do + it "returns the right serial number" do mini_cmd = "system_profiler -xml -detailLevel mini SPParallelATAData SPAudioData SPBluetoothData" mini_cmd += " SPCardReaderData SPDiagnosticsData SPDiscBurningData SPEthernetData SPFibreChannelData" mini_cmd += " SPFireWireData SPDisplaysData SPHardwareRAIDData SPMemoryData SPModemData SPNetworkData" diff --git a/spec/unit/plugins/darwin/virtualization_spec.rb b/spec/unit/plugins/darwin/virtualization_spec.rb index 0529699a..d25d1e77 100644 --- a/spec/unit/plugins/darwin/virtualization_spec.rb +++ b/spec/unit/plugins/darwin/virtualization_spec.rb @@ -23,7 +23,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin virtualization platform" do let(:plugin) { get_plugin("darwin/virtualization") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:darwin) allow(plugin).to receive(:prlctl_exists?).and_return(false) allow(plugin).to receive(:ioreg_exists?).and_return(false) @@ -32,12 +32,12 @@ describe Ohai::System, "Darwin virtualization platform" do end describe "when detecting OS X virtualization" do - it "should not set virtualization keys if no binaries are found" do + it "does not set virtualization keys if no binaries are found" do plugin.run expect(plugin[:virtualization]).to eq({ "systems" => {} }) end - it "should set vmware host if /Applications/VMware\ Fusion.app exists" do + it "sets vmware host if /Applications/VMware\ Fusion.app exists" do allow(plugin).to receive(:fusion_exists?).and_return(true) plugin.run expect(plugin[:virtualization][:system]).to eq("vmware") @@ -45,7 +45,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:vmware]).to eq("host") end - it "should set vbox host if /usr/local/bin/VBoxManage exists" do + it "sets vbox host if /usr/local/bin/VBoxManage exists" do allow(plugin).to receive(:vboxmanage_exists?).and_return("/usr/local/bin/VBoxManage") plugin.run expect(plugin[:virtualization][:system]).to eq("vbox") @@ -53,7 +53,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:vbox]).to eq("host") end - it "should set parallels host if /usr/bin/prlctl exists" do + it "sets parallels host if /usr/bin/prlctl exists" do allow(plugin).to receive(:prlctl_exists?).and_return("/usr/bin/prlctl") plugin.run expect(plugin[:virtualization][:system]).to eq("parallels") @@ -61,7 +61,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:parallels]).to eq("host") end - it "should set parallels guest if /usr/sbin/ioreg exists and its output contains pci1ab8,4000" do + it "sets parallels guest if /usr/sbin/ioreg exists and its output contains pci1ab8,4000" do allow(plugin).to receive(:ioreg_exists?).and_return(true) ioreg = <<-IOREG | | +-o pci1ab8,4000@3 <class IOPCIDevice, id 0x1000001d1, registered, matched, active, busy 0 (40 ms), retain 9> @@ -95,7 +95,7 @@ describe Ohai::System, "Darwin virtualization platform" do expect(plugin[:virtualization][:systems][:parallels]).to eq("guest") end - it "should not set parallels guest if /usr/sbin/ioreg exists and its output not contain pci1ab8,4000" do + it "does not set parallels guest if /usr/sbin/ioreg exists and its output not contain pci1ab8,4000" do allow(plugin).to receive(:ioreg_exists?).and_return(true) ioreg = <<-IOREG | | +-o pci8086,2445@1F,4 <class IOPCIDevice, id 0x1000001d4, registered, matched, active, busy 0 (974 ms), retain 11> diff --git a/spec/unit/plugins/digital_ocean_spec.rb b/spec/unit/plugins/digital_ocean_spec.rb index 45b0109d..13cfe146 100644 --- a/spec/unit/plugins/digital_ocean_spec.rb +++ b/spec/unit/plugins/digital_ocean_spec.rb @@ -56,7 +56,7 @@ describe Ohai::System, "plugin digital_ocean" do end shared_examples_for "!digital_ocean" do - before(:each) do + before do plugin.run end @@ -81,7 +81,7 @@ describe Ohai::System, "plugin digital_ocean" do end shared_examples_for "digital_ocean" do - before(:each) do + before do plugin.run end diff --git a/spec/unit/plugins/dmi_spec.rb b/spec/unit/plugins/dmi_spec.rb index 08a0bf25..064db79c 100644 --- a/spec/unit/plugins/dmi_spec.rb +++ b/spec/unit/plugins/dmi_spec.rb @@ -101,13 +101,13 @@ Chassis Information EOS describe Ohai::System, "plugin dmi" do - before(:each) do + before do @plugin = get_plugin("dmi") @stdout = DMI_OUT allow(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, "")) end - it "should run dmidecode" do + it "runs dmidecode" do expect(@plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, @stdout, "")) @plugin.run end @@ -141,7 +141,7 @@ describe Ohai::System, "plugin dmi" do end end - it "should correctly ignore unwanted data" do + it "correctlies ignore unwanted data" do @plugin.run expect(@plugin[:dmi][:base_board]).not_to have_key(:error_correction_type) end diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb index df0f00d0..050c681a 100644 --- a/spec/unit/plugins/ec2_spec.rb +++ b/spec/unit/plugins/ec2_spec.rb @@ -23,7 +23,7 @@ require "base64" describe Ohai::System, "plugin ec2" do - before(:each) do + before do allow(plugin).to receive(:hint?).with("ec2").and_return(false) allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(false) end @@ -41,7 +41,7 @@ describe Ohai::System, "plugin ec2" do shared_examples_for "ec2" do let(:plugin) { get_plugin("ec2") } - before(:each) do + before do @http_client = double("Net::HTTP client") allow(plugin).to receive(:http_client).and_return(@http_client) allow(IO).to receive(:select).and_return([[], [1], []]) @@ -250,7 +250,7 @@ describe Ohai::System, "plugin ec2" do describe "with ec2 dmi data" do it_behaves_like "ec2" - before(:each) do + before do plugin[:dmi] = { :bios => { :all_records => [ { :Version => "4.2.amazon" } ] } } end end @@ -258,7 +258,7 @@ describe Ohai::System, "plugin ec2" do describe "with amazon kernel data" do it_behaves_like "ec2" - before(:each) do + before do plugin[:kernel] = { :os_info => { :organization => "Amazon.com" } } end end @@ -266,7 +266,7 @@ describe Ohai::System, "plugin ec2" do describe "with EC2 Xen UUID" do it_behaves_like "ec2" - before(:each) do + before do allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(true) allow(File).to receive(:read).with("/sys/hypervisor/uuid").and_return("ec2a0561-e4d6-8e15-d9c8-2e0e03adcde8") end @@ -275,7 +275,7 @@ describe Ohai::System, "plugin ec2" do describe "with non-EC2 Xen UUID" do it_behaves_like "!ec2" - before(:each) do + before do allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(true) allow(File).to receive(:read).with("/sys/hypervisor/uuid").and_return("123a0561-e4d6-8e15-d9c8-2e0e03adcde8") end @@ -284,14 +284,14 @@ describe Ohai::System, "plugin ec2" do describe "with ec2 hint file" do it_behaves_like "ec2" - before(:each) do + before do allow(plugin).to receive(:hint?).with("ec2").and_return({}) end end describe "without any hints that it is an ec2 system" do it_behaves_like "!ec2" - before(:each) do + before do allow(plugin).to receive(:hint?).with("ec2").and_return(false) plugin[:dmi] = nil end diff --git a/spec/unit/plugins/elixir_spec.rb b/spec/unit/plugins/elixir_spec.rb index c3191985..290f3353 100644 --- a/spec/unit/plugins/elixir_spec.rb +++ b/spec/unit/plugins/elixir_spec.rb @@ -19,11 +19,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_he describe Ohai::System, "plugin elixir" do let(:plugin) { get_plugin("elixir") } - before(:each) do + before do plugin[:languages] = Mash.new end - it "should shellout to elixir -v" do + it "shellouts to elixir -v" do expect(plugin).to receive(:shell_out).with("elixir -v").and_return(mock_shell_out(0, "Elixir 1.0.2", "")) plugin.run end diff --git a/spec/unit/plugins/erlang_spec.rb b/spec/unit/plugins/erlang_spec.rb index b7f51f14..8a789680 100644 --- a/spec/unit/plugins/erlang_spec.rb +++ b/spec/unit/plugins/erlang_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin erlang" do let(:plugin) { get_plugin("erlang") } - before(:each) do + before do plugin[:languages] = Mash.new erl_v_output = "Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 7.3\n" erl_systeminfo_output = "\"18\"\r\n\"7.3\"\r\n\"2.10\"\r\n" diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb index e834b430..e31673ae 100644 --- a/spec/unit/plugins/eucalyptus_spec.rb +++ b/spec/unit/plugins/eucalyptus_spec.rb @@ -31,7 +31,7 @@ describe Ohai::System, "plugin eucalyptus" do end shared_examples_for "eucalyptus" do - before(:each) do + before do @http_client = double("Net::HTTP client") allow(plugin).to receive(:http_client).and_return(@http_client) @@ -71,7 +71,7 @@ describe Ohai::System, "plugin eucalyptus" do describe "with eucalyptus mac and metadata address connected" do it_behaves_like "eucalyptus" - before(:each) do + before do allow(IO).to receive(:select).and_return([[], [1], []]) plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED" => { "family" => "lladdr" } } } } } end @@ -80,7 +80,7 @@ describe Ohai::System, "plugin eucalyptus" do describe "without eucalyptus mac and metadata address connected" do it_behaves_like "!eucalyptus" - before(:each) do + before do plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "ff:ff:95:47:6E:ED" => { "family" => "lladdr" } } } } } end end @@ -88,7 +88,7 @@ describe Ohai::System, "plugin eucalyptus" do describe "with eucalyptus hint file" do it_behaves_like "eucalyptus" - before(:each) do + before do allow(plugin).to receive(:hint?).with("eucalyptus").and_return(true) end end @@ -96,7 +96,7 @@ describe Ohai::System, "plugin eucalyptus" do describe "without hint file" do it_behaves_like "!eucalyptus" - before(:each) do + before do plugin[:network] = { :interfaces => {} } allow(plugin).to receive(:hint?).with("eucalyptus").and_return(false) end diff --git a/spec/unit/plugins/fail_spec.rb b/spec/unit/plugins/fail_spec.rb index 763dc266..4b08dea6 100644 --- a/spec/unit/plugins/fail_spec.rb +++ b/spec/unit/plugins/fail_spec.rb @@ -30,13 +30,13 @@ shared_examples "a v7 loading failure" do end end - before(:each) do + before do fail_file = File.open("#{tmp}/plugins/fail.rb", "w+") fail_file.write(failstr) fail_file.close end - after(:each) do + after do File.delete("#{tmp}/plugins/fail.rb") end @@ -48,23 +48,23 @@ shared_examples "a v7 loading failure" do end end - before(:each) do + before do @ohai = Ohai::System.new @loader = Ohai::Loader.new(@ohai) end - it "should not have attribute keys" do + it "does not have attribute keys" do @loader.load_plugin("#{tmp}/plugins/fail.rb") #@ohai.attributes.should_not have_key("fail") expect { @ohai.provides_map.find_providers_for(["fail"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound) end - it "should not have source key" do + it "does not have source key" do @loader.load_plugin("#{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 + it "writes to Ohai::Log" do expect(Ohai::Log).to receive(:warn).once @loader.load_plugin("#{tmp}/plugins/fail.rb") end @@ -79,13 +79,13 @@ shared_examples "a v7 loading success" do end end - before(:each) do + before do fail_file = File.open("#{tmp}/plugins/fail.rb", "w+") fail_file.write(failstr) fail_file.close end - after(:each) do + after do File.delete("#{tmp}/plugins/fail.rb") end @@ -97,22 +97,22 @@ shared_examples "a v7 loading success" do end end - before(:each) do + before do @ohai = Ohai::System.new @loader = Ohai::Loader.new(@ohai) end - it "should have attribute keys" do + it "has attribute keys" do @loader.load_plugin("#{tmp}/plugins/fail.rb") expect(@ohai.provides_map).to have_key("fail") end - it "should have source key" do + it "has source key" do @loader.load_plugin("#{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 + it "does not write to Ohai::Log" do expect(Ohai::Log).not_to receive(:warn) @loader.load_plugin("#{tmp}/plugins/fail.rb") end @@ -127,13 +127,13 @@ shared_examples "a v7 run failure" do end end - before(:each) do + before do fail_file = File.open("#{tmp}/plugins/fail.rb", "w+") fail_file.write(failstr) fail_file.close end - after(:each) do + after do File.delete("#{tmp}/plugins/fail.rb") end @@ -145,17 +145,17 @@ shared_examples "a v7 run failure" do end end - before(:each) do + before do @ohai = Ohai::System.new @loader = Ohai::Loader.new(@ohai) end - it "should not have new attribute keys" do + it "does not have new attribute keys" do @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run expect(@ohai.provides_map).not_to have_key("other") end - it "should write to Ohai::Log" do + it "writes to Ohai::Log" do expect(Ohai::Log).to receive(:warn).once @loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run end diff --git a/spec/unit/plugins/freebsd/cpu_spec.rb b/spec/unit/plugins/freebsd/cpu_spec.rb index 1dbbf3a6..1026e9a7 100644 --- a/spec/unit/plugins/freebsd/cpu_spec.rb +++ b/spec/unit/plugins/freebsd/cpu_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do - before(:each) do + before do @plugin = get_plugin("freebsd/cpu") allow(@plugin).to receive(:collect_os).and_return(:freebsd) @double_file = double("/var/run/dmesg.boot") @@ -94,7 +94,7 @@ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do end describe Ohai::System, "FreeBSD cpu plugin on FreeBSD <=10.1" do - before(:each) do + before do @plugin = get_plugin("freebsd/cpu") 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", "")) diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb index a1279b20..ed5d7b32 100644 --- a/spec/unit/plugins/freebsd/hostname_spec.rb +++ b/spec/unit/plugins/freebsd/hostname_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") 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", "")) diff --git a/spec/unit/plugins/freebsd/kernel_spec.rb b/spec/unit/plugins/freebsd/kernel_spec.rb index d9baf8fc..2f5bb412 100644 --- a/spec/unit/plugins/freebsd/kernel_spec.rb +++ b/spec/unit/plugins/freebsd/kernel_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD kernel plugin" do - before(:each) do + before do @plugin = get_plugin("kernel") allow(@plugin).to receive(:collect_os).and_return(:freebsd) allow(@plugin).to receive(:init_kernel).and_return({ :name => "freebsd" }) @@ -28,7 +28,7 @@ describe Ohai::System, "FreeBSD kernel plugin" do 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 + it "sets the kernel_os to the kernel_name value" do @plugin.run expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name]) end diff --git a/spec/unit/plugins/freebsd/os_spec.rb b/spec/unit/plugins/freebsd/os_spec.rb index dfb89996..a739f559 100644 --- a/spec/unit/plugins/freebsd/os_spec.rb +++ b/spec/unit/plugins/freebsd/os_spec.rb @@ -19,13 +19,13 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD plugin os" do - before(:each) do + before do @plugin = get_plugin("freebsd/os") 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 + it "sets os_version to __FreeBSD_version" do @plugin.run expect(@plugin[:os_version]).to eq("902001") end diff --git a/spec/unit/plugins/freebsd/platform_spec.rb b/spec/unit/plugins/freebsd/platform_spec.rb index 2ddcc4cd..6356cc15 100644 --- a/spec/unit/plugins/freebsd/platform_spec.rb +++ b/spec/unit/plugins/freebsd/platform_spec.rb @@ -19,19 +19,19 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD plugin platform" do - before(:each) do + before do @plugin = get_plugin("freebsd/platform") 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 + it "sets platform to lowercased lsb[:id]" do @plugin.run expect(@plugin[:platform]).to eq("freebsd") end - it "should set platform_version to lsb[:release]" do + it "sets platform_version to lsb[:release]" do @plugin.run expect(@plugin[:platform_version]).to eq("7.1") end diff --git a/spec/unit/plugins/gce_spec.rb b/spec/unit/plugins/gce_spec.rb index a30b232d..d554f707 100644 --- a/spec/unit/plugins/gce_spec.rb +++ b/spec/unit/plugins/gce_spec.rb @@ -34,7 +34,7 @@ describe Ohai::System, "plugin gce" do end shared_examples_for "gce" do - before(:each) do + before do @http_get = double("Net::HTTP client") allow(plugin).to receive(:http_get).and_return(double("Net::HTTP Response", :body => '{"instance":{"hostname":"test-host"}}', :code => "200")) allow(IO).to receive(:select).and_return([[], [1], []]) @@ -56,7 +56,7 @@ describe Ohai::System, "plugin gce" do describe "with hint file and with metadata connection" do it_behaves_like "gce" - before(:each) do + before do allow(plugin).to receive(:hint?).with("gce").and_return({}) end end @@ -64,7 +64,7 @@ describe Ohai::System, "plugin gce" do describe "without hint file and without metadata connection" do it_behaves_like "!gce" - before(:each) do + before do allow(plugin).to receive(:hint?).with("gce").and_return(false) # Raise Errno::ENOENT to simulate the scenario in which metadata server diff --git a/spec/unit/plugins/go_spec.rb b/spec/unit/plugins/go_spec.rb index 7bd3cd79..91656c0e 100644 --- a/spec/unit/plugins/go_spec.rb +++ b/spec/unit/plugins/go_spec.rb @@ -18,7 +18,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_he describe Ohai::System, "plugin go" do let(:plugin) { get_plugin("go") } - before(:each) do + before do plugin[:languages] = Mash.new stdout = "go version go1.6.1 darwin/amd64\n" allow(plugin).to receive(:shell_out).with("go version").and_return(mock_shell_out(0, stdout, "")) diff --git a/spec/unit/plugins/groovy_spec.rb b/spec/unit/plugins/groovy_spec.rb index 4b614ab3..faa2f905 100644 --- a/spec/unit/plugins/groovy_spec.rb +++ b/spec/unit/plugins/groovy_spec.rb @@ -21,7 +21,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_he describe Ohai::System, "plugin groovy" do let(:plugin) { get_plugin("groovy") } - before(:each) do + before do plugin[:languages] = Mash.new end diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb index e0f7672d..dcaa1130 100644 --- a/spec/unit/plugins/hostname_spec.rb +++ b/spec/unit/plugins/hostname_spec.rb @@ -19,72 +19,72 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") 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 + before do 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 + it "uses #resolve_fqdn to find the fqdn" do @plugin.run expect(@plugin[:fqdn]).to eq("katie.bethell") end - it "should set the domain to everything after the first dot of the fqdn" do + it "sets the domain to everything after the first dot of the fqdn" do @plugin.run expect(@plugin[:domain]).to eq("bethell") end - it "should set the [short] hostname to everything before the first dot of the fqdn" do + it "sets the [short] hostname to everything before the first dot of the fqdn" do @plugin.run expect(@plugin[:hostname]).to eq("katie") end end context "when sigar is installed" do - before(:each) do + before do 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 + it "sets the fqdn to the returned value from sigar" do @plugin.run expect(@plugin[:fqdn]).to eq("katie.bethell") end - it "should set the domain to everything after the first dot of the fqdn" do + it "sets the domain to everything after the first dot of the fqdn" do @plugin.run expect(@plugin[:domain]).to eq("bethell") end - it "should set the [short] hostname to everything before the first dot of the fqdn" do + it "sets the [short] hostname to everything before the first dot of the fqdn" do @plugin.run expect(@plugin[:hostname]).to eq("katie") end end context "when a system has a bare hostname without a FQDN" do - before(:each) do + before do 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 + it "correctlies set the [short] hostname" do @plugin.run expect(@plugin[:hostname]).to eq("katie") end end context "hostname --fqdn when it returns empty string" do - before(:each) do + before do 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", "")) @@ -92,14 +92,14 @@ describe Ohai::System, "hostname plugin" do mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", "")) end - it "should be called twice" do + it "is called twice" do @plugin.run expect(@plugin[:fqdn]).to eq("katie.local") end end context "hostname --fqdn when it works" do - before(:each) do + before do 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", "")) @@ -107,7 +107,7 @@ describe Ohai::System, "hostname plugin" do mock_shell_out(0, "katie.local", "")) end - it "should be not be called twice" do + it "is not be called twice" do @plugin.run expect(@plugin[:fqdn]).to eq("katie.local") end diff --git a/spec/unit/plugins/init_package_spec.rb b/spec/unit/plugins/init_package_spec.rb index c34fb654..43e72936 100644 --- a/spec/unit/plugins/init_package_spec.rb +++ b/spec/unit/plugins/init_package_spec.rb @@ -30,12 +30,12 @@ describe Ohai::System, "Init package" do let(:proc_1_file_path) { "/proc/1/comm" } let(:proc_1_file) { double(proc_1_file_path, :gets => proc1_content) } - before(:each) do + before do allow(File).to receive(:exists?).with(proc_1_file_path).and_return(proc1_exists) allow(File).to receive(:open).with(proc_1_file_path).and_return(proc_1_file) end - it "should set init_package to init" do + it "sets init_package to init" do plugin.run expect(plugin[:init_package]).to eq("init") end @@ -43,7 +43,7 @@ describe Ohai::System, "Init package" do describe "when init_package is systemd" do let(:proc1_content) { "systemd\n" } - it "should set init_package to systemd" do + it "sets init_package to systemd" do plugin.run expect(plugin[:init_package]).to eq("systemd") end @@ -52,7 +52,7 @@ describe Ohai::System, "Init package" do describe "when /proc/1/comm doesn't exist" do let(:proc1_exists) { false } - it "should set init_package to init" do + it "sets init_package to init" do plugin.run expect(plugin[:init_package]).to eq("init") end diff --git a/spec/unit/plugins/java_spec.rb b/spec/unit/plugins/java_spec.rb index a8279caf..214898fd 100644 --- a/spec/unit/plugins/java_spec.rb +++ b/spec/unit/plugins/java_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin java (Java5 Client VM)" do let(:plugin) { get_plugin("java") } - before(:each) do + before do plugin[:languages] = Mash.new end @@ -78,7 +78,7 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do shared_examples_for "when the Server JRE is installed" do - before(:each) do + before 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)" allow(plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", stderr)) end @@ -123,7 +123,7 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do shared_examples_for "when the openjdk 1.8 is installed" do - before(:each) do + before do stderr = "openjdk version \"1.8.0_71\"\nOpenJDK Runtime Environment (build 1.8.0_71-b15)\nOpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)" allow(plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", stderr)) end diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb index c46952e5..252e9f77 100644 --- a/spec/unit/plugins/kernel_spec.rb +++ b/spec/unit/plugins/kernel_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin kernel" do - before(:each) do + before do @plugin = get_plugin("kernel") 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", "")) @@ -78,7 +78,7 @@ describe Ohai::System, "plugin kernel" do @plugin.run end - it "should set the correct system information" do + it "sets the correct system information" do 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") diff --git a/spec/unit/plugins/linux/block_device_spec.rb b/spec/unit/plugins/linux/block_device_spec.rb index edb4b243..2060793e 100644 --- a/spec/unit/plugins/linux/block_device_spec.rb +++ b/spec/unit/plugins/linux/block_device_spec.rb @@ -41,7 +41,7 @@ describe Ohai::System, "Linux Block Device Plugin" do tmp_double end - before(:each) do + before do @plugin = get_plugin("linux/block_device") allow(@plugin).to receive(:collect_os).and_return(:linux) @@ -66,7 +66,7 @@ describe Ohai::System, "Linux Block Device Plugin" do end end - it "should collect all relevant data from disks" do + it "collects all relevant data from disks" do @plugin.run DISKS.each do |disk, checks| expect(@plugin[:block_device][disk.to_sym]).to include(checks) diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb index f6252453..e8f563a0 100644 --- a/spec/unit/plugins/linux/cpu_spec.rb +++ b/spec/unit/plugins/linux/cpu_spec.rb @@ -95,12 +95,12 @@ clflush size : 32 tempfile end - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(File).to receive(:open).with("/proc/cpuinfo").and_return(tempfile_handle) end - after(:each) do + after do begin tempfile.close tempfile.unlink @@ -113,7 +113,7 @@ clflush size : 32 it "gets total cores" do plugin.run - expect(plugin[:cpu][:cores]).to eql(0) + expect(plugin[:cpu][:cores]).to be(0) end it "doesn't have a cpu 1" do @@ -314,7 +314,7 @@ end describe Ohai::System, "S390 linux cpu plugin" do let(:plugin) { get_plugin("linux/cpu") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) @double_file = double("/proc/cpuinfo") diff --git a/spec/unit/plugins/linux/filesystem2_spec.rb b/spec/unit/plugins/linux/filesystem2_spec.rb index e62e9d1a..7006b884 100644 --- a/spec/unit/plugins/linux/filesystem2_spec.rb +++ b/spec/unit/plugins/linux/filesystem2_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux filesystem plugin" do let (:plugin) { get_plugin("linux/filesystem2") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", "")) @@ -53,7 +53,7 @@ describe Ohai::System, "Linux filesystem plugin" do end describe "when gathering filesystem usage data from df" do - before(:each) do + before do @stdout = <<-DF Filesystem 1024-blocks Used Available Capacity Mounted on /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% / @@ -80,55 +80,55 @@ DFi allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) end - it "should run df -P and df -iP" do + it "runs df -P and df -iP" do 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 -iP").and_return(mock_shell_out(0, @inode_stdout, "")) plugin.run end - it "should set kb_size to value from df -P" do + it "sets kb_size to value from df -P" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057") end - it "should set kb_used to value from df -P" do + it "sets kb_used to value from df -P" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253") end - it "should set kb_available to value from df -P" do + it "sets kb_available to value from df -P" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805") end - it "should set percent_used to value from df -P" do + it "sets percent_used to value from df -P" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%") end - it "should set mount to value from df -P" do + it "sets mount to value from df -P" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") end - it "should set total_inodes to value from df -iP" do + it "sets total_inodes to value from df -iP" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865") end - it "should set inodes_used to value from df -iP" do + it "sets inodes_used to value from df -iP" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380") end - it "should set inodes_available to value from df -iP" do + it "sets inodes_available to value from df -iP" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485") end end describe "when gathering mounted filesystem data from mount" do - before(:each) do + before do @stdout = <<-MOUNT /dev/mapper/sys.vg-root.lv on / type ext4 (rw,noatime,errors=remount-ro) tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755) @@ -149,29 +149,29 @@ MOUNT allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) end - it "should run mount" do + it "runs mount" do 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 + it "sets mount to value from mount" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") end - it "should set fs_type to value from mount" do + it "sets fs_type to value from mount" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs") end - it "should set mount_options to an array of values from mount" do + it "sets mount_options to an array of values from mount" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime}) end end describe "when gathering filesystem type data from blkid" do - before(:each) do + before do # blkid and lsblk output are coorelated with df/mount output, so the # most full test of them actually requires we have both @dfstdout = <<-DF @@ -216,11 +216,11 @@ BLKID_TYPE allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, @stdout, "")) end - it "should run blkid" do + it "runs blkid" do plugin.run end - it "should set kb_size to value from blkid" do + it "sets kb_size to value from blkid" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member") expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa") @@ -229,7 +229,7 @@ BLKID_TYPE end describe "when gathering filesystem type data from lsblk" do - before(:each) do + before do @dfstdout = <<-DF Filesystem 1024-blocks Used Available Capacity Mounted on /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% / @@ -276,18 +276,18 @@ BLKID_TYPE and_return(mock_shell_out(0, @stdout, "")) end - it "should run lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do + it "runs lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do plugin.run end - it "should set kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do + it "sets kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member") expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa") expect(plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot") end - it "should ignore extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do + it "ignores extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/debian--7-root,"][:label]).to eq("root") end @@ -295,7 +295,7 @@ BLKID_TYPE end describe "when gathering data from /proc/mounts" do - before(:each) do + before do allow(File).to receive(:exist?).with("/proc/mounts").and_return(true) @double_file = double("/proc/mounts") @mounts = <<-MOUNTS @@ -326,24 +326,24 @@ MOUNTS allow(File).to receive(:open).with("/proc/mounts").and_return(@double_file) end - it "should set mount to value from /proc/mounts" do + it "sets mount to value from /proc/mounts" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special") end - it "should set fs_type to value from /proc/mounts" do + it "sets fs_type to value from /proc/mounts" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs") end - it "should set mount_options to an array of values from /proc/mounts" do + it "sets mount_options to an array of values from /proc/mounts" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota}) end end describe "when gathering filesystem data with devices mounted more than once" do - before(:each) do + before do # there's a few different examples one can run into in this output: # 1. A device physically mounted in more than one place: /home and /home2 # 2. A bind-mounted directory, which shows up as the same device in a @@ -383,7 +383,7 @@ BLKID_TYPE and_return(mock_shell_out(0, @stdout, "")) end - it "should provide a devices view with all mountpoints" do + it "provides a devices view with all mountpoints" do plugin.run expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"]) expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"]) @@ -392,7 +392,7 @@ BLKID_TYPE end describe "when gathering filesystem data with double-mounts" do - before(:each) do + before do @dfstdout = <<-DF Filesystem 1024-blocks Used Available Capacity Mounted on /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% / @@ -429,7 +429,7 @@ BLKID_TYPE and_return(mock_shell_out(0, @stdout, "")) end - it "should provide a mounts view with all devices" do + it "provides a mounts view with all devices" do plugin.run expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"]) end diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb index 7375a8cf..01cd1ff4 100644 --- a/spec/unit/plugins/linux/filesystem_spec.rb +++ b/spec/unit/plugins/linux/filesystem_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux filesystem plugin" do let(:plugin) { get_plugin("linux/filesystem") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", "")) @@ -58,7 +58,7 @@ describe Ohai::System, "Linux filesystem plugin" do end describe "when gathering filesystem usage data from df" do - before(:each) do + before do @stdout = <<-DF Filesystem 1024-blocks Used Available Capacity Mounted on /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% / @@ -85,55 +85,55 @@ DFi allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, "")) end - it "should run df -P and df -iP" do + it "runs df -P and df -iP" do 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 -iP").and_return(mock_shell_out(0, @inode_stdout, "")) plugin.run end - it "should set kb_size to value from df -P" do + it "sets kb_size to value from df -P" do plugin.run 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 + it "sets kb_used to value from df -P" do plugin.run 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 + it "sets kb_available to value from df -P" do plugin.run 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 + it "sets percent_used to value from df -P" do plugin.run 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 + it "sets mount to value from df -P" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") end - it "should set total_inodes to value from df -iP" do + it "sets total_inodes to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865") end - it "should set inodes_used to value from df -iP" do + it "sets inodes_used to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380") end - it "should set inodes_available to value from df -iP" do + it "sets inodes_available to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485") end end describe "when gathering mounted filesystem data from mount" do - before(:each) do + before do @stdout = <<-MOUNT /dev/mapper/sys.vg-root.lv on / type ext4 (rw,noatime,errors=remount-ro) tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755) @@ -154,29 +154,29 @@ MOUNT allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, "")) end - it "should run mount" do + it "runs mount" do 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 + it "sets mount to value from mount" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") end - it "should set fs_type to value from mount" do + it "sets fs_type to value from mount" do plugin.run 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 + it "sets mount_options to an array of values from mount" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq(%w{ro noatime}) end end describe "when gathering filesystem type data from blkid" do - before(:each) do + before do @stdout = <<-BLKID_TYPE /dev/sdb1: TYPE=\"linux_raid_member\" /dev/sdb2: TYPE=\"linux_raid_member\" @@ -195,19 +195,19 @@ BLKID_TYPE 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 + it "runs blkid -s TYPE" do expect(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set fs_type to value from blkid -s TYPE" do + it "sets fs_type to value from blkid -s TYPE" do plugin.run 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 + before do allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @stdout = <<-BLKID_TYPE NAME="sdb1" FSTYPE="linux_raid_member" @@ -228,25 +228,25 @@ BLKID_TYPE and_return(mock_shell_out(0, @stdout, "")) end - it "should run lsblk -P -n -o NAME,FSTYPE" do + it "runs lsblk -P -n -o NAME,FSTYPE" do expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE"). and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set fs_type to value from lsblk -P -n -o NAME,FSTYPE" do + it "sets fs_type to value from lsblk -P -n -o NAME,FSTYPE" do plugin.run expect(plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member") end - it "should ignore extra info in name and set fs_type to value from lsblk -P -n -o NAME,FSTYPE" do + it "ignores extra info in name and set fs_type to value from lsblk -P -n -o NAME,FSTYPE" do plugin.run expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:fs_type]).to eq("ext4") end end describe "when gathering filesystem uuid data from blkid" do - before(:each) do + before do @stdout = <<-BLKID_UUID /dev/sdb1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" /dev/sdb2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" @@ -265,19 +265,19 @@ BLKID_UUID 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 + it "runs blkid -s UUID" do expect(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set uuid to value from blkid -s UUID" do + it "sets uuid to value from blkid -s UUID" do plugin.run 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 + before do allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @stdout = <<-BLKID_UUID NAME="sdb1" UUID="bd1197e0-6997-1f3a-e27e-7801388308b5" @@ -298,20 +298,20 @@ BLKID_UUID and_return(mock_shell_out(0, @stdout, "")) end - it "should run lsblk -P -n -o NAME,UUID" do + it "runs lsblk -P -n -o NAME,UUID" do expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID"). and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set uuid to value from lsblk -P -n -o NAME,UUID" do + it "sets uuid to value from lsblk -P -n -o NAME,UUID" do plugin.run expect(plugin[:filesystem]["/dev/sda2"][:uuid]).to eq( "e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa" ) end - it "should ignore extra info in name and set uuid to value from lsblk -P -n -o NAME,UUID" do + it "ignores extra info in name and set uuid to value from lsblk -P -n -o NAME,UUID" do plugin.run expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:uuid]).to eq( "09187faa-3512-4505-81af-7e86d2ccb99a" @@ -320,7 +320,7 @@ BLKID_UUID end describe "when gathering filesystem label data from blkid" do - before(:each) do + before do @stdout = <<-BLKID_LABEL /dev/sda1: LABEL=\"fuego:0\" /dev/sda2: LABEL=\"fuego:1\" @@ -337,19 +337,19 @@ BLKID_LABEL 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 + it "runs blkid -s LABEL" do expect(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set label to value from blkid -s LABEL" do + it "sets label to value from blkid -s LABEL" do plugin.run expect(plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot") end end describe "when gathering filesystem label data from lsblk" do - before(:each) do + before do allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @stdout = <<-BLKID_LABEL NAME="sda1" LABEL="fuego:0" @@ -368,25 +368,25 @@ BLKID_LABEL and_return(mock_shell_out(0, @stdout, "")) end - it "should run lsblk -P -n -o NAME,LABEL" do + it "runs lsblk -P -n -o NAME,LABEL" do expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL"). and_return(mock_shell_out(0, @stdout, "")) plugin.run end - it "should set label to value from lsblk -P -n -o NAME,LABEL" do + it "sets label to value from lsblk -P -n -o NAME,LABEL" do plugin.run expect(plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot") end - it "should ignore extra info in name and set label to value from lsblk -P -n -o NAME,LABEL" do + it "ignores extra info in name and set label to value from lsblk -P -n -o NAME,LABEL" do plugin.run expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:label]).to eq("root") end end describe "when gathering data from /proc/mounts" do - before(:each) do + before do allow(File).to receive(:exist?).with("/proc/mounts").and_return(true) @double_file = double("/proc/mounts") @mounts = <<-MOUNTS @@ -417,17 +417,17 @@ MOUNTS allow(File).to receive(:open).with("/proc/mounts").and_return(@double_file) end - it "should set mount to value from /proc/mounts" do + it "sets mount to value from /proc/mounts" do plugin.run 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 + it "sets fs_type to value from /proc/mounts" do plugin.run 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 + it "sets mount_options to an array of values from /proc/mounts" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq(%w{ro noatime attr2 noquota}) end diff --git a/spec/unit/plugins/linux/fips_spec.rb b/spec/unit/plugins/linux/fips_spec.rb index 30d70c17..a3a6f1b1 100644 --- a/spec/unit/plugins/linux/fips_spec.rb +++ b/spec/unit/plugins/linux/fips_spec.rb @@ -23,7 +23,7 @@ describe Ohai::System, "plugin fips" do let(:plugin) { get_plugin("linux/fips") } let(:fips_path) { "/proc/sys/crypto/fips_enabled" } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(::File).to receive(:read).with(fips_path).and_return(enabled) end diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb index a7dba293..076c2303 100644 --- a/spec/unit/plugins/linux/hostname_spec.rb +++ b/spec/unit/plugins/linux/hostname_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") 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", "")) @@ -34,15 +34,15 @@ describe Ohai::System, "Linux hostname plugin" do it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local") describe "when domain name is unset" do - before(:each) do + before do expect(@plugin).to receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec") end - it "should not raise an error" do + it "does not raise an error" do expect { @plugin.run }.not_to raise_error end - it "should not set fqdn" do + it "does not set fqdn" do @plugin.run expect(@plugin.fqdn).to eq(nil) end diff --git a/spec/unit/plugins/linux/hostnamectl_spec.rb b/spec/unit/plugins/linux/hostnamectl_spec.rb index bfa72790..1201b4f2 100644 --- a/spec/unit/plugins/linux/hostnamectl_spec.rb +++ b/spec/unit/plugins/linux/hostnamectl_spec.rb @@ -21,11 +21,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux hostnamectl plugin" do let(:plugin) { get_plugin("linux/hostnamectl") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) end - it "should populate hostnamectl if hostnamectl is available" do + it "populates hostnamectl if hostnamectl is available" do hostnamectl_out = <<-HOSTNAMECTL_OUT Static hostname: foo Icon name: computer-laptop @@ -52,7 +52,7 @@ HOSTNAMECTL_OUT }) end - it "should not populate hostnamectl if hostnamectl is not available" do + it "does not populate hostnamectl if hostnamectl is not available" do allow(plugin).to receive(:which).with("hostnamectl").and_return(false) expect(plugin[:hostnamectl]).to eq(nil) end diff --git a/spec/unit/plugins/linux/kernel_spec.rb b/spec/unit/plugins/linux/kernel_spec.rb index 18646156..c7b86337 100644 --- a/spec/unit/plugins/linux/kernel_spec.rb +++ b/spec/unit/plugins/linux/kernel_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux kernel plugin" do - before(:each) do + before do @env_lsmod = <<-ENV_LSMOD Module Size Used by dm_crypt 22321 0 diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb index 309133d3..3006a8f5 100644 --- a/spec/unit/plugins/linux/lsb_spec.rb +++ b/spec/unit/plugins/linux/lsb_spec.rb @@ -21,13 +21,13 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") # We do not alter case for lsb attributes and consume them as provided describe Ohai::System, "Linux lsb plugin" do - before(:each) do + before do @plugin = get_plugin("linux/lsb") allow(@plugin).to receive(:collect_os).and_return(:linux) end describe "on systems with /etc/lsb-release" do - before(:each) do + before do @double_file = double("/etc/lsb-release") allow(@double_file).to receive(:each). and_yield("DISTRIB_ID=Ubuntu"). @@ -39,29 +39,29 @@ describe Ohai::System, "Linux lsb plugin" do allow(File).to receive(:exists?).with("/etc/lsb-release").and_return(true) end - it "should set lsb[:id]" do + it "sets lsb[:id]" do @plugin.run expect(@plugin[:lsb][:id]).to eq("Ubuntu") end - it "should set lsb[:release]" do + it "sets lsb[:release]" do @plugin.run expect(@plugin[:lsb][:release]).to eq("8.04") end - it "should set lsb[:codename]" do + it "sets lsb[:codename]" do @plugin.run expect(@plugin[:lsb][:codename]).to eq("hardy") end - it "should set lsb[:description]" do + it "sets lsb[:description]" do @plugin.run expect(@plugin[:lsb][:description]).to eq("Ubuntu 8.04") end end describe "on systems with /usr/bin/lsb_release" do - before(:each) do + before do allow(File).to receive(:exists?).with("/usr/bin/lsb_release").and_return(true) @stdin = double("STDIN", { :close => true }) @@ -73,7 +73,7 @@ describe Ohai::System, "Linux lsb plugin" do end describe "on Centos 5.4 correctly" do - before(:each) do + before do @stdout = <<-LSB_RELEASE LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch Distributor ID: CentOS @@ -84,29 +84,29 @@ LSB_RELEASE allow(@plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, "")) end - it "should set lsb[:id]" do + it "sets lsb[:id]" do @plugin.run expect(@plugin[:lsb][:id]).to eq("CentOS") end - it "should set lsb[:release]" do + it "sets lsb[:release]" do @plugin.run expect(@plugin[:lsb][:release]).to eq("5.4") end - it "should set lsb[:codename]" do + it "sets lsb[:codename]" do @plugin.run expect(@plugin[:lsb][:codename]).to eq("Final") end - it "should set lsb[:description]" do + it "sets lsb[:description]" do @plugin.run expect(@plugin[:lsb][:description]).to eq("CentOS release 5.4 (Final)") end end describe "on Fedora 14 correctly" do - before(:each) do + before do @stdout = <<-LSB_RELEASE LSB Version: :core-4.0-ia32:core-4.0-noarch Distributor ID: Fedora @@ -117,29 +117,29 @@ LSB_RELEASE allow(@plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, "")) end - it "should set lsb[:id]" do + it "sets lsb[:id]" do @plugin.run expect(@plugin[:lsb][:id]).to eq("Fedora") end - it "should set lsb[:release]" do + it "sets lsb[:release]" do @plugin.run expect(@plugin[:lsb][:release]).to eq("14") end - it "should set lsb[:codename]" do + it "sets lsb[:codename]" do @plugin.run expect(@plugin[:lsb][:codename]).to eq("Laughlin") end - it "should set lsb[:description]" do + it "sets lsb[:description]" do @plugin.run 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 + it "does not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist" do 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) diff --git a/spec/unit/plugins/linux/machineid_spec.rb b/spec/unit/plugins/linux/machineid_spec.rb index 12267079..8b531acb 100644 --- a/spec/unit/plugins/linux/machineid_spec.rb +++ b/spec/unit/plugins/linux/machineid_spec.rb @@ -21,11 +21,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Machine id plugin" do let(:plugin) { get_plugin("linux/machineid") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) end - it "should read /etc/machine-id if available" do + it "reads /etc/machine-id if available" do machine_id = "6f702523e2fc7499eb1dc68e5314dacf" allow(File).to receive(:exists?).with("/etc/machine-id").and_return(true) @@ -34,7 +34,7 @@ describe Ohai::System, "Machine id plugin" do expect(plugin[:machine_id]).to eq(machine_id) end - it "should read /var/lib/dbus/machine-id if available" do + it "reads /var/lib/dbus/machine-id if available" do machine_id = "6f702523e2fc7499eb1dc68e5314dacf" allow(File).to receive(:exists?).with("/etc/machine-id").and_return(false) diff --git a/spec/unit/plugins/linux/mdadm_spec.rb b/spec/unit/plugins/linux/mdadm_spec.rb index 2e8b533d..0cba2048 100644 --- a/spec/unit/plugins/linux/mdadm_spec.rb +++ b/spec/unit/plugins/linux/mdadm_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux Mdadm Plugin" do - before(:each) do + before do @md0 = <<-MD /dev/md0: Version : 1.2 @@ -67,26 +67,26 @@ MD describe "gathering Mdadm information via /proc/mdstat and mdadm" do - it "should not raise an error" do + it "does not raise an error" do expect { @plugin.run }.not_to raise_error end - it "should detect raid level" do + it "detects raid level" do @plugin.run expect(@plugin[:mdadm][:md0][:level]).to eq(10) end - it "should detect raid state" do + it "detects raid state" do @plugin.run expect(@plugin[:mdadm][:md0][:state]).to eq("clean") end - it "should detect raid size" do + it "detects raid size" do @plugin.run expect(@plugin[:mdadm][:md0][:size]).to eq(2794.16) end - it "should detect raid metadata level" do + it "detects raid metadata level" do @plugin.run expect(@plugin[:mdadm][:md0][:version]).to eq(1.2) end diff --git a/spec/unit/plugins/linux/memory_spec.rb b/spec/unit/plugins/linux/memory_spec.rb index 3a30ead3..5085a1aa 100644 --- a/spec/unit/plugins/linux/memory_spec.rb +++ b/spec/unit/plugins/linux/memory_spec.rb @@ -17,7 +17,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux memory plugin" do - before(:each) do + before do @plugin = get_plugin("linux/memory") allow(@plugin).to receive(:collect_os).and_return(:linux) @double_file = double("/proc/meminfo") @@ -58,167 +58,167 @@ describe Ohai::System, "Linux memory plugin" do allow(File).to receive(:open).with("/proc/meminfo").and_return(@double_file) end - it "should get total memory" do + it "gets total memory" do @plugin.run expect(@plugin[:memory][:total]).to eql("131932120kB") end - it "should get free memory" do + it "gets free memory" do @plugin.run expect(@plugin[:memory][:free]).to eql("2269032kB") end - it "should get memory used for file buffers" do + it "gets memory used for file buffers" do @plugin.run expect(@plugin[:memory][:buffers]).to eql("646368kB") end - it "should get cache memory" do + it "gets cache memory" do @plugin.run expect(@plugin[:memory][:cached]).to eql("32346556kB") end - it "should get active memory" do + it "gets active memory" do @plugin.run expect(@plugin[:memory][:active]).to eql("98595796kB") end - it "should get inactive memory" do + it "gets inactive memory" do @plugin.run expect(@plugin[:memory][:inactive]).to eql("18477320kB") end - it "should get high_total memory" do + it "gets high_total memory" do @plugin.run expect(@plugin[:memory][:high_total]).to eql("0kB") end - it "should get high_free memory" do + it "gets high_free memory" do @plugin.run expect(@plugin[:memory][:high_free]).to eql("0kB") end - it "should get low_total memory" do + it "gets low_total memory" do @plugin.run expect(@plugin[:memory][:low_total]).to eql("131932120kB") end - it "should get low_free memory" do + it "gets low_free memory" do @plugin.run expect(@plugin[:memory][:low_free]).to eql("2269032kB") end - it "should get dirty memory" do + it "gets dirty memory" do @plugin.run expect(@plugin[:memory][:dirty]).to eql("3212kB") end - it "should get writeback memory" do + it "gets writeback memory" do @plugin.run expect(@plugin[:memory][:writeback]).to eql("0kB") end - it "should get anon_pages memory" do + it "gets anon_pages memory" do @plugin.run expect(@plugin[:memory][:anon_pages]).to eql("84082132kB") end - it "should get mapped memory" do + it "gets mapped memory" do @plugin.run expect(@plugin[:memory][:mapped]).to eql("3445224kB") end - it "should get slab memory" do + it "gets slab memory" do @plugin.run expect(@plugin[:memory][:slab]).to eql("9892096kB") end - it "should get slab_reclaimable memory" do + it "gets slab_reclaimable memory" do @plugin.run expect(@plugin[:memory][:slab_reclaimable]).to eql("362636kB") end - it "should get slab_reclaimable memory" do + it "gets slab_reclaimable memory" do @plugin.run expect(@plugin[:memory][:slab_unreclaim]).to eql("18860kB") end - it "should get page_tables memory" do + it "gets page_tables memory" do @plugin.run expect(@plugin[:memory][:page_tables]).to eql("1759332kB") end - it "should get nfs_unstable memory" do + it "gets nfs_unstable memory" do @plugin.run expect(@plugin[:memory][:nfs_unstable]).to eql("0kB") end - it "should get bounce memory" do + it "gets bounce memory" do @plugin.run expect(@plugin[:memory][:bounce]).to eql("0kB") end - it "should get commit_limit memory" do + it "gets commit_limit memory" do @plugin.run expect(@plugin[:memory][:commit_limit]).to eql("148709328kB") end - it "should get committed_as memory" do + it "gets committed_as memory" do @plugin.run expect(@plugin[:memory][:committed_as]).to eql("333717060kB") end - it "should get vmalloc_total memory" do + it "gets vmalloc_total memory" do @plugin.run expect(@plugin[:memory][:vmalloc_total]).to eql("34359738367kB") end - it "should get vmalloc_used memory" do + it "gets vmalloc_used memory" do @plugin.run expect(@plugin[:memory][:vmalloc_used]).to eql("276796kB") end - it "should get vmalloc_chunk memory" do + it "gets vmalloc_chunk memory" do @plugin.run expect(@plugin[:memory][:vmalloc_chunk]).to eql("34359461515kB") end - it "should get total swap" do + it "gets total swap" do @plugin.run expect(@plugin[:memory][:swap][:total]).to eql("16777208kB") end - it "should get cached swap" do + it "gets cached swap" do @plugin.run expect(@plugin[:memory][:swap][:cached]).to eql("312kB") end - it "should get free swap" do + it "gets free swap" do @plugin.run expect(@plugin[:memory][:swap][:free]).to eql("14127356kB") end - it "should get total hugepages" do + it "gets total hugepages" do @plugin.run expect(@plugin[:memory][:hugepages][:total]).to eql("11542") end - it "should get free hugepages" do + it "gets free hugepages" do @plugin.run expect(@plugin[:memory][:hugepages][:free]).to eql("11235") end - it "should get reserved hugepages" do + it "gets reserved hugepages" do @plugin.run expect(@plugin[:memory][:hugepages][:reserved]).to eql("11226") end - it "should get surplus hugepages" do + it "gets surplus hugepages" do @plugin.run expect(@plugin[:memory][:hugepages][:surplus]).to eql("0") end - it "should get hugepage size" do + it "gets hugepage size" do @plugin.run expect(@plugin[:memory][:hugepage_size]).to eql("2048kB") end diff --git a/spec/unit/plugins/linux/network_spec.rb b/spec/unit/plugins/linux/network_spec.rb index 6e78997f..7053c8ab 100644 --- a/spec/unit/plugins/linux/network_spec.rb +++ b/spec/unit/plugins/linux/network_spec.rb @@ -366,7 +366,7 @@ TX: 8192 EOM end - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(plugin).to receive(:shell_out).with("ip addr").and_return(mock_shell_out(0, linux_ip_addr, "")) @@ -560,7 +560,7 @@ EOM %w{ifconfig iproute2}.each do |network_method| describe "gathering IP layer address info via #{network_method}" do - before(:each) do + before do allow(plugin).to receive(:iproute2_binary_available?).and_return( network_method == "iproute2" ) allow(plugin).to receive(:find_ethtool_binary).and_return( "/sbin/ethtool" ) plugin.run @@ -679,7 +679,7 @@ EOM end describe "gathering interface counters via #{network_method}" do - before(:each) do + before do allow(plugin).to receive(:iproute2_binary_available?).and_return( network_method == "iproute2" ) plugin.run end @@ -717,7 +717,7 @@ EOM end describe "setting the node's default IP address attribute with #{network_method}" do - before(:each) do + before do allow(plugin).to receive(:iproute2_binary_available?).and_return( network_method == "iproute2" ) plugin.run end @@ -749,7 +749,7 @@ Destination Gateway Genmask Flags Metric Ref Use Iface EOM end - before(:each) do + before do plugin.run end @@ -779,7 +779,7 @@ Destination Gateway Genmask Flags Metric Ref Use Iface EOM end - before(:each) do + before do plugin.run end @@ -795,7 +795,7 @@ EOM end describe "for newer network features using iproute2 only" do - before(:each) do + before do allow(File).to receive(:exist?).with("/sbin/ip").and_return(true) # iproute2 only allow(File).to receive(:exist?).with("/proc/net/if_inet6").and_return(true) # ipv6 is enabled allow(File).to receive(:exist?).with("/sbin/ethtool").and_return(true) # ethtool is available @@ -849,7 +849,7 @@ EOM end describe "when IPv6 is disabled" do - before :each do + before do allow(File).to receive(:exist?).with("/proc/net/if_inet6").and_return(false) plugin.run end @@ -880,7 +880,7 @@ fe80::/64 dev eth0.11 proto kernel metric 256 EOM end - before(:each) do + before do plugin.run end @@ -918,7 +918,7 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024 src 1111:2222:3333: EOM end - before(:each) do + before do plugin.run end @@ -959,7 +959,7 @@ default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023 EOM end - before(:each) do + before do plugin.run end @@ -1002,7 +1002,7 @@ default via 1111:2222:3333:4444::ffff dev eth0.11 metric 1023 src 1111:2222:333 EOM end - before(:each) do + before do plugin.run end @@ -1103,7 +1103,7 @@ default dev venet0 scope link EOM end - before(:each) do + before do plugin.run end @@ -1124,7 +1124,7 @@ default dev eth3 scope link EOM end - before(:each) do + before do plugin.run end @@ -1149,7 +1149,7 @@ default dev fwdintf scope link src 2.2.2.2 EOM end - before(:each) do + before do plugin.run end @@ -1174,7 +1174,7 @@ fe80::/64 dev eth0 proto kernel metric 256 default via fe80::21c:eff:fe12:3456 dev eth0.153 src fe80::2e0:81ff:fe2b:48e7 metric 1024 EOM end - before(:each) do + before do plugin.run end @@ -1208,7 +1208,7 @@ fe80::/64 dev eth0.11 proto kernel metric 256 EOM end - before(:each) do + before do plugin.run end @@ -1247,7 +1247,7 @@ EOM let(:linux_ip_route_inet6) { "" } let(:linux_ip_inet6_neighbor_show) { "" } - before(:each) do + before do allow(plugin).to receive(:is_openvz?).and_return true allow(plugin).to receive(:is_openvz_host?).and_return false plugin.run @@ -1292,7 +1292,7 @@ default via 1111:2222:3333:4444::1 dev eth0.11 metric 1024 EOM end - before(:each) do + before do plugin.run end diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index 5bff78e4..eecd4b17 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -38,7 +38,7 @@ describe Ohai::System, "Linux plugin platform" do let(:have_os_release) { false } let(:have_cisco_release) { false } - before(:each) do + before do @plugin = get_plugin("linux/platform") allow(@plugin).to receive(:collect_os).and_return(:linux) @plugin[:lsb] = Mash.new @@ -63,43 +63,43 @@ describe Ohai::System, "Linux plugin platform" do end describe "on lsb compliant distributions" do - before(:each) do + before do @plugin[:lsb][:id] = "Ubuntu" @plugin[:lsb][:release] = "8.04" end - it "should set platform to lowercased lsb[:id]" do + it "sets platform to lowercased lsb[:id]" do @plugin.run expect(@plugin[:platform]).to eq("ubuntu") end - it "should set platform_version to lsb[:release]" do + it "sets platform_version to lsb[:release]" do @plugin.run 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 + it "sets platform to ubuntu and platform_family to debian [:lsb][:id] contains Ubuntu" do @plugin[:lsb][:id] = "Ubuntu" @plugin.run 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 + it "sets platform to linuxmint and platform_family to debian [:lsb][:id] contains LinuxMint" do @plugin[:lsb][:id] = "LinuxMint" @plugin.run 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 + it "sets platform to debian and platform_family to debian [:lsb][:id] contains Debian" do @plugin[:lsb][:id] = "Debian" @plugin.run 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 + it "sets 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 @@ -107,7 +107,7 @@ describe Ohai::System, "Linux plugin platform" do 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 + it "sets 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 @@ -115,14 +115,14 @@ describe Ohai::System, "Linux plugin platform" do expect(@plugin[:platform_family]).to eq("rhel") end - it "should set platform to scientific when [:lsb][:id] contains ScientificSL" do + it "sets platform to scientific when [:lsb][:id] contains ScientificSL" do @plugin[:lsb][:id] = "ScientificSL" @plugin[:lsb][:release] = "5.7" @plugin.run 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 + it "sets 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 @@ -135,24 +135,24 @@ describe Ohai::System, "Linux plugin platform" do let(:have_debian_version) { true } - before(:each) do + before do @plugin.lsb = nil end - it "should read the version from /etc/debian_version" do + it "reads the version from /etc/debian_version" do expect(File).to receive(:read).with("/etc/debian_version").and_return("5.0") @plugin.run expect(@plugin[:platform_version]).to eq("5.0") end - it "should correctly strip any newlines" do + it "correctlies strip any newlines" do expect(File).to receive(:read).with("/etc/debian_version").and_return("5.0\n") @plugin.run expect(@plugin[:platform_version]).to eq("5.0") end # Ubuntu has /etc/debian_version as well - it "should detect Ubuntu as itself rather than debian" do + it "detects Ubuntu as itself rather than debian" do @plugin[:lsb][:id] = "Ubuntu" @plugin[:lsb][:release] = "8.04" @plugin.run @@ -164,7 +164,7 @@ describe Ohai::System, "Linux plugin platform" do let(:have_raspi_config) { true } # Raspbian is a debian clone - it "should detect Raspbian as itself with debian as the family" do + it "detects Raspbian as itself with debian as the family" do expect(File).to receive(:read).with("/etc/debian_version").and_return("wheezy/sid") @plugin.run expect(@plugin[:platform]).to eq("raspbian") @@ -177,11 +177,11 @@ describe Ohai::System, "Linux plugin platform" do let(:have_slackware_version) { true } - before(:each) do + before do @plugin.lsb = nil end - it "should set platform and platform_family to slackware" do + it "sets platform and platform_family to slackware" do expect(File).to receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0") @plugin.run expect(@plugin[:platform]).to eq("slackware") @@ -193,17 +193,17 @@ describe Ohai::System, "Linux plugin platform" do let(:have_arch_release) { true } - before(:each) do + before do @plugin.lsb = nil end - it "should set platform to arch and platform_family to arch" do + it "sets platform to arch and platform_family to arch" do @plugin.run expect(@plugin[:platform]).to eq("arch") expect(@plugin[:platform_family]).to eq("arch") end - it "should set platform_version to kernel release" do + it "sets platform_version to kernel release" do expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.2-2-ARCH") @plugin.run expect(@plugin[:platform_version]).to eq("3.18.2-2-ARCH") @@ -214,17 +214,17 @@ describe Ohai::System, "Linux plugin platform" do let(:have_gentoo_release) { true } - before(:each) do + before do @plugin.lsb = nil end - it "should set platform and platform_family to gentoo" do + it "sets platform and platform_family to gentoo" do @plugin.run expect(@plugin[:platform]).to eq("gentoo") expect(@plugin[:platform_family]).to eq("gentoo") end - it "should set platform_version to kernel release" do + it "sets platform_version to kernel release" do expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.7-gentoo") @plugin.run expect(@plugin[:platform_version]).to eq("3.18.7-gentoo") @@ -235,11 +235,11 @@ describe Ohai::System, "Linux plugin platform" do let(:have_alpine_release) { true } - before(:each) do + before do @plugin.lsb = nil end - it "should set platform and platform_family to alpine" do + it "sets platform and platform_family to alpine" do expect(File).to receive(:read).with("/etc/alpine-release").and_return("3.2.3") @plugin.run expect(@plugin[:platform]).to eq("alpine") @@ -252,11 +252,11 @@ describe Ohai::System, "Linux plugin platform" do let(:have_eos_release) { true } - before(:each) do + before do @plugin.lsb = nil end - it "should set platform to arista_eos" do + it "sets platform to arista_eos" do expect(File).to receive(:read).with("/etc/Eos-release").and_return("Arista Networks EOS 4.16.7M") @plugin.run expect(@plugin[:platform]).to eq("arista_eos") @@ -269,17 +269,17 @@ describe Ohai::System, "Linux plugin platform" do let(:have_exherbo_release) { true } - before(:each) do + before do @plugin.lsb = nil end - it "should set platform and platform_family to exherbo" do + it "sets platform and platform_family to exherbo" do @plugin.run expect(@plugin[:platform]).to eq("exherbo") expect(@plugin[:platform_family]).to eq("exherbo") end - it "should set platform_version to kernel release" do + it "sets platform_version to kernel release" do expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.2-2-ARCH") @plugin.run expect(@plugin[:platform_version]).to eq("3.18.2-2-ARCH") @@ -289,7 +289,7 @@ describe Ohai::System, "Linux plugin platform" do describe "on redhat breeds" do describe "with lsb_release results" do - it "should set the platform to redhat and platform_family to rhel even if the LSB name is something absurd but redhat like" do + it "sets the platform to redhat and platform_family to rhel even if the LSB name is something absurd but redhat like" do @plugin[:lsb][:id] = "RedHatEnterpriseServer" @plugin[:lsb][:release] = "6.1" @plugin.run @@ -298,7 +298,7 @@ describe Ohai::System, "Linux plugin platform" do expect(@plugin[:platform_family]).to eq("rhel") end - it "should set the platform to centos and platform_family to rhel" do + it "sets the platform to centos and platform_family to rhel" do @plugin[:lsb][:id] = "CentOS" @plugin[:lsb][:release] = "5.4" @plugin.run @@ -307,31 +307,31 @@ describe Ohai::System, "Linux plugin platform" do expect(@plugin[:platform_family]).to eq("rhel") end - it "should set the platform_family to rhel if the LSB name is oracle-ish" do + it "sets the platform_family to rhel if the LSB name is oracle-ish" do @plugin[:lsb][:id] = "EnterpriseEnterpriseServer" @plugin.run expect(@plugin[:platform_family]).to eq("rhel") end - it "should set the platform_family to rhel if the LSB name is amazon-ish" do + it "sets the platform_family to rhel if the LSB name is amazon-ish" do @plugin[:lsb][:id] = "Amazon" @plugin.run expect(@plugin[:platform_family]).to eq("rhel") end - it "should set the platform_family to fedora if the LSB name is fedora-ish" do + it "sets the platform_family to fedora if the LSB name is fedora-ish" do @plugin[:lsb][:id] = "Fedora" @plugin.run expect(@plugin[:platform_family]).to eq("fedora") end - it "should set the platform_family to redhat if the LSB name is scientific-ish" do + it "sets the platform_family to redhat if the LSB name is scientific-ish" do @plugin[:lsb][:id] = "Scientific" @plugin.run expect(@plugin[:platform_family]).to eq("rhel") end - it "should set the platform_family to redhat if the LSB name is ibm-ish" do + it "sets the platform_family to redhat if the LSB name is ibm-ish" do @plugin[:lsb][:id] = "IBM_PowerKVM" @plugin.run expect(@plugin[:platform_family]).to eq("rhel") @@ -342,11 +342,11 @@ describe Ohai::System, "Linux plugin platform" do let(:have_redhat_release) { true } - before(:each) do + before do @plugin.lsb = nil end - it "should read the platform as centos and version as 5.3" do + it "reads the platform as centos and version as 5.3" do expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS release 5.3") @plugin.run expect(@plugin[:platform]).to eq("centos") @@ -359,28 +359,28 @@ describe Ohai::System, "Linux plugin platform" do expect(@plugin[:platform_version]).to eq("5.3") end - it "should read the platform as redhat and version as 5.3" do + it "reads the platform as redhat and version as 5.3" do expect(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat release 5.3") @plugin.run 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 + it "reads the platform as fedora and version as 13 (rawhide)" do expect(File).to receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)") @plugin.run 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 + it "reads the platform as fedora and version as 10" do expect(File).to receive(:read).with("/etc/redhat-release").and_return("Fedora release 10") @plugin.run 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 + it "reads the platform as fedora and version as 13 using to_i" do expect(File).to receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)") @plugin.run expect(@plugin[:platform]).to eq("fedora") @@ -469,7 +469,7 @@ CISCO_RELEASE expect(File).to receive(:read).with("/etc/shared/os-release").and_return(cisco_release_content) end - it "should set platform to nexus_guestshell and platform_family to rhel" do + it "sets platform to nexus_guestshell and platform_family to rhel" do @plugin.run expect(@plugin[:platform]).to start_with("nexus") expect(@plugin[:platform]).to eq("nexus_centos") @@ -488,7 +488,7 @@ CISCO_RELEASE describe "with lsb_result" do - it "should read the platform as parallels and version as 6.0.5" do + it "reads the platform as parallels and version as 6.0.5" do @plugin[:lsb][:id] = "CloudLinuxServer" @plugin[:lsb][:release] = "6.5" allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)") @@ -502,11 +502,11 @@ CISCO_RELEASE describe "without lsb_results" do - before(:each) do + before do @plugin.lsb = nil end - it "should read the platform as parallels and version as 6.0.5" do + it "reads the platform as parallels and version as 6.0.5" do allow(File).to receive(:read).with("/etc/redhat-release").and_return("CloudLinux Server release 6.5 (Pavel Popovich)") expect(File).to receive(:read).with("/etc/parallels-release").and_return("Parallels Cloud Server 6.0.5 (20007)") @plugin.run @@ -527,7 +527,7 @@ CISCO_RELEASE let(:have_enterprise_release) { true } - it "should read the platform as oracle and version as 5.7" do + it "reads the platform as oracle and version as 5.7" do @plugin[:lsb][:id] = "EnterpriseEnterpriseServer" @plugin[:lsb][:release] = "5.7" allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)") @@ -542,7 +542,7 @@ CISCO_RELEASE let(:have_oracle_release) { true } - it "should read the platform as oracle and version as 6.1" do + it "reads the platform as oracle and version as 6.1" do @plugin[:lsb][:id] = "OracleServer" @plugin[:lsb][:release] = "6.1" allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)") @@ -556,7 +556,7 @@ CISCO_RELEASE end context "without lsb_results" do - before(:each) do + before do @plugin.lsb = nil end @@ -564,7 +564,7 @@ CISCO_RELEASE let(:have_enterprise_release) { true } - it "should read the platform as oracle and version as 5" do + it "reads the platform as oracle and version as 5" do allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)") expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)") @plugin.run @@ -572,7 +572,7 @@ CISCO_RELEASE expect(@plugin[:platform_version]).to eq("5") end - it "should read the platform as oracle and version as 5.1" do + it "reads the platform as oracle and version as 5.1" do allow(File).to receive(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)") expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.1 (Carthage)") @plugin.run @@ -580,7 +580,7 @@ CISCO_RELEASE expect(@plugin[:platform_version]).to eq("5.1") end - it "should read the platform as oracle and version as 5.7" do + it "reads the platform as oracle and version as 5.7" do allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 5.7 (Tikanga)") expect(File).to receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5.7 (Carthage)") @plugin.run @@ -594,7 +594,7 @@ CISCO_RELEASE let(:have_oracle_release) { true } - it "should read the platform as oracle and version as 6.0" do + it "reads the platform as oracle and version as 6.0" do allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.0 (Santiago)") expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0") @plugin.run @@ -602,7 +602,7 @@ CISCO_RELEASE expect(@plugin[:platform_version]).to eq("6.0") end - it "should read the platform as oracle and version as 6.1" do + it "reads the platform as oracle and version as 6.1" do allow(File).to receive(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)") expect(File).to receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1") @plugin.run @@ -618,11 +618,11 @@ CISCO_RELEASE let(:have_suse_release) { true } describe "with lsb_release results" do - before(:each) do + before do @plugin[:lsb][:id] = "SUSE LINUX" end - it "should read the platform as opensuse on openSUSE" do + it "reads the platform as opensuse on openSUSE" do @plugin[:lsb][:release] = "12.1" expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n") @plugin.run @@ -632,18 +632,18 @@ CISCO_RELEASE end describe "without lsb_release results" do - before(:each) do + before do @plugin.lsb = nil end - it "should set platform and platform_family to suse and bogus verion to 10.0" do + it "sets platform and platform_family to suse and bogus verion to 10.0" do expect(File).to receive(:read).with("/etc/SuSE-release").at_least(:once).and_return("VERSION = 10.0") @plugin.run 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 + it "reads the version as 10.1 for bogus SLES 10" do expect(File).to receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 10 (i586)\nVERSION = 10\nPATCHLEVEL = 1\n") @plugin.run expect(@plugin[:platform]).to eq("suse") @@ -651,7 +651,7 @@ CISCO_RELEASE expect(@plugin[:platform_family]).to eq("suse") end - it "should read the version as 11.2" do + it "reads the version as 11.2" do 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 expect(@plugin[:platform]).to eq("suse") @@ -683,14 +683,14 @@ CISCO_RELEASE expect(@plugin[:platform_family]).to eq("suse") end - it "should read the platform as opensuse on openSUSE" do + it "reads the platform as opensuse on openSUSE" do expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.2 (x86_64)\nVERSION = 12.2\nCODENAME = Mantis\n") @plugin.run expect(@plugin[:platform]).to eq("opensuse") expect(@plugin[:platform_family]).to eq("suse") end - it "should read the platform as opensuseleap on openSUSE Leap" do + it "reads the platform as opensuseleap on openSUSE Leap" do expect(File).to receive(:read).with("/etc/SuSE-release").and_return("openSUSE 42.1 (x86_64)\nVERSION = 42.1\nCODENAME = Malachite\n") @plugin.run expect(@plugin[:platform]).to eq("opensuseleap") @@ -774,7 +774,7 @@ CISCO_RELEASE } end - it "should set platform to nexus and platform_family to wrlinux" do + it "sets platform to nexus and platform_family to wrlinux" do allow(@plugin).to receive(:os_release_info).and_return(os_release_info) @plugin.lsb = nil @plugin.run @@ -801,7 +801,7 @@ CISCO_RELEASE } end - it "should set platform to ios_xr and platform_family to wrlinux" do + it "sets platform to ios_xr and platform_family to wrlinux" do allow(@plugin).to receive(:os_release_info).and_return(os_release_info) @plugin.lsb = nil @plugin.run diff --git a/spec/unit/plugins/linux/sessions_spec.rb b/spec/unit/plugins/linux/sessions_spec.rb index 89130142..fbc921d1 100644 --- a/spec/unit/plugins/linux/sessions_spec.rb +++ b/spec/unit/plugins/linux/sessions_spec.rb @@ -21,11 +21,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux sessions plugin" do let(:plugin) { get_plugin("linux/sessions") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) end - it "should populate sessions if loginctl is found" do + it "populates sessions if loginctl is found" do loginctl_out = <<-LOGINCTL_OUT c1 118 Debian-gdm seat0 318 0 root @@ -90,7 +90,7 @@ LOGINCTL_OUT }) end - it "should not populate sessions if loginctl is not found" do + it "does not populate sessions if loginctl is not found" do allow(plugin).to receive(:which).with("loginctl").and_return(false) plugin.run expect(plugin[:sessions]).to be(nil) diff --git a/spec/unit/plugins/linux/uptime_spec.rb b/spec/unit/plugins/linux/uptime_spec.rb index 4bdc46de..c95e9a3d 100644 --- a/spec/unit/plugins/linux/uptime_spec.rb +++ b/spec/unit/plugins/linux/uptime_spec.rb @@ -19,29 +19,29 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux plugin uptime" do - before(:each) do + before do @plugin = get_plugin("uptime") allow(@plugin).to receive(:collect_os).and_return(:linux) @double_file = double("/proc/uptime", { :gets => "18423 989" }) allow(File).to receive(:open).with("/proc/uptime").and_return(@double_file) end - it "should set uptime_seconds to uptime" do + it "sets uptime_seconds to uptime" do @plugin.run expect(@plugin[:uptime_seconds]).to eq(18423) end - it "should set uptime to a human readable date" do + it "sets uptime to a human readable date" do @plugin.run expect(@plugin[:uptime]).to eq("5 hours 07 minutes 03 seconds") end - it "should set idletime_seconds to uptime" do + it "sets idletime_seconds to uptime" do @plugin.run expect(@plugin[:idletime_seconds]).to eq(989) end - it "should set idletime to a human readable date" do + it "sets idletime to a human readable date" do @plugin.run expect(@plugin[:idletime]).to eq("16 minutes 29 seconds") end diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb index 84870b95..3c7b56c0 100644 --- a/spec/unit/plugins/linux/virtualization_spec.rb +++ b/spec/unit/plugins/linux/virtualization_spec.rb @@ -21,7 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux virtualization platform" do let(:plugin) { get_plugin("linux/virtualization") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) # default to all requested Files not existing @@ -174,7 +174,7 @@ describe Ohai::System, "Linux virtualization platform" do end describe "when we are parsing dmidecode" do - before(:each) do + before do expect(File).to receive(:exist?).with("/usr/sbin/dmidecode").and_return(true) end @@ -345,7 +345,7 @@ OUTPUT expect(plugin[:virtualization][:systems][:bhyve]).to eq("guest") end - it "should run dmidecode and not set virtualization if nothing is detected" do + it "runs dmidecode and not set virtualization if nothing is detected" do allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", "")) plugin.run expect(plugin[:virtualization]).to eq({ "systems" => {} }) @@ -541,7 +541,7 @@ CGROUP end context "/proc/self/cgroup only has / mounts" do - before(:each) do + before do self_cgroup = <<-CGROUP 8:blkio:/ 7:net_cls:/ @@ -632,7 +632,7 @@ CGROUP # Relevant at least starting docker 1.6.2, kernel 4.0.5 & systemd 224-1. # Doi not exactly know which software/version really matters here. - it "should set docker guest if /proc/self/cgroup exists and there are /system.slice/docker-<hexadecimal> mounts (systemd managed cgroup)" do + it "sets docker guest if /proc/self/cgroup exists and there are /system.slice/docker-<hexadecimal> mounts (systemd managed cgroup)" do self_cgroup = <<-CGROUP 8:devices:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope 7:cpuset:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope @@ -669,7 +669,7 @@ CGROUP end context "/proc/self/cgroup only has / mounts" do - before(:each) do + before do self_cgroup = <<-CGROUP 8:blkio:/ 7:net_cls:/ diff --git a/spec/unit/plugins/lua_spec.rb b/spec/unit/plugins/lua_spec.rb index c994ef17..c7d278c5 100644 --- a/spec/unit/plugins/lua_spec.rb +++ b/spec/unit/plugins/lua_spec.rb @@ -24,7 +24,7 @@ describe Ohai::System, "plugin lua" do let(:plugin) { get_plugin("lua") } - before(:each) do + before do plugin[:languages] = Mash.new @stderr = "Lua 5.1.2 Copyright (C) 1994-2008 Lua.org, PUC-Rio\n" allow(plugin).to receive(:shell_out).with("lua -v").and_return(mock_shell_out(0, "", @stderr)) diff --git a/spec/unit/plugins/mono_spec.rb b/spec/unit/plugins/mono_spec.rb index a45f57ed..6f05f6dd 100644 --- a/spec/unit/plugins/mono_spec.rb +++ b/spec/unit/plugins/mono_spec.rb @@ -21,7 +21,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_he describe Ohai::System, "plugin mono" do let(:plugin) { get_plugin("mono") } - before(:each) do + before do plugin[:languages] = Mash.new @stdout = <<-OUT Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 30 13:57:48 PDT 2016) diff --git a/spec/unit/plugins/netbsd/hostname_spec.rb b/spec/unit/plugins/netbsd/hostname_spec.rb index 4486a4c9..3b214a34 100644 --- a/spec/unit/plugins/netbsd/hostname_spec.rb +++ b/spec/unit/plugins/netbsd/hostname_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "NetBSD hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") 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", "")) @@ -31,12 +31,12 @@ describe Ohai::System, "NetBSD hostname plugin" do it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local") - it "should use #resolve_fqdn to find the fqdn" do + it "uses #resolve_fqdn to find the fqdn" do @plugin.run expect(@plugin[:fqdn]).to eq("katie.bethell") end - it "should set the domain to everything after the first dot of the fqdn" do + it "sets the domain to everything after the first dot of the fqdn" do @plugin.run expect(@plugin[:domain]).to eq("bethell") end diff --git a/spec/unit/plugins/netbsd/kernel_spec.rb b/spec/unit/plugins/netbsd/kernel_spec.rb index 6b716efc..48e418a9 100644 --- a/spec/unit/plugins/netbsd/kernel_spec.rb +++ b/spec/unit/plugins/netbsd/kernel_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "NetBSD kernel plugin" do - before(:each) do + before do @plugin = get_plugin("kernel") allow(@plugin).to receive(:collect_os).and_return(:netbsd) allow(@plugin).to receive(:init_kernel).and_return({}) @@ -28,7 +28,7 @@ describe Ohai::System, "NetBSD kernel plugin" do 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 + it "sets the kernel_os to the kernel_name value" do @plugin.run expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name]) end diff --git a/spec/unit/plugins/netbsd/platform_spec.rb b/spec/unit/plugins/netbsd/platform_spec.rb index 37da17ab..d0947075 100644 --- a/spec/unit/plugins/netbsd/platform_spec.rb +++ b/spec/unit/plugins/netbsd/platform_spec.rb @@ -19,19 +19,19 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "NetBSD plugin platform" do - before(:each) do + before do @plugin = get_plugin("netbsd/platform") 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 + it "sets platform to lowercased lsb[:id]" do @plugin.run expect(@plugin[:platform]).to eq("netbsd") end - it "should set platform_version to lsb[:release]" do + it "sets platform_version to lsb[:release]" do @plugin.run expect(@plugin[:platform_version]).to eq("4.5") end diff --git a/spec/unit/plugins/network_spec.rb b/spec/unit/plugins/network_spec.rb index 60d4cac6..af25aaa0 100644 --- a/spec/unit/plugins/network_spec.rb +++ b/spec/unit/plugins/network_spec.rb @@ -329,7 +329,7 @@ describe Ohai::System, "Network Plugin" do } describe "on linux" do - before(:each) do + before do @plugin = get_plugin("network") @plugin["network"] = basic_data["linux"]["network"] end @@ -490,7 +490,7 @@ describe Ohai::System, "Network Plugin" do expect(@plugin["ip6address"]).to be_nil end - it "should warn about it" do + it "warns about it" do expect(Ohai::Log).to receive(:warn).with(/^unable to detect ipaddress/).once expect(Ohai::Log).to receive(:debug).with(/^unable to detect macaddress/).twice # for each family expect(Ohai::Log).to receive(:debug).with(/^unable to detect ip6address/).once @@ -852,7 +852,7 @@ describe Ohai::System, "Network Plugin" do # specs using network plugin data for each mocked OS (freebsd,linux,windows) basic_data.keys.sort.each do |os| describe "the #{os}::network has already set some of the {ip,mac,ip6}address attributes" do - before(:each) do + before do @plugin["network"] = basic_data[os]["network"] end diff --git a/spec/unit/plugins/nodejs_spec.rb b/spec/unit/plugins/nodejs_spec.rb index a87d5b05..0240bab4 100644 --- a/spec/unit/plugins/nodejs_spec.rb +++ b/spec/unit/plugins/nodejs_spec.rb @@ -24,7 +24,7 @@ describe Ohai::System, "plugin nodejs" do let(:plugin) { get_plugin("nodejs") } - before(:each) do + before do plugin[:languages] = Mash.new @stdout = "v0.8.11\n" allow(plugin).to receive(:shell_out).with("node -v").and_return(mock_shell_out(0, @stdout, "")) diff --git a/spec/unit/plugins/ohai_spec.rb b/spec/unit/plugins/ohai_spec.rb index 530df962..a5cded04 100644 --- a/spec/unit/plugins/ohai_spec.rb +++ b/spec/unit/plugins/ohai_spec.rb @@ -21,11 +21,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin ohai" do - before(:each) do + before do @plugin = get_plugin("ohai") end - it "should set [:chef_packages][:ohai][:version] to the current version" do + it "sets [:chef_packages][:ohai][:version] to the current version" do @plugin.run expect(@plugin[:chef_packages][:ohai][:version]).to eq(Ohai::VERSION) end diff --git a/spec/unit/plugins/ohai_time_spec.rb b/spec/unit/plugins/ohai_time_spec.rb index e1fe0e48..30163482 100644 --- a/spec/unit/plugins/ohai_time_spec.rb +++ b/spec/unit/plugins/ohai_time_spec.rb @@ -19,23 +19,23 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin ohai_time" do - before(:each) do + before do @plugin = get_plugin("ohai_time") end - it "should get the current time" do + it "gets the current time" do expect(Time).to receive(:now) @plugin.run end - it "should turn the time into a floating point number" do + it "turns the time into a floating point number" do time = Time.now 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 + it "sets ohai_time to the current time" do time = Time.now allow(Time).to receive(:now).and_return(time) @plugin.run diff --git a/spec/unit/plugins/openbsd/hostname_spec.rb b/spec/unit/plugins/openbsd/hostname_spec.rb index d2d320a0..1899c291 100644 --- a/spec/unit/plugins/openbsd/hostname_spec.rb +++ b/spec/unit/plugins/openbsd/hostname_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "OpenBSD hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") 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", "")) @@ -31,12 +31,12 @@ describe Ohai::System, "OpenBSD hostname plugin" do it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local") - it "should use #resolve_fqdn to find the fqdn" do + it "uses #resolve_fqdn to find the fqdn" do @plugin.run expect(@plugin[:fqdn]).to eq("katie.bethell") end - it "should set the domain to everything after the first dot of the fqdn" do + it "sets the domain to everything after the first dot of the fqdn" do @plugin.run expect(@plugin[:domain]).to eq("bethell") end diff --git a/spec/unit/plugins/openbsd/kernel_spec.rb b/spec/unit/plugins/openbsd/kernel_spec.rb index f80de3bb..5794e008 100644 --- a/spec/unit/plugins/openbsd/kernel_spec.rb +++ b/spec/unit/plugins/openbsd/kernel_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "OpenBSD kernel plugin" do - before(:each) do + before do @plugin = get_plugin("kernel") allow(@plugin).to receive(:collect_os).and_return(:openbsd) allow(@plugin).to receive(:init_kernel).and_return({}) @@ -28,7 +28,7 @@ describe Ohai::System, "OpenBSD kernel plugin" do 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 + it "sets the kernel_os to the kernel_name value" do @plugin.run expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name]) end diff --git a/spec/unit/plugins/openbsd/platform_spec.rb b/spec/unit/plugins/openbsd/platform_spec.rb index 3c3759ae..ff8e17c6 100644 --- a/spec/unit/plugins/openbsd/platform_spec.rb +++ b/spec/unit/plugins/openbsd/platform_spec.rb @@ -19,14 +19,14 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "OpenBSD plugin platform" do - before(:each) do + before do @plugin = get_plugin("openbsd/platform") 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 + it "sets platform_version to lsb[:release]" do @plugin.run expect(@plugin[:platform_version]).to eq("4.5") end diff --git a/spec/unit/plugins/openstack_spec.rb b/spec/unit/plugins/openstack_spec.rb index fcca9a33..24fa6377 100644 --- a/spec/unit/plugins/openstack_spec.rb +++ b/spec/unit/plugins/openstack_spec.rb @@ -23,7 +23,7 @@ describe "OpenStack Plugin" do let(:plugin) { get_plugin("openstack") } - before(:each) do + before do allow(plugin).to receive(:hint?).with("openstack").and_return(false) plugin[:dmi] = nil end diff --git a/spec/unit/plugins/os_spec.rb b/spec/unit/plugins/os_spec.rb index 3cff244d..ef909864 100644 --- a/spec/unit/plugins/os_spec.rb +++ b/spec/unit/plugins/os_spec.rb @@ -21,7 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG["host_os"] describe Ohai::System, "plugin os" do - before(:each) do + before do @plugin = get_plugin("os") @plugin[:kernel] = Mash.new @plugin[:kernel][:release] = "kings of leon" @@ -31,28 +31,28 @@ describe Ohai::System, "plugin os" do ::RbConfig::CONFIG["host_os"] = ORIGINAL_CONFIG_HOST_OS end - it "should set os_version to kernel_release" do + it "sets os_version to kernel_release" do @plugin.run expect(@plugin[:os_version]).to eq(@plugin[:kernel][:release]) end describe "on linux" do - before(:each) do + before do ::RbConfig::CONFIG["host_os"] = "linux" end - it "should set the os to linux" do + it "sets the os to linux" do @plugin.run expect(@plugin[:os]).to eq("linux") end end describe "on darwin" do - before(:each) do + before do ::RbConfig::CONFIG["host_os"] = "darwin10.0" end - it "should set the os to darwin" do + it "sets the os to darwin" do @plugin.run expect(@plugin[:os]).to eq("darwin") end diff --git a/spec/unit/plugins/packages_spec.rb b/spec/unit/plugins/packages_spec.rb index ac1e5a26..6feca11c 100644 --- a/spec/unit/plugins/packages_spec.rb +++ b/spec/unit/plugins/packages_spec.rb @@ -33,7 +33,7 @@ describe Ohai::System, "plugin packages" do File.read(File.join(SPEC_PLUGIN_PATH, "dpkg-query.output")) end - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(plugin).to receive(:shell_out) .with("dpkg-query -W -f='#{format}'") @@ -72,7 +72,7 @@ describe Ohai::System, "plugin packages" do File.read(File.join(SPEC_PLUGIN_PATH, "rpmquery.output")) end - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(plugin).to receive(:shell_out).with("rpm -qa --qf '#{format}'").and_return(mock_shell_out(0, stdout, "")) plugin.run @@ -152,7 +152,7 @@ describe Ohai::System, "plugin packages" do end end - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:windows) allow(win_reg_double).to receive(:open).with(win_reg_keys[0]).and_return(win_reg_output[0]) allow(win_reg_double).to receive(:open).with(win_reg_keys[1]).and_return(win_reg_output[1]) @@ -194,7 +194,7 @@ describe Ohai::System, "plugin packages" do File.read(File.join(SPEC_PLUGIN_PATH, "lslpp.output")) end - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:aix) allow(plugin).to receive(:shell_out).with("lslpp -L -q -c").and_return(mock_shell_out(0, stdout, "")) plugin.run @@ -219,7 +219,7 @@ describe Ohai::System, "plugin packages" do File.read(File.join(SPEC_PLUGIN_PATH, "pkg-query.output")) end - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:freebsd) allow(plugin).to receive(:shell_out).with('pkg query -a "%n %v"').and_return(mock_shell_out(0, stdout, "")) plugin.run @@ -248,7 +248,7 @@ describe Ohai::System, "plugin packages" do File.read(File.join(SPEC_PLUGIN_PATH, "pkginfo.output")) end - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:solaris2) allow(plugin).to receive(:shell_out).with("pkg list -H").and_return(mock_shell_out(0, pkglist_output, "")) allow(plugin).to receive(:shell_out).with("pkginfo -l").and_return(mock_shell_out(0, pkginfo_output, "")) diff --git a/spec/unit/plugins/passwd_spec.rb b/spec/unit/plugins/passwd_spec.rb index b6559989..eafe4c76 100644 --- a/spec/unit/plugins/passwd_spec.rb +++ b/spec/unit/plugins/passwd_spec.rb @@ -1,14 +1,14 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin etc", :unix_only do - before(:each) do + before do @plugin = get_plugin("passwd") end PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos) GroupEntry = Struct.new(:name, :gid, :mem) - it "should include a list of all users" do + it "includes a list of all users" do 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 @@ -16,21 +16,21 @@ describe Ohai::System, "plugin etc", :unix_only do 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 + it "ignores duplicate users" do 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 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 + it "sets the current user" do 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 expect(@plugin[:current_user]).to eq("chef") end - it "should set the available groups" do + it "sets the available groups" do expect(Etc).to receive(:group).and_yield(GroupEntry.new("admin", 100, %w{root chef})).and_yield(GroupEntry.new("www", 800, %w{www deploy})) @plugin.run expect(@plugin[:etc][:group]["admin"]).to eq(Mash.new(:gid => 100, :members => %w{root chef})) diff --git a/spec/unit/plugins/perl_spec.rb b/spec/unit/plugins/perl_spec.rb index 47bd686f..0f5c73ec 100644 --- a/spec/unit/plugins/perl_spec.rb +++ b/spec/unit/plugins/perl_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin perl" do let(:plugin) { get_plugin("perl") } - before(:each) do + before do plugin[:languages] = Mash.new @stdout = "version='5.8.8';#{$/}archname='darwin-thread-multi-2level';" allow(plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, "")) diff --git a/spec/unit/plugins/php_spec.rb b/spec/unit/plugins/php_spec.rb index cc2542ae..c7ed30f4 100644 --- a/spec/unit/plugins/php_spec.rb +++ b/spec/unit/plugins/php_spec.rb @@ -23,7 +23,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_he describe Ohai::System, "plugin php" do let(:plugin) { get_plugin("php") } - before(:each) do + before do plugin[:languages] = Mash.new @stdout = <<-OUT PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52) diff --git a/spec/unit/plugins/platform_spec.rb b/spec/unit/plugins/platform_spec.rb index 7e841c3f..2b77cbba 100644 --- a/spec/unit/plugins/platform_spec.rb +++ b/spec/unit/plugins/platform_spec.rb @@ -19,45 +19,45 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin platform" do - before(:each) do + before do @plugin = get_plugin("platform") 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 + it "sets the platform and platform family to the os if it was not set earlier" do @plugin.run 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 + it "does not set the platform to the os if it was set earlier" do @plugin[:platform] = "lars" @plugin.run 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 + it "sets 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 expect(@plugin[:platform_family]).to eql("jack") end - it "should not set the platform_family if the platform_family was set earlier." do + it "does not set the platform_family if the platform_family was set earlier." do @plugin[:platform] = "lars" @plugin.run 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 + it "sets the platform_version to the os_version if it was not set earlier" do @plugin.run expect(@plugin[:os_version]).to eql("poop") end - it "should not set the platform to the os if it was set earlier" do + it "does not set the platform to the os if it was set earlier" do @plugin[:platform_version] = "ulrich" @plugin.run expect(@plugin[:platform_version]).to eql("ulrich") diff --git a/spec/unit/plugins/powershell_spec.rb b/spec/unit/plugins/powershell_spec.rb index 43ecbee9..c0ce086e 100644 --- a/spec/unit/plugins/powershell_spec.rb +++ b/spec/unit/plugins/powershell_spec.rb @@ -24,7 +24,7 @@ describe Ohai::System, "plugin powershell" do stub_const("::RbConfig::CONFIG", { "host_os" => "windows" }) end - before(:each) do + before do plugin[:languages] = Mash.new end diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb index 76dc34bf..3b7f6c81 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin rackspace" do let(:plugin) { get_plugin("rackspace") } - before(:each) do + before do allow(Resolv).to receive(:getname).and_return("1.2.3.4") plugin[:hostname] = "katie" @@ -187,7 +187,7 @@ OUT describe "with rackspace hint file" do it_behaves_like "rackspace" - before(:each) do + before do allow(Resolv).to receive(:getname).and_raise(Resolv::ResolvError) allow(File).to receive(:exist?).with("/etc/resolv.conf").and_return(true) allow(File).to receive(:read).with("/etc/resolv.conf").and_return("") @@ -219,7 +219,7 @@ OUT describe "without hint file" do it_behaves_like "!rackspace" - before(:each) do + before do allow(plugin).to receive(:hint?).with("rackspace").and_return(false) end end @@ -227,7 +227,7 @@ OUT describe "xenstore provider returns rackspace" do it_behaves_like "rackspace" - before(:each) do + before do stdout = "Rackspace\n" allow(plugin).to receive(:hint?).with("rackspace").and_return(false) allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" )) @@ -237,7 +237,7 @@ OUT describe "xenstore provider does not return rackspace" do it_behaves_like "!rackspace" - before(:each) do + before do allow(plugin).to receive(:hint?).with("rackspace").and_return(false) stdout = "cumulonimbus\n" allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" )) @@ -247,7 +247,7 @@ OUT describe "xenstore provider does not exist" do it_behaves_like "!rackspace" - before(:each) do + before do allow(plugin).to receive(:hint?).with("rackspace").and_return(false) allow(plugin). to receive(:shell_out). diff --git a/spec/unit/plugins/root_group_spec.rb b/spec/unit/plugins/root_group_spec.rb index 67ee4c11..8e719c3d 100644 --- a/spec/unit/plugins/root_group_spec.rb +++ b/spec/unit/plugins/root_group_spec.rb @@ -20,12 +20,12 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") require File.expand_path(File.dirname(__FILE__) + "/../../../lib/ohai/util/win32/group_helper.rb") describe Ohai::System, "root_group" do - before(:each) do + before do @plugin = get_plugin("root_group") end describe "unix platform", :unix_only do - before(:each) do + before do # this is deeply intertwingled. unfortunately, the law of demeter # apparently didn't apply to this api. we're just trying to fake # Etc.getgrgid(Etc.getpwnam('root').gid).name @@ -37,40 +37,40 @@ describe Ohai::System, "root_group" do end describe "with wheel group" do - before(:each) do + before do allow(@grgid).to receive(:name).and_return("wheel") end - it "should have a root_group of wheel" do + it "has a root_group of wheel" do @plugin.run expect(@plugin[:root_group]).to eq("wheel") end end describe "with root group" do - before(:each) do + before do allow(@grgid).to receive(:name).and_return("root") end - it "should have a root_group of root" do + it "has a root_group of root" do @plugin.run expect(@plugin[:root_group]).to eq("root") end end describe "platform hpux with sys group" do - before(:each) do + before do 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 + it "has a root_group of sys" do @plugin.run expect(@plugin[:root_group]).to eq("sys") end end describe "platform aix with system group" do - before(:each) do + before do allow(@grgid).to receive(:name).and_return("system") end - it "should have a root_group of system" do + it "has a root_group of system" do @plugin.run expect(@plugin[:root_group]).to eq("system") end @@ -78,7 +78,7 @@ describe Ohai::System, "root_group" do end describe "windows platform" do - it "should return the group administrators" do + it "returns the group administrators" do stub_const("::RbConfig::CONFIG", { "host_os" => "windows" } ) expect(Ohai::Util::Win32::GroupHelper).to receive(:windows_root_group_name).and_return("administrators") @plugin.run diff --git a/spec/unit/plugins/ruby_spec.rb b/spec/unit/plugins/ruby_spec.rb index 9acb35b6..4b9514ff 100644 --- a/spec/unit/plugins/ruby_spec.rb +++ b/spec/unit/plugins/ruby_spec.rb @@ -30,7 +30,7 @@ describe Ohai::System, "plugin ruby" do @ruby_ohai_data_pristine = @plugin[:languages][:ruby] end - before(:each) do + before do @ruby_ohai_data = @ruby_ohai_data_pristine.dup end diff --git a/spec/unit/plugins/rust_spec.rb b/spec/unit/plugins/rust_spec.rb index daa45d48..6fd0b13d 100644 --- a/spec/unit/plugins/rust_spec.rb +++ b/spec/unit/plugins/rust_spec.rb @@ -25,17 +25,17 @@ describe Ohai::System, "plugin rust" do plugin end - it "should get the rust version" do + it "gets the rust version" do expect(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(0, stdout, "")) plugin.run end - it "should set languages[:rust][:version]" do + it "sets languages[:rust][:version]" do plugin.run expect(plugin.languages[:rust][:version]).to eql("1.0.0-nightly") end - it "should not set the languages[:rust] if rust command fails" do + it "does not set the languages[:rust] if rust command fails" do allow(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(1, stdout, "")) plugin.run expect(plugin.languages).not_to have_key(:rust) diff --git a/spec/unit/plugins/scala_spec.rb b/spec/unit/plugins/scala_spec.rb index f85c577c..640bb752 100644 --- a/spec/unit/plugins/scala_spec.rb +++ b/spec/unit/plugins/scala_spec.rb @@ -38,7 +38,7 @@ describe Ohai::System, "plugin scala" do end context "if scala is installed" do - before(:each) do + before do setup_plugin plugin.run end @@ -50,7 +50,7 @@ describe Ohai::System, "plugin scala" do context "if sbt is installed" do - before(:each) do + before do setup_plugin plugin.run end @@ -62,7 +62,7 @@ describe Ohai::System, "plugin scala" do context "if scala/sbt are not installed" do - before(:each) do + before do allow(plugin).to receive(:shell_out) .and_raise( Ohai::Exceptions::Exec ) plugin.run @@ -74,7 +74,7 @@ describe Ohai::System, "plugin scala" do end context "if sbt is not installed" do - before(:each) do + before do allow(plugin).to receive(:shell_out) .with("scala -version") .and_return(mock_shell_out(0, "", scala_out)) diff --git a/spec/unit/plugins/shard_spec.rb b/spec/unit/plugins/shard_spec.rb index 5d6ef066..fef5c192 100644 --- a/spec/unit/plugins/shard_spec.rb +++ b/spec/unit/plugins/shard_spec.rb @@ -27,7 +27,7 @@ describe Ohai::System, "shard plugin" do let(:machine_id) { "0a1f869f457a4c8080ab19faf80af9cc" } let(:machinename) { "somehost004" } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) plugin["machinename"] = machinename plugin["machine_id"] = machine_id @@ -38,7 +38,7 @@ describe Ohai::System, "shard plugin" do allow(plugin).to receive(:collect_os).and_return(:linux) end - it "should provide a shard with a default-safe set of sources" do + it "provides a shard with a default-safe set of sources" do plugin.run result = Digest::MD5.hexdigest( "#{machinename}#{serial}#{uuid}" @@ -46,7 +46,7 @@ describe Ohai::System, "shard plugin" do expect(plugin[:shard_seed]).to eq(result) end - it "should provide a shard with a configured source" do + it "provides a shard with a configured source" do Ohai.config[:plugin][:shard_seed][:sources] = [:fqdn] plugin.run result = Digest::MD5.hexdigest(fqdn)[0...7].to_i(16) diff --git a/spec/unit/plugins/sigar/network_route_spec.rb b/spec/unit/plugins/sigar/network_route_spec.rb index b3b2ec4d..ad7fe9c0 100644 --- a/spec/unit/plugins/sigar/network_route_spec.rb +++ b/spec/unit/plugins/sigar/network_route_spec.rb @@ -31,7 +31,7 @@ describe Ohai::System, "Sigar network route plugin" do if sigar_available - before(:each) do + before do @ohai = Ohai::System.new @plugin = get_plugin("sigar/network", @ohai) allow(@plugin).to receive(:collect_os).and_return(:sigar) @@ -126,11 +126,11 @@ describe Ohai::System, "Sigar network route plugin" do @plugin.run end - it "should set the routes" do + it "sets the routes" do expect(@plugin[:network][:interfaces][:eth0]).to have_key(:route) end - it "should set the route details" do + it "sets the route details" do @net_route_conf.each_pair do |k, v| # Work around the above doubleing of net_route_list skipping the call to flags() if k == :flags diff --git a/spec/unit/plugins/solaris2/cpu_spec.rb b/spec/unit/plugins/solaris2/cpu_spec.rb index c183b796..d84e1ef1 100644 --- a/spec/unit/plugins/solaris2/cpu_spec.rb +++ b/spec/unit/plugins/solaris2/cpu_spec.rb @@ -17,13 +17,13 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris2.X cpu plugin" do - before(:each) do + before do @plugin = get_plugin("solaris2/cpu") allow(@plugin).to receive(:collect_os).and_return("solaris2") end describe "on x86 processors" do - before(:each) do + before do kstatinfo_output = <<-END cpu_info:0:cpu_info0:brand Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz cpu_info:0:cpu_info0:cache_id 1 @@ -446,28 +446,28 @@ END @plugin.run end - it "should get the total virtual processor count" do - expect(@plugin["cpu"]["total"]).to eql(16) + it "gets the total virtual processor count" do + expect(@plugin["cpu"]["total"]).to be(16) end - it "should get the total processor count" do - expect(@plugin["cpu"]["real"]).to eql(2) + it "gets the total processor count" do + expect(@plugin["cpu"]["real"]).to be(2) end - it "should get the number of threads per core" do + it "gets the number of threads per core" do expect(@plugin["cpu"]["corethreads"]).to eql (2) end - it "should get the total number of online cores" do + it "gets the total number of online cores" do expect(@plugin["cpu"]["cpustates"]["on-line"]).to eql (8) end - it "should get the total number of offline cores" do + it "gets the total number of offline cores" do expect(@plugin["cpu"]["cpustates"]["off-line"]).to eql (8) end describe "per-cpu information" do - it "should include processor vendor_ids" do + it "includes processor vendor_ids" do # CPU Socket 0 expect(@plugin["cpu"]["15"]["vendor_id"]).to eql("GenuineIntel") expect(@plugin["cpu"]["13"]["vendor_id"]).to eql("GenuineIntel") @@ -488,7 +488,7 @@ END expect(@plugin["cpu"]["0"]["vendor_id"]).to eql("CrazyTown") end - it "should include processor families" do + it "includes processor families" do expect(@plugin["cpu"]["15"]["family"]).to eql("6") expect(@plugin["cpu"]["13"]["family"]).to eql("6") expect(@plugin["cpu"]["11"]["family"]).to eql("6") @@ -508,7 +508,7 @@ END expect(@plugin["cpu"]["0"]["family"]).to eql("12") end - it "should include processor models" do + it "includes processor models" do expect(@plugin["cpu"]["15"]["model"]).to eql("26") expect(@plugin["cpu"]["13"]["model"]).to eql("26") expect(@plugin["cpu"]["11"]["model"]).to eql("26") @@ -528,7 +528,7 @@ END expect(@plugin["cpu"]["0"]["model"]).to eql("93") end - it "should includ processor architecture" do + it "includs processor architecture" do expect(@plugin["cpu"]["15"]["arch"]).to eql("i386") expect(@plugin["cpu"]["13"]["arch"]).to eql("i386") expect(@plugin["cpu"]["11"]["arch"]).to eql("i386") @@ -548,7 +548,7 @@ END expect(@plugin["cpu"]["0"]["arch"]).to eql("i386") end - it "should include processor stepping" do + it "includes processor stepping" do expect(@plugin["cpu"]["15"]["stepping"]).to eql("5") expect(@plugin["cpu"]["13"]["stepping"]).to eql("5") expect(@plugin["cpu"]["11"]["stepping"]).to eql("5") @@ -569,7 +569,7 @@ END end - it "should include processor model names" do + it "includes processor model names" do expect(@plugin["cpu"]["15"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz") expect(@plugin["cpu"]["13"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz") expect(@plugin["cpu"]["11"]["model_name"]).to eql("Intel(r) Xeon(r) CPU X5570 @ 2.93GHz") @@ -588,7 +588,7 @@ END expect(@plugin["cpu"]["0"]["model_name"]).to eql("Crazy(r) Argon(r) CPU Y5570 @ 1.93GHz") end - it "should include processor speed in MHz" do + it "includes processor speed in MHz" do expect(@plugin["cpu"]["15"]["mhz"]).to eql("2926") expect(@plugin["cpu"]["13"]["mhz"]).to eql("2926") expect(@plugin["cpu"]["11"]["mhz"]).to eql("2926") @@ -607,7 +607,7 @@ END expect(@plugin["cpu"]["0"]["mhz"]).to eql("1933") end - it "should include processor state" do + it "includes processor state" do expect(@plugin["cpu"]["15"]["state"]).to eql("on-line") expect(@plugin["cpu"]["13"]["state"]).to eql("on-line") expect(@plugin["cpu"]["11"]["state"]).to eql("on-line") @@ -629,7 +629,7 @@ END end describe "on sparc processors" do - before(:each) do + before do kstatinfo_output = <<-END cpu_info:0:cpu_info0:brand SPARC-T3 cpu_info:0:cpu_info0:chip_id 0 @@ -2812,32 +2812,32 @@ END @plugin.run end - it "should get the total virtual processor count" do - expect(@plugin["cpu"]["total"]).to eql(128) + it "gets the total virtual processor count" do + expect(@plugin["cpu"]["total"]).to be(128) end - it "should get the total processor count" do - expect(@plugin["cpu"]["real"]).to eql(1) + it "gets the total processor count" do + expect(@plugin["cpu"]["real"]).to be(1) end - it "should get the total core count" do - expect(@plugin["cpu"]["cores"]).to eql(16) + it "gets the total core count" do + expect(@plugin["cpu"]["cores"]).to be(16) end - it "should get the number of threads per core" do - expect(@plugin["cpu"]["corethreads"]).to eql(8) + it "gets the number of threads per core" do + expect(@plugin["cpu"]["corethreads"]).to be(8) end - it "should get the total number of online cores" do - expect(@plugin["cpu"]["cpustates"]["on-line"]).to eql(124) + it "gets the total number of online cores" do + expect(@plugin["cpu"]["cpustates"]["on-line"]).to be(124) end - it "should get the total number of offline cores" do - expect(@plugin["cpu"]["cpustates"]["off-line"]).to eql(4) + it "gets the total number of offline cores" do + expect(@plugin["cpu"]["cpustates"]["off-line"]).to be(4) end describe "per-cpu information" do - it "should include processor model names" do + it "includes processor model names" do expect(@plugin["cpu"]["0"]["model_name"]).to eql("SPARC-T3") expect(@plugin["cpu"]["1"]["model_name"]).to eql("SPARC-T3") expect(@plugin["cpu"]["2"]["model_name"]).to eql("SPARC-T3") @@ -2848,7 +2848,7 @@ END expect(@plugin["cpu"]["127"]["model_name"]).to eql("SPARC-T4") end - it "should include processor sockets" do + it "includes processor sockets" do expect(@plugin["cpu"]["0"]["socket"]).to eql("0") expect(@plugin["cpu"]["1"]["socket"]).to eql("0") expect(@plugin["cpu"]["2"]["socket"]).to eql("0") @@ -2859,7 +2859,7 @@ END expect(@plugin["cpu"]["127"]["socket"]).to eql("0") end - it "should include processor MHz" do + it "includes processor MHz" do expect(@plugin["cpu"]["0"]["mhz"]).to eql("1649") expect(@plugin["cpu"]["1"]["mhz"]).to eql("1649") expect(@plugin["cpu"]["2"]["mhz"]).to eql("1649") @@ -2870,7 +2870,7 @@ END expect(@plugin["cpu"]["127"]["mhz"]).to eql("1649") end - it "should include processor core IDs" do + it "includes processor core IDs" do expect(@plugin["cpu"]["0"]["core_id"]).to eql("1026") expect(@plugin["cpu"]["8"]["core_id"]).to eql("1033") expect(@plugin["cpu"]["16"]["core_id"]).to eql("1040") @@ -2889,7 +2889,7 @@ END expect(@plugin["cpu"]["120"]["core_id"]).to eql("1131") end - it "should include processor architecture" do + it "includes processor architecture" do expect(@plugin["cpu"]["0"]["arch"]).to eql("sparcv9") expect(@plugin["cpu"]["1"]["arch"]).to eql("sparcv9") expect(@plugin["cpu"]["2"]["arch"]).to eql("sparcv9") @@ -2900,7 +2900,7 @@ END expect(@plugin["cpu"]["127"]["arch"]).to eql("sparcv9") end - it "should include processor FPU type" do + it "includes processor FPU type" do expect(@plugin["cpu"]["0"]["fpu_type"]).to eql("sparcv9") expect(@plugin["cpu"]["1"]["fpu_type"]).to eql("sparcv9") expect(@plugin["cpu"]["2"]["fpu_type"]).to eql("sparcv9") @@ -2911,7 +2911,7 @@ END expect(@plugin["cpu"]["127"]["fpu_type"]).to eql("sparcv9") end - it "should include processor state" do + it "includes processor state" do expect(@plugin["cpu"]["0"]["state"]).to eql("on-line") expect(@plugin["cpu"]["1"]["state"]).to eql("on-line") expect(@plugin["cpu"]["2"]["state"]).to eql("on-line") diff --git a/spec/unit/plugins/solaris2/dmi_spec.rb b/spec/unit/plugins/solaris2/dmi_spec.rb index 261c4431..ccaeb6dd 100644 --- a/spec/unit/plugins/solaris2/dmi_spec.rb +++ b/spec/unit/plugins/solaris2/dmi_spec.rb @@ -112,14 +112,14 @@ ID SIZE TYPE EOS describe Ohai::System, "Solaris2.X DMI plugin" do - before(:each) do + before do @plugin = get_plugin("solaris2/dmi") allow(@plugin).to receive(:collect_os).and_return("solaris2") @stdout = SOLARIS_DMI_OUT allow(@plugin).to receive(:shell_out).with("smbios").and_return(mock_shell_out(0, @stdout, "")) end - it "should run smbios" do + it "runs smbios" do expect(@plugin).to receive(:shell_out).with("smbios").and_return(mock_shell_out(0, @stdout, "")) @plugin.run end @@ -146,7 +146,7 @@ describe Ohai::System, "Solaris2.X DMI plugin" do end end - it "should ignore unwanted types" do + it "ignores unwanted types" do @plugin.run expect(@plugin[:dmi]).not_to have_key(:on_board_devices) end diff --git a/spec/unit/plugins/solaris2/filesystem.rb b/spec/unit/plugins/solaris2/filesystem.rb index 97a3b222..8ced417c 100644 --- a/spec/unit/plugins/solaris2/filesystem.rb +++ b/spec/unit/plugins/solaris2/filesystem.rb @@ -20,14 +20,14 @@ require_relative "../../../spec_helper" describe Ohai::System, "Solaris2.X filesystem plugin" do let(:plugin) { get_plugin("solaris2/filesystem") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return("solaris2") end describe "filesystem properties" do let(:plugin_config) { {} } - before(:each) do + before do @original_plugin_config = Ohai.config[:plugin] Ohai.config[:plugin] = plugin_config allow(plugin).to receive(:shell_out).with("df -Pka").and_return(mock_shell_out(0, "", "")) @@ -35,7 +35,7 @@ describe Ohai::System, "Solaris2.X filesystem plugin" do allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", "")) end - after(:each) do + after do Ohai.config[:plugin] = @original_plugin_config end diff --git a/spec/unit/plugins/solaris2/hostname_spec.rb b/spec/unit/plugins/solaris2/hostname_spec.rb index 6b793abe..175c090f 100644 --- a/spec/unit/plugins/solaris2/hostname_spec.rb +++ b/spec/unit/plugins/solaris2/hostname_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris2.X hostname plugin" do - before(:each) do + before do @plugin = get_plugin("hostname") allow(@plugin).to receive(:collect_os).and_return(:solaris2) allow(@plugin).to receive(:resolve_fqdn).and_return("kitteh.inurfridge.eatinurfoodz") @@ -29,7 +29,7 @@ describe Ohai::System, "Solaris2.X hostname plugin" do it_should_check_from("solaris2::hostname", "hostname", "hostname", "kitteh") - it "should get the fqdn value from #resolve_fqdn" do + it "gets the fqdn value from #resolve_fqdn" do @plugin.run expect(@plugin["fqdn"]).to eq("kitteh.inurfridge.eatinurfoodz") end diff --git a/spec/unit/plugins/solaris2/kernel_spec.rb b/spec/unit/plugins/solaris2/kernel_spec.rb index cb2822b1..06732025 100644 --- a/spec/unit/plugins/solaris2/kernel_spec.rb +++ b/spec/unit/plugins/solaris2/kernel_spec.rb @@ -133,7 +133,7 @@ describe Ohai::System, "Solaris2.X kernel plugin" do 146 121719e 28c - 1 RT_DPTBL (realtime dispatch table) TOOMUCH - before(:each) do + before do @plugin = get_plugin("kernel") allow(@plugin).to receive(:collect_os).and_return(:solaris2) allow(@plugin).to receive(:init_kernel).and_return({}) @@ -143,21 +143,21 @@ describe Ohai::System, "Solaris2.X kernel plugin" do allow(File).to receive(:open).with("/etc/release").and_yield(@release) end - it "should give the Solaris update version information" do + it "gives the Solaris update version information" do @release = StringIO.new(" Solaris 10 10/08 s10s_u6wos_07b SPARC\n Use is subject to license terms.\n Assembled 27 October 2008") allow(File).to receive(:open).with("/etc/release").and_yield(@release) @plugin.run expect(@plugin[:kernel][:update]).to eq("10 10/08 s10s_u6wos_07") end - it "should give the Oracle Solaris update version information" do + it "gives the Oracle Solaris update version information" do @release = StringIO.new(" Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC\n Assembled 17 January 2013") allow(File).to receive(:open).with("/etc/release").and_yield(@release) @plugin.run expect(@plugin[:kernel][:update]).to eq("10 1/13 s10s_u11wos_24") end - it "should give the Solaris 11 update version information" do + it "gives the Solaris 11 update version information" do @release = StringIO.new(" Oracle Solaris 11.3 SPARC\n Assembled 25 July 2016") allow(File).to receive(:open).with("/etc/release").and_yield(@release) @plugin.run diff --git a/spec/unit/plugins/solaris2/memory_spec.rb b/spec/unit/plugins/solaris2/memory_spec.rb index 101dcd3d..e8046c45 100644 --- a/spec/unit/plugins/solaris2/memory_spec.rb +++ b/spec/unit/plugins/solaris2/memory_spec.rb @@ -17,7 +17,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris2.X memory plugin" do - before(:each) do + before do @plugin = get_plugin("solaris2/memory") allow(@plugin).to receive(:collect_os).and_return("solaris2") allow(@plugin).to receive(:shell_out).with("prtconf | grep Memory").and_return(mock_shell_out(0, "Memory size: 8194 Megabytes\n", "")) @@ -25,17 +25,17 @@ describe Ohai::System, "Solaris2.X memory plugin" do allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, "")) end - it "should get the total memory" do + it "gets the total memory" do @plugin.run expect(@plugin[:memory][:total]).to eql("#{8194 * 1024}kB") end - it "should get total swap" do + it "gets total swap" do @plugin.run expect(@plugin[:memory][:swap][:total]).to eql("#{(470096232 + 47057688)}kB" ) end - it "should get free swap" do + it "gets free swap" do @plugin.run expect(@plugin[:memory][:swap][:free]).to eql("47057688kB") end diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb index 1c813f72..f6ca85e6 100644 --- a/spec/unit/plugins/solaris2/platform_spec.rb +++ b/spec/unit/plugins/solaris2/platform_spec.rb @@ -19,14 +19,14 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris plugin platform" do - before(:each) do + before do @plugin = get_plugin("solaris2/platform") allow(@plugin).to receive(:collect_os).and_return(:solaris2) allow(@plugin).to receive(:shell_out).with("/sbin/uname -X") end describe "on SmartOS" do - before(:each) do + before do @uname_x = <<-UNAME_X System = SunOS Node = node.example.com @@ -48,17 +48,17 @@ UNAME_X allow(File).to receive(:open).with("/etc/release").and_yield(@release) end - it "should run uname and set platform and build" do + it "runs uname and set platform and build" do @plugin.run expect(@plugin[:platform_build]).to eq("joyent_20120130T201844Z") end - it "should set the platform" do + it "sets the platform" do @plugin.run expect(@plugin[:platform]).to eq("smartos") end - it "should set the platform_version" do + it "sets the platform_version" do @plugin.run expect(@plugin[:platform_version]).to eq("5.11") end @@ -66,7 +66,7 @@ UNAME_X end describe "on Solaris 11" do - before(:each) do + before do @uname_x = <<-UNAME_X System = SunOS Node = node.example.com @@ -88,17 +88,17 @@ UNAME_X allow(File).to receive(:open).with("/etc/release").and_yield(@release) end - it "should run uname and set platform and build" do + it "runs uname and set platform and build" do @plugin.run expect(@plugin[:platform_build]).to eq("11.1") end - it "should set the platform" do + it "sets the platform" do @plugin.run expect(@plugin[:platform]).to eq("solaris2") end - it "should set the platform_version" do + it "sets the platform_version" do @plugin.run expect(@plugin[:platform_version]).to eq("5.11") end diff --git a/spec/unit/plugins/solaris2/virtualization_spec.rb b/spec/unit/plugins/solaris2/virtualization_spec.rb index e0f950e3..94cb3a3b 100644 --- a/spec/unit/plugins/solaris2/virtualization_spec.rb +++ b/spec/unit/plugins/solaris2/virtualization_spec.rb @@ -19,7 +19,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris virtualization platform" do - before(:each) do + before do @psrinfo_pv = <<-PSRINFO_PV The physical processor has 1 virtual processor (0) x86 (GenuineIntel family 6 model 2 step 3 clock 2667 MHz) @@ -38,16 +38,16 @@ PSRINFO_PV end describe "when we are checking for kvm" do - before(:each) do + before do expect(File).to receive(:exist?).with("/usr/sbin/psrinfo").and_return(true) end - it "should run psrinfo -pv" do + it "runs psrinfo -pv" do 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 + it "sets kvm guest if psrinfo -pv contains QEMU Virtual CPU" do 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 expect(@plugin[:virtualization][:system]).to eq("kvm") @@ -55,7 +55,7 @@ PSRINFO_PV expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest") end - it "should not set virtualization if kvm isn't there" do + it "does not set virtualization if kvm isn't there" do expect(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, "")) @plugin.run expect(@plugin[:virtualization][:systems]).to eq({}) @@ -63,16 +63,16 @@ PSRINFO_PV end describe "when we are parsing smbios" do - before(:each) do + before do expect(File).to receive(:exist?).with("/usr/sbin/smbios").and_return(true) end - it "should run smbios" do + it "runs smbios" do expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios") @plugin.run end - it "should set virtualpc guest if smbios detects Microsoft Virtual Machine" do + it "sets virtualpc guest if smbios detects Microsoft Virtual Machine" do ms_vpc_smbios = <<-MSVPC ID SIZE TYPE 1 72 SMB_TYPE_SYSTEM (system information) @@ -91,7 +91,7 @@ MSVPC expect(@plugin[:virtualization][:role]).to eq("guest") end - it "should set vmware guest if smbios detects VMware Virtual Platform" do + it "sets vmware guest if smbios detects VMware Virtual Platform" do vmware_smbios = <<-VMWARE ID SIZE TYPE 1 72 SMB_TYPE_SYSTEM (system information) @@ -111,14 +111,14 @@ VMWARE expect(@plugin[:virtualization][:systems][:vmware]).to eq("guest") end - it "should run smbios and not set virtualization if nothing is detected" do + it "runs smbios and not set virtualization if nothing is detected" do expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios") @plugin.run expect(@plugin[:virtualization][:systems]).to eq({}) end end - it "should not set virtualization if no tests match" do + it "does not set virtualization if no tests match" do @plugin.run expect(@plugin[:virtualization][:systems]).to eq({}) end diff --git a/spec/unit/plugins/solaris2/zpools_spec.rb b/spec/unit/plugins/solaris2/zpools_spec.rb index b53b659b..5ca7029d 100644 --- a/spec/unit/plugins/solaris2/zpools_spec.rb +++ b/spec/unit/plugins/solaris2/zpools_spec.rb @@ -16,7 +16,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris 2.x zpool plugin" do - before(:each) do + before do @plugin = get_plugin("solaris2/zpools") allow(@plugin).to receive(:collect_os).and_return(:solaris2) @@ -68,49 +68,49 @@ EOZO end describe "On Solaris2 Common" do - it "Should have entries for both zpools" do + it "has entries for both zpools" do @plugin.run expect(@plugin[:zpools][:rpool]).to be expect(@plugin[:zpools][:tank]).to be end - it "Should have the correct pool size" do + it "has the correct pool size" do @plugin.run expect(@plugin[:zpools][:rpool][:pool_size]).to match("109G") expect(@plugin[:zpools][:tank][:pool_size]).to match("130T") end - it "Should have the correct pool allocated size" do + it "has the correct pool allocated size" do @plugin.run expect(@plugin[:zpools][:rpool][:pool_allocated]).to match("66.2G") expect(@plugin[:zpools][:tank][:pool_allocated]).to match("4.91M") end - it "Should have the correct pool free size" do + it "has the correct pool free size" do @plugin.run expect(@plugin[:zpools][:rpool][:pool_free]).to match("42.8G") expect(@plugin[:zpools][:tank][:pool_free]).to match("130T") end - it "Should have the correct capacity_used" do + it "has the correct capacity_used" do @plugin.run expect(@plugin[:zpools][:rpool][:capacity_used]).to match("60%") expect(@plugin[:zpools][:tank][:capacity_used]).to match("0%") end - it "Should have the correct dedup_factor" do + it "has the correct dedup_factor" do @plugin.run expect(@plugin[:zpools][:rpool][:dedup_factor]).to match("1.00x") expect(@plugin[:zpools][:tank][:dedup_factor]).to match("1.00x") end - it "Should have the correct health" do + it "has the correct health" do @plugin.run expect(@plugin[:zpools][:rpool][:health]).to match("ONLINE") expect(@plugin[:zpools][:tank][:health]).to match("ONLINE") end - it "Should have the correct number of devices" do + it "has the correct number of devices" do @plugin.run expect(@plugin[:zpools][:rpool][:devices].keys.size).to match(2) expect(@plugin[:zpools][:tank][:devices].keys.size).to match(12) @@ -118,7 +118,7 @@ EOZO end describe "On OmniOS_151006" do - before(:each) do + before do @zpool_out = <<-EOZO rpool 109G 66.2G 42.8G 60% 1.00x ONLINE - tank 130T 4.91M 130T 0% 1.00x ONLINE - @@ -135,7 +135,7 @@ EOZO end describe "On Solaris_11.1" do - before(:each) do + before do @zpool_out = <<-EOZO rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34 tank 130T 4.91M 130T 0% 1.00x ONLINE 34 @@ -143,7 +143,7 @@ EOZO 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 + it "has a version number" do @plugin.run expect(@plugin[:zpools][:rpool][:zpool_version]).to match("34") expect(@plugin[:zpools][:tank][:zpool_version]).to match("34") diff --git a/spec/unit/plugins/ssh_host_keys_spec.rb b/spec/unit/plugins/ssh_host_keys_spec.rb index 7bdf90d8..381d3e1d 100644 --- a/spec/unit/plugins/ssh_host_keys_spec.rb +++ b/spec/unit/plugins/ssh_host_keys_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_he describe Ohai::System, "ssh_host_key plugin" do - before(:each) do + before do @plugin = get_plugin("ssh_host_key") @plugin[:keys] = Mash.new diff --git a/spec/unit/plugins/timezone_spec.rb b/spec/unit/plugins/timezone_spec.rb index 62fcb0ef..0953a096 100644 --- a/spec/unit/plugins/timezone_spec.rb +++ b/spec/unit/plugins/timezone_spec.rb @@ -18,12 +18,12 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "timezone plugin" do - before(:each) do + before do @plugin = get_plugin("timezone") allow(Time).to receive_message_chain(:now, :getlocal, :zone) { "ZZZ" } end - it "should get the local timezone" do + it "gets the local timezone" do @plugin.run expect(@plugin["time"]["timezone"]).to eq("ZZZ") end diff --git a/spec/unit/plugins/virtualbox_spec.rb b/spec/unit/plugins/virtualbox_spec.rb index 49e2268f..cb2d56b1 100644 --- a/spec/unit/plugins/virtualbox_spec.rb +++ b/spec/unit/plugins/virtualbox_spec.rb @@ -49,7 +49,7 @@ EOF describe Ohai::System, "plugin virtualbox" do context "when VBoxControl shellout fails" do - it "should not set the virtualbox attribute" do + it "does not set the virtualbox attribute" do plugin = get_plugin("virtualbox") allow(plugin).to receive(:shell_out).with("VBoxControl guestproperty enumerate").and_return(mock_shell_out(1, "", "")) plugin.run @@ -60,28 +60,28 @@ describe Ohai::System, "plugin virtualbox" do context "when VBoxControl shellout succeeds" do let(:plugin) { get_plugin("virtualbox") } - before(:each) do + before do allow(plugin).to receive(:shell_out).with("VBoxControl guestproperty enumerate").and_return(mock_shell_out(0, vbox_output, "")) plugin.run end - it "should set the host version" do + it "sets the host version" do expect(plugin[:virtualbox][:host][:version]).to eql("5.0.10") end - it "should set the host revision" do + it "sets the host revision" do expect(plugin[:virtualbox][:host][:revision]).to eql("104061") end - it "should set the host language" do + it "sets the host language" do expect(plugin[:virtualbox][:host][:language]).to eql("en_US") end - it "should set the guest additions version" do + it "sets the guest additions version" do expect(plugin[:virtualbox][:guest][:guest_additions_version]).to eql("5.0.2") end - it "should set the guest additions revision" do + it "sets the guest additions revision" do expect(plugin[:virtualbox][:guest][:guest_additions_revision]).to eql("102096") end end diff --git a/spec/unit/plugins/vmware_spec.rb b/spec/unit/plugins/vmware_spec.rb index bcaf17bf..6b793e9e 100644 --- a/spec/unit/plugins/vmware_spec.rb +++ b/spec/unit/plugins/vmware_spec.rb @@ -20,12 +20,12 @@ describe Ohai::System, "plugin vmware" do let(:plugin) { get_plugin("vmware") } let(:path) { "/usr/bin/vmware-toolbox-cmd" } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:linux) end context "on vmware guest with toolbox installed" do - before(:each) do + before do allow(File).to receive(:exist?).with("/usr/bin/vmware-toolbox-cmd").and_return(true) allow(plugin).to receive(:shell_out).with("#{path} stat speed").and_return(mock_shell_out(0, "2000 MHz", nil)) allow(plugin).to receive(:shell_out).with("#{path} stat hosttime").and_return(mock_shell_out(0, "04 Jun 2015 19:21:16", nil)) @@ -58,7 +58,7 @@ describe Ohai::System, "plugin vmware" do end context "on vmware guest without toolbox" do - it "should not create a vmware attribute" do + it "does not create a vmware attribute" do plugin[:virtualization] = Mash.new plugin[:virtualization][:systems] = Mash.new plugin[:virtualization][:systems][:vmware] = Mash.new @@ -68,7 +68,7 @@ describe Ohai::System, "plugin vmware" do end context "on vbox guest" do - it "should not create a vmware attribute" do + it "does not create a vmware attribute" do plugin[:virtualization] = Mash.new plugin[:virtualization][:systems] = Mash.new plugin[:virtualization][:systems][:vbox] = Mash.new diff --git a/spec/unit/plugins/windows/cpu_spec.rb b/spec/unit/plugins/windows/cpu_spec.rb index 313104bf..74d03573 100644 --- a/spec/unit/plugins/windows/cpu_spec.rb +++ b/spec/unit/plugins/windows/cpu_spec.rb @@ -24,39 +24,39 @@ shared_examples "a cpu" do |cpu_no| expect(@plugin[:cpu]["#{cpu_no}"][:physical_id]).to eq("CPU#{cpu_no}") end - it "should set mhz to 2793" do + it "sets mhz to 2793" do expect(@plugin[:cpu]["#{cpu_no}"][:mhz]).to eq("2793") end - it "should set vendor_id to GenuineIntel" do + it "sets vendor_id to GenuineIntel" do expect(@plugin[:cpu]["#{cpu_no}"][:vendor_id]).to eq("GenuineIntel") end - it "should set model_name to Intel64 Family 6 Model 70 Stepping 1" do + it "sets model_name to Intel64 Family 6 Model 70 Stepping 1" do expect(@plugin[:cpu]["#{cpu_no}"][:model_name]) .to eq("Intel64 Family 6 Model 70 Stepping 1") end - it "should set model to 17921" do + it "sets model to 17921" do expect(@plugin[:cpu]["#{cpu_no}"][:model]).to eq("17921") end - it "should set family to 2" do + it "sets family to 2" do expect(@plugin[:cpu]["#{cpu_no}"][:family]).to eq("2") end - it "should set stepping to 9" do + it "sets stepping to 9" do expect(@plugin[:cpu]["#{cpu_no}"][:stepping]).to eq(9) end - it "should set cache_size to 64 KB" do + it "sets cache_size to 64 KB" do expect(@plugin[:cpu]["#{cpu_no}"][:cache_size]).to eq("64 KB") end end end describe Ohai::System, "Windows cpu plugin" do - before(:each) do + before do @plugin = get_plugin("windows/cpu") allow(@plugin).to receive(:collect_os).and_return(:windows) @@ -94,15 +94,15 @@ describe Ohai::System, "Windows cpu plugin" do @plugin.run end - it "should set total cpu to 2" do + it "sets total cpu to 2" do expect(@plugin[:cpu][:total]).to eq(4) end - it "should set real cpu to 2" do + it "sets real cpu to 2" do expect(@plugin[:cpu][:real]).to eq(2) end - it "should set 2 distinct cpus numbered 0 and 1" do + it "sets 2 distinct cpus numbered 0 and 1" do expect(@plugin[:cpu]).to have_key("0") expect(@plugin[:cpu]).to have_key("1") end diff --git a/spec/unit/plugins/windows/fips_spec.rb b/spec/unit/plugins/windows/fips_spec.rb index 29138082..4aad7a40 100644 --- a/spec/unit/plugins/windows/fips_spec.rb +++ b/spec/unit/plugins/windows/fips_spec.rb @@ -24,7 +24,7 @@ describe Ohai::System, "plugin fips", :windows_only do let(:fips_key) { 'System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy' } let(:win_reg_entry) { { "Enabled" => enabled } } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:windows) allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with(fips_key, arch).and_yield(win_reg_entry) end diff --git a/spec/unit/plugins/windows/memory_spec.rb b/spec/unit/plugins/windows/memory_spec.rb index 0579439b..cd2a7c5a 100644 --- a/spec/unit/plugins/windows/memory_spec.rb +++ b/spec/unit/plugins/windows/memory_spec.rb @@ -29,22 +29,22 @@ describe Ohai::System, "Windows memory plugin", :windows_only do expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_OperatingSystem").and_return(mock_os) end - it "should get total memory" do + it "gets total memory" do @plugin.run expect(@plugin["memory"]["total"]).to eql("10485760kB") end - it "should get free memory" do + it "gets free memory" do @plugin.run expect(@plugin["memory"]["free"]).to eql("5242880kB") end - it "should get total swap" do + it "gets total swap" do @plugin.run expect(@plugin["memory"]["swap"]["total"]).to eql("20971520kB") end - it "should get free memory" do + it "gets free memory" do @plugin.run expect(@plugin["memory"]["swap"]["free"]).to eql("15728640kB") end diff --git a/spec/unit/plugins/windows/uptime_spec.rb b/spec/unit/plugins/windows/uptime_spec.rb index 05d2fd2f..73e560ae 100644 --- a/spec/unit/plugins/windows/uptime_spec.rb +++ b/spec/unit/plugins/windows/uptime_spec.rb @@ -22,7 +22,7 @@ describe Ohai::System, "Windows plugin uptime" do let(:wmi) { double("wmi", { :first_of => "" }) } - before(:each) do + before do allow(WmiLite::Wmi).to receive(:new).and_return(wmi) end @@ -49,8 +49,8 @@ describe Ohai::System, "Windows plugin uptime" do it "uses Win32_PerfFormattedData_PerfOS_System WMI class to fetch the system's uptime" do expect(wmi).to receive(:first_of).with("Win32_PerfFormattedData_PerfOS_System") - expect(Time).to_not receive(:new) - expect(Time).to_not receive(:parse) + expect(Time).not_to receive(:new) + expect(Time).not_to receive(:parse) expect(uptime_plugin).to receive(:seconds_to_human) uptime_plugin.run end diff --git a/spec/unit/plugins/windows/virtualization_spec.rb b/spec/unit/plugins/windows/virtualization_spec.rb index 124e92f6..7243c5c2 100644 --- a/spec/unit/plugins/windows/virtualization_spec.rb +++ b/spec/unit/plugins/windows/virtualization_spec.rb @@ -23,7 +23,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Windows virtualization platform" do let(:plugin) { get_plugin("windows/virtualization") } - before(:each) do + before do allow(plugin).to receive(:collect_os).and_return(:windows) end diff --git a/spec/unit/provides_map_spec.rb b/spec/unit/provides_map_spec.rb index 5a6eb1fe..0ca377da 100644 --- a/spec/unit/provides_map_spec.rb +++ b/spec/unit/provides_map_spec.rb @@ -22,7 +22,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb") describe Ohai::ProvidesMap do let(:ohai_system) { Ohai::System.new } - let(:provides_map) { Ohai::ProvidesMap.new } + let(:provides_map) { described_class.new } let(:plugin_1) { Ohai::DSL::Plugin.new(ohai_system.data) } let(:plugin_2) { Ohai::DSL::Plugin.new(ohai_system.data) } let(:plugin_3) { Ohai::DSL::Plugin.new(ohai_system.data) } @@ -30,13 +30,13 @@ describe Ohai::ProvidesMap do describe "when looking up providing plugins for a single attribute" do describe "when the attribute does not exist" do - it "should raise Ohai::Exceptions::AttributeNotFound error" do + it "raises Ohai::Exceptions::AttributeNotFound error" do expect { provides_map.find_providers_for(["single"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'single'") end end describe "when the attribute does not have a provider" do - it "should raise Ohai::Exceptions::ProviderNotFound error" do + it "raises Ohai::Exceptions::ProviderNotFound error" do provides_map.set_providers_for(plugin_1, ["first/second"]) expect { provides_map.find_providers_for(["first"]) }.to raise_error(Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: 'first'") end @@ -47,7 +47,7 @@ describe Ohai::ProvidesMap do provides_map.set_providers_for(plugin_1, ["single"]) end - it "should return the provider" do + it "returns the provider" do expect(provides_map.find_providers_for(["single"])).to eq([plugin_1]) end end @@ -58,7 +58,7 @@ describe Ohai::ProvidesMap do provides_map.set_providers_for(plugin_2, ["single"]) end - it "should return all providers" do + it "returns all providers" do expect(provides_map.find_providers_for(["single"])).to eq([plugin_1, plugin_2]) end end @@ -72,7 +72,7 @@ describe Ohai::ProvidesMap do provides_map.set_providers_for(plugin_2, ["two"]) end - it "should return each provider" do + it "returns each provider" do expect(provides_map.find_providers_for(%w{one two})).to eq([plugin_1, plugin_2]) end end @@ -84,7 +84,7 @@ describe Ohai::ProvidesMap do provides_map.set_providers_for(plugin_1, ["one_again"]) end - it "should return unique providers" do + it "returns unique providers" do expect(provides_map.find_providers_for(%w{one one_again})).to eq([plugin_1]) end end @@ -96,7 +96,7 @@ describe Ohai::ProvidesMap do provides_map.set_providers_for(plugin_1, ["top/middle/bottom"]) end - it "should collect the provider" do + it "collects the provider" do expect(provides_map.find_providers_for(["top/middle/bottom"])).to eq([plugin_1]) end end @@ -104,13 +104,13 @@ describe Ohai::ProvidesMap do describe "when setting multi-level attributes" do describe "when the attribute contains //" do - it "should raise an Ohai::Exceptions::AttributeSyntaxError" do + it "raises an Ohai::Exceptions::AttributeSyntaxError" do expect { provides_map.set_providers_for(plugin_1, ["this/plugin//is/bad"]) }.to raise_error(Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: this/plugin//is/bad") end end describe "when the attribute has a trailing slash" do - it "should raise an Ohai::Exceptions::AttributeSyntaxError" do + it "raises an Ohai::Exceptions::AttributeSyntaxError" do expect { provides_map.set_providers_for(plugin_1, ["this/plugin/is/bad/"]) }.to raise_error(Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': this/plugin/is/bad/") end end @@ -123,7 +123,7 @@ describe Ohai::ProvidesMap do provides_map.set_providers_for(plugin_3, ["cat/mouth/teeth"]) end - it "should find providers for subattributes if any exists when the attribute doesn't have a provider" do + it "finds providers for subattributes if any exists when the attribute doesn't have a provider" do providers = provides_map.deep_find_providers_for(["cat"]) expect(providers).to have(3).plugins expect(providers).to include(plugin_1) @@ -131,7 +131,7 @@ describe Ohai::ProvidesMap do expect(providers).to include(plugin_3) end - it "should find providers for the first parent attribute when the attribute or any subattributes doesn't have a provider" do + it "finds providers for the first parent attribute when the attribute or any subattributes doesn't have a provider" do providers = provides_map.deep_find_providers_for(["cat/paws/front"]) expect(providers).to eq([plugin_2]) end @@ -143,7 +143,7 @@ describe Ohai::ProvidesMap do provides_map.set_providers_for(plugin_1, ["do/not/eat/metal"]) end - it "should return the provider of the full attribute" do + it "returns the provider of the full attribute" do expect(provides_map.find_closest_providers_for(["do/not/eat/metal"])).to eql([plugin_1]) end end @@ -153,34 +153,34 @@ describe Ohai::ProvidesMap do provides_map.set_providers_for(plugin_1, ["do/not/eat"]) end - it "should not raise error if a parent attribute is provided" do + it "does not raise error if a parent attribute is provided" do expect { provides_map.find_closest_providers_for(["do/not/eat/plastic"]) }.not_to raise_error end - it "should return the providers of the closest parent attribute" do + it "returns the providers of the closest parent attribute" do provides_map.set_providers_for(plugin_2, ["do/not"]) # set a less-specific parent expect(provides_map.find_closest_providers_for(["do/not/eat/glass"])).to eql([plugin_1]) end - it "should raise error if the least-specific parent is not an attribute" do + it "raises error if the least-specific parent is not an attribute" do expect { provides_map.find_closest_providers_for(["please/eat/your/vegetables"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'please/eat/your/vegetables'") end - it "should raise error if no parent attribute has a provider" do + it "raises error if no parent attribute has a provider" do expect { provides_map.find_closest_providers_for(["do/not"]) }.to raise_error(Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: 'do/not'") end end end describe "when listing all plugins" do - before(:each) do + before do provides_map.set_providers_for(plugin_1, ["one"]) provides_map.set_providers_for(plugin_2, ["two"]) provides_map.set_providers_for(plugin_3, ["stub/three"]) provides_map.set_providers_for(plugin_4, ["foo/bar/four", "also/this/four"]) end - it "should find all the plugins providing attributes" do + it "finds all the plugins providing attributes" do all_plugins = provides_map.all_plugins expect(all_plugins).to have(4).plugins expect(all_plugins).to include(plugin_1) diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb index abbeecd3..6446cd52 100644 --- a/spec/unit/runner_spec.rb +++ b/spec/unit/runner_spec.rb @@ -22,13 +22,13 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb") describe Ohai::Runner, "run_plugin" do let(:safe_run) { true } - before(:each) do + before do @ohai = Ohai::System.new @runner = Ohai::Runner.new(@ohai, safe_run) end describe "when running an invalid plugin" do - it "should raise error" do + it "raises error" do expect { @runner.run_plugin(double("Ohai::NotPlugin")) }.to raise_error(Ohai::Exceptions::InvalidPlugin) end end @@ -39,7 +39,7 @@ describe Ohai::Runner, "run_plugin" do let(:has_run) { false } describe "version 7" do - it "should call run_v7_plugin" do + it "calls run_v7_plugin" do expect(@runner).to receive(:run_v7_plugin) @runner.run_plugin(plugin) end @@ -47,7 +47,7 @@ describe Ohai::Runner, "run_plugin" do describe "if the plugin has run before" do let(:has_run) { true } - it "should not run the plugin" do + it "does not run the plugin" do expect(plugin).not_to receive(:safe_run) @runner.run_plugin(plugin) end @@ -57,7 +57,7 @@ describe Ohai::Runner, "run_plugin" do describe "version 6" do let(:version) { :version6 } - it "should call run_v6_plugin" do + it "calls run_v6_plugin" do expect(@runner).to receive(:run_v6_plugin) @runner.run_plugin(plugin) end @@ -83,7 +83,7 @@ describe Ohai::Runner, "run_plugin" do describe "if the plugin has run before" do let(:has_run) { true } - it "should not run" do + it "does not run" do expect(plugin).not_to receive(:safe_run) @runner.run_plugin(plugin) end @@ -94,7 +94,7 @@ describe Ohai::Runner, "run_plugin" do describe "invalid version" do let(:version) { :versionBla } - it "should raise error" do + it "raises error" do expect { @runner.run_plugin(plugin) }.to raise_error(Ohai::Exceptions::InvalidPlugin) end end @@ -111,12 +111,12 @@ describe Ohai::Runner, "run_plugin" do klass.new(@ohai.data) end - it "should run the plugin" do + it "runs the plugin" do @runner.run_plugin(plugin) expect(plugin.has_run?).to be true end - it "should add plugin data to Ohai::System.data" do + it "adds plugin data to Ohai::System.data" do @runner.run_plugin(plugin) expect(@ohai.data).to have_key(:thing) expect(@ohai.data[:thing]).to eql({}) @@ -125,7 +125,7 @@ describe Ohai::Runner, "run_plugin" do describe "when running a plugin with one dependency" do describe "when the dependency does not exist" do - before(:each) do + before do klass = Ohai.plugin(:Test) do provides("thing") depends("other_thing") @@ -136,18 +136,18 @@ describe Ohai::Runner, "run_plugin" do @plugin = klass.new(@ohai.data) end - it "should raise Ohai::Excpetions::AttributeNotFound" do + it "raises Ohai::Excpetions::AttributeNotFound" do expect { @runner.run_plugin(@plugin) }.to raise_error(Ohai::Exceptions::AttributeNotFound) end - it "should not run the plugin" do + it "does not run the plugin" do expect { @runner.run_plugin(@plugin) }.to raise_error(Ohai::Exceptions::AttributeNotFound) expect(@plugin.has_run?).to be false end end describe "when the dependency has a single provider" do - before(:each) do + before do klass1 = Ohai.plugin(:Thing) do provides("thing") collect_data do @@ -171,7 +171,7 @@ describe Ohai::Runner, "run_plugin" do @ohai.provides_map.set_providers_for(@plugin1, ["thing"]) end - it "should run the plugins" do + it "runs the plugins" do @runner.run_plugin(@plugin2) @plugins.each do |plugin| expect(plugin.has_run?).to be true @@ -180,7 +180,7 @@ describe Ohai::Runner, "run_plugin" do end describe "when the dependency has multiple providers" do - before(:each) do + before do klass1 = Ohai.plugin(:Thing) do provides("thing") collect_data do @@ -205,7 +205,7 @@ describe Ohai::Runner, "run_plugin" do @ohai.provides_map.set_providers_for(@plugin2, ["thing"]) end - it "should run the plugins" do + it "runs the plugins" do @runner.run_plugin(@plugin3) @plugins.each do |plugin| expect(plugin.has_run?).to be true @@ -215,7 +215,7 @@ describe Ohai::Runner, "run_plugin" do end describe "when running a plugin with many dependencies" do - before(:each) do + before do @ohai = Ohai::System.new @runner = Ohai::Runner.new(@ohai, true) @@ -248,7 +248,7 @@ describe Ohai::Runner, "run_plugin" do @ohai.provides_map.set_providers_for(@plugin2, %w{one two}) end - it "should run the plugins" do + it "runs the plugins" do @runner.run_plugin(@plugin3) @plugins.each do |plugin| expect(plugin.has_run?).to be true @@ -281,7 +281,7 @@ describe Ohai::Runner, "run_plugin" do end context "when there is one edge in the cycle (A->B and B->A)" do - before(:each) do + before do klass1 = Ohai.plugin(:Thing) do provides("thing") depends("other") @@ -305,7 +305,7 @@ describe Ohai::Runner, "run_plugin" do @plugin1, @plugin2 = @plugins end - it "should raise Ohai::Exceptions::DependencyCycle" do + it "raises Ohai::Exceptions::DependencyCycle" do 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" @@ -315,7 +315,7 @@ describe Ohai::Runner, "run_plugin" do end describe "when A depends on B and C, and B depends on C" do - before(:each) do + before do @ohai = Ohai::System.new @runner = Ohai::Runner.new(@ohai, true) @@ -341,7 +341,7 @@ describe Ohai::Runner, "run_plugin" do @plugin_a, @plugin_b, @plugin_c = @plugins end - it "should not detect a cycle when B is the first provider returned" do + it "does not detect a cycle when B is the first provider returned" do @ohai.provides_map.set_providers_for(@plugin_a, ["A"]) @ohai.provides_map.set_providers_for(@plugin_b, ["B"]) @ohai.provides_map.set_providers_for(@plugin_c, ["C"]) @@ -354,7 +354,7 @@ describe Ohai::Runner, "run_plugin" do end end - it "should not detect a cycle when C is the first provider returned" do + it "does not detect a cycle when C is the first provider returned" do @ohai.provides_map.set_providers_for(@plugin_a, ["A"]) @ohai.provides_map.set_providers_for(@plugin_c, ["C"]) @ohai.provides_map.set_providers_for(@plugin_b, ["B"]) @@ -370,14 +370,14 @@ describe Ohai::Runner, "run_plugin" do end describe Ohai::Runner, "fetch_plugins" do - before(:each) do + before do @provides_map = Ohai::ProvidesMap.new @data = Mash.new @ohai = double("Ohai::System", :data => @data, :provides_map => @provides_map) @runner = Ohai::Runner.new(@ohai, true) end - it "should collect the provider" do + it "collects the provider" do plugin = Ohai::DSL::Plugin.new(@ohai.data) @ohai.provides_map.set_providers_for(plugin, ["top/middle/bottom"]) @@ -387,7 +387,7 @@ describe Ohai::Runner, "fetch_plugins" do describe "when the attribute is not provided by any plugin" do describe "and some parent attribute has providers" do - it "should return the providers for the parent" do + it "returns the providers for the parent" do plugin = Ohai::DSL::Plugin.new(@ohai.data) @provides_map.set_providers_for(plugin, ["test/attribute"]) expect(@runner.fetch_plugins(["test/attribute/too_far"])).to eql([plugin]) @@ -395,14 +395,14 @@ describe Ohai::Runner, "fetch_plugins" do end describe "and no parent attribute has providers" do - it "should raise Ohai::Exceptions::AttributeNotFound exception" do + it "raises Ohai::Exceptions::AttributeNotFound exception" do # provides map is empty expect { @runner.fetch_plugins(["false/attribute"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'false/attribute'") end end end - it "should return unique providers" do + it "returns unique providers" do plugin = Ohai::DSL::Plugin.new(@ohai.data) @provides_map.set_providers_for(plugin, ["test", "test/too_far/way_too_far"]) expect(@runner.fetch_plugins(["test", "test/too_far/way_too_far"])).to eql([plugin]) @@ -410,7 +410,7 @@ describe Ohai::Runner, "fetch_plugins" do end describe Ohai::Runner, "#get_cycle" do - before(:each) do + before do @ohai = Ohai::System.new @runner = Ohai::Runner.new(@ohai, true) @@ -443,7 +443,7 @@ describe Ohai::Runner, "#get_cycle" do @plugin1, @plugin2, @plugin3 = plugins end - it "should return the sources for the plugins in the cycle, when given an exact cycle" do + it "returns the sources for the plugins in the cycle, when given an exact cycle" do cycle = [@plugin1, @plugin2] cycle_start = @plugin1 @@ -451,7 +451,7 @@ describe Ohai::Runner, "#get_cycle" do 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 + it "returns the sources for only the plugins in the cycle, when there are plugins before the cycle begins" do cycle = [@plugin3, @plugin1, @plugin2] cycle_start = @plugin1 diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb index 0144ff61..af72816e 100644 --- a/spec/unit/system_spec.rb +++ b/spec/unit/system_spec.rb @@ -194,7 +194,7 @@ provides 'park' park("plants") EOF - it "should collect data from all the plugins" do + it "collects data from all the plugins" do Ohai.config[:plugin_path] = [ path_to(".") ] ohai.all_plugins expect(ohai.data[:zoo]).to eq("animals") @@ -210,7 +210,7 @@ EOF Ohai.config[:disabled_plugins] = [ ] end - it "shouldn't run disabled version 6 plugins" do + it "does not run disabled version 6 plugins" do Ohai.config[:plugin_path] = [ path_to(".") ] ohai.all_plugins expect(ohai.data[:zoo]).to be_nil @@ -313,7 +313,7 @@ Ohai.plugin(:Message) do end EOF - it "should collect platform specific" do + it "collects platform specific" do Ohai.config[:plugin_path] = [ path_to(".") ] ohai.all_plugins expect(ohai.data[:message]).to eq("platform_specific_message") @@ -340,14 +340,14 @@ Ohai.plugin(:Park) do end EOF - it "should collect data from all the plugins" do + it "collects data from all the plugins" do Ohai.config[:plugin_path] = [ path_to(".") ] ohai.all_plugins expect(ohai.data[:zoo]).to eq("animals") expect(ohai.data[:park]).to eq("plants") end - it "should write an error to Ohai::Log" do + it "writes 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 allow(ohai).to receive(:reset_system) @@ -365,7 +365,7 @@ EOF Ohai.config[:disabled_plugins] = [ ] end - it "shouldn't run disabled plugins" do + it "does not run disabled plugins" do Ohai.config[:plugin_path] = [ path_to(".") ] ohai.all_plugins expect(ohai.data[:zoo]).to be_nil @@ -414,7 +414,7 @@ EOF Ohai.config[:disabled_plugins] = [ ] end - it "shouldn't run disabled plugins" do + it "does not run disabled plugins" do Ohai.config[:plugin_path] = [ path_to(".") ] ohai.all_plugins expect(ohai.data[:zoo]).to be_nil @@ -456,7 +456,7 @@ EOF Ohai.config[:plugin_path] = [ path_to(".") ] end - it "should collect all data" do + it "collects all data" do ohai.all_plugins [:v6message, :v7message, :messages].each do |attribute| expect(ohai.data).to have_key(attribute) @@ -537,7 +537,7 @@ EOF Ohai.config[:plugin_path] = [ path_to(".") ] end - it "should collect all the data properly" do + it "collects all the data properly" do ohai.all_plugins expect(ohai.data[:v7message]).to eq("Hellos from 7: animals") expect(ohai.data[:zoo]).to eq("animals") @@ -559,7 +559,7 @@ EOF Ohai.config[:plugin_path] = [ path_to(".") ] end - it "should raise DependencyNotFound" do + it "raises DependencyNotFound" do expect { ohai.all_plugins }.to raise_error(Ohai::Exceptions::DependencyNotFound) end end @@ -599,7 +599,7 @@ EOF Ohai.config[:plugin_path] = [ path_to(".") ] end - it "should rerun the plugin providing the desired attributes" do + it "reruns the plugin providing the desired attributes" do ohai.all_plugins initial_value = ohai.data["random"] ohai.all_plugins @@ -656,19 +656,19 @@ EOF ohai.all_plugins end - it "should rerun the plugin providing the desired attributes" do + it "reruns the plugin providing the desired attributes" do expect(ohai.data[:desired_attr_count]).to eq(1) ohai.refresh_plugins("desired_attr") expect(ohai.data[:desired_attr_count]).to eq(2) end - it "should not re-run dependencies of the plugin providing the desired attributes" do + it "does not re-run dependencies of the plugin providing the desired attributes" do expect(ohai.data[:depended_attr_count]).to eq(1) ohai.refresh_plugins("desired_attr") 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 + it "does not re-run plugins unrelated to the plugin providing the desired attributes" do expect(ohai.data[:other_attr_count]).to eq(1) ohai.refresh_plugins("desired_attr") expect(ohai.data[:other_attr_count]).to eq(1) @@ -719,19 +719,19 @@ EOF Ohai.config[:plugin_path] = [ path_to(".") ] end - it "should run all the plugins when a top level attribute is specified" do + it "runs all the plugins when a top level attribute is specified" do ohai.all_plugins("languages") 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 + it "runs the first parent when a non-existent child is specified" do ohai.all_plugins("languages/english/version") 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 + it "is able to run multiple plugins" do ohai.all_plugins(["languages/english", "languages/french"]) expect(ohai.data[:languages][:english][:version]).to eq(2014) expect(ohai.data[:languages][:french][:version]).to eq(2012) diff --git a/spec/unit/util/file_helper_spec.rb b/spec/unit/util/file_helper_spec.rb index f6c91cb1..259d4a22 100644 --- a/spec/unit/util/file_helper_spec.rb +++ b/spec/unit/util/file_helper_spec.rb @@ -26,7 +26,7 @@ end describe "Ohai::Util::FileHelper" do let(:file_helper) { FileHelperMock.new } - before(:each) do + before do allow(file_helper).to receive(:name).and_return("Fakeclass") allow(File).to receive(:executable?).and_return(false) end diff --git a/spec/unit/util/ip_helper_spec.rb b/spec/unit/util/ip_helper_spec.rb index 0532cbc9..ec9b37ba 100644 --- a/spec/unit/util/ip_helper_spec.rb +++ b/spec/unit/util/ip_helper_spec.rb @@ -78,12 +78,12 @@ describe "Ohai::Util::IpHelper" do allow(ip_helper).to receive(:private_address?) end - it "should call #private_address?" do + it "calls #private_address?" do expect(ip_helper).to receive(:private_address?) ip_helper.public_address?(address) end - it "should return the inverse of #private_address?" do + it "returns the inverse of #private_address?" do expect(ip_helper.public_address?(address)).to equal !ip_helper.private_address?(address) end end @@ -93,7 +93,7 @@ describe "Ohai::Util::IpHelper" do context "that is a loopback address" do let(:address) { "127.0.0.1" } - it "should identify the address as a loopback address" do + it "identifies the address as a loopback address" do expect(ip_helper.loopback?(address)).to be_truthy end end @@ -101,7 +101,7 @@ describe "Ohai::Util::IpHelper" do context "that is not a loopback address" do let(:address) { "1.2.3.4" } - it "should not identify the address as a loopback address" do + it "does not identify the address as a loopback address" do expect(ip_helper.loopback?(address)).to be_falsey end end @@ -111,7 +111,7 @@ describe "Ohai::Util::IpHelper" do context "that is a loopback address" do let(:address) { "0:0:0:0:0:0:0:1" } - it "should identify the address as a loopback address" do + it "identifies the address as a loopback address" do expect(ip_helper.loopback?(address)).to be_truthy end end @@ -119,7 +119,7 @@ describe "Ohai::Util::IpHelper" do context "that is not a loopback address" do let(:address) { "2400:6180:0000:00D0:0000:0000:0009:7001" } - it "should not identify the address as a loopback address" do + it "does not identify the address as a loopback address" do expect(ip_helper.loopback?(address)).to be_falsey end end |