diff options
author | mcquin <claire@chef.io> | 2016-04-01 10:19:13 -0700 |
---|---|---|
committer | mcquin <claire@chef.io> | 2016-04-01 10:24:43 -0700 |
commit | f81c4518ff4ab37e8f5ccade4e395b8552c9480b (patch) | |
tree | ee1822317f725f24a9cf62445d06c971c695e647 | |
parent | 8c0431684f1fa7bdd6a3806894c740e735929795 (diff) | |
download | ohai-shellout-log-and-timeout.tar.gz |
rubocop fixesshellout-log-and-timeout
-rw-r--r-- | spec/unit/mixin/command_spec.rb | 24 | ||||
-rw-r--r-- | spec/unit/plugins/rackspace_spec.rb | 22 |
2 files changed, 23 insertions, 23 deletions
diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb index 7a326820..14a91405 100644 --- a/spec/unit/mixin/command_spec.rb +++ b/spec/unit/mixin/command_spec.rb @@ -30,7 +30,7 @@ describe Ohai::Mixin::Command, "popen4" do end it "should respect locale when specified explicitly" do - Ohai::Mixin::Command.popen4("echo $LC_ALL", :environment => { "LC_ALL" => "es" }) do |pid, stdin, stdout, stderr| + 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") end @@ -52,14 +52,14 @@ describe Ohai::Mixin::Command, "popen4" do it "should force encode the string to UTF-8" do extend Ohai::Mixin::Command - snowy = run_command(:command => ("echo "" + ("☃" * 8096) + """))[1] + snowy = 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 extend Ohai::Mixin::Command - snowy = run_command(:command => ("echo "" + ("☃" * 8096) + """))[1] + snowy = run_command(:command => ("echo '" + ("☃" * 8096) + "'"))[1] expect(snowy.encoding).to eq(Encoding::UTF_8) end end @@ -72,7 +72,7 @@ describe Ohai::Mixin::Command, "popen4" do created_procs = 0 100.times do begin - Ohai::Mixin::Command.popen4("/bin/this-is-not-a-real-command") { |p, i, o, e| nil } + Ohai::Mixin::Command.popen4("/bin/this-is-not-a-real-command") { |p, i, o, e| nil } rescue Ohai::Exceptions::Exec created_procs += 1 end @@ -80,7 +80,7 @@ describe Ohai::Mixin::Command, "popen4" do expect(created_procs).to eq(100) reaped_procs = 0 begin - loop { Process.wait(-1); reaped_procs += 1 } + loop { Process.wait(-1); reaped_procs += 1 } rescue Errno::ECHILD end expect(reaped_procs).to eq(0) @@ -88,11 +88,11 @@ describe Ohai::Mixin::Command, "popen4" do end describe Ohai::Mixin::Command, "shell_out" do - let(:cmd) { 'sparkle-dream --version' } + let(:cmd) { "sparkle-dream --version" } - let(:shell_out) { double("Mixlib::ShellOut") } + let(:shell_out) { double("Mixlib::ShellOut") } - let(:plugin_name) { :OSSparkleDream } + let(:plugin_name) { :OSSparkleDream } before(:each) do allow(Ohai::Mixin::Command).to receive(:name).and_return(plugin_name) @@ -135,7 +135,7 @@ describe Ohai::Mixin::Command, "shell_out" do with("Plugin OSSparkleDream ran 'sparkle-dream --version' and failed " \ "#<Errno::ENOENT: No such file or directory - sparkle-dream>") - expect{ Ohai::Mixin::Command.shell_out(cmd) }. + expect { Ohai::Mixin::Command.shell_out(cmd) }. to raise_error(Ohai::Exceptions::Exec) end end @@ -156,13 +156,13 @@ describe Ohai::Mixin::Command, "shell_out" do with("Plugin OSSparkleDream ran 'sparkle-dream --version' and timed " \ "out after 30 seconds") - expect{ Ohai::Mixin::Command.shell_out(cmd) }. + expect { Ohai::Mixin::Command.shell_out(cmd) }. to raise_error(Ohai::Exceptions::Exec) end end describe "when a timeout option is provided" do - let(:options) { {timeout: 10} } + let(:options) { { timeout: 10 } } it "runs the command with the provided timeout" do expect(Mixlib::ShellOut). @@ -199,7 +199,7 @@ describe Ohai::Mixin::Command, "shell_out" do with("Plugin OSSparkleDream ran 'sparkle-dream --version' and timed " \ "out after 10 seconds") - expect{ Ohai::Mixin::Command.shell_out(cmd, options) }. + expect { Ohai::Mixin::Command.shell_out(cmd, options) }. to raise_error(Ohai::Exceptions::Exec) end end diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb index f8b64b95..5678dccb 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -47,11 +47,11 @@ describe Ohai::System, "plugin rackspace" do "family" => "inet6", }, "40:40:95:47:6E:ED" => { - "family" => "lladdr" - } - } - } - } + "family" => "lladdr", + }, + }, + }, + }, } plugin[:network][:interfaces][:eth1] = { @@ -67,9 +67,9 @@ describe Ohai::System, "plugin rackspace" do "family" => "inet", }, "40:40:F5:AB:28:36" => { - "family" => "lladdr" - } - } + "family" => "lladdr", + }, + }, } # In olden days we could detect rackspace by a -rscloud suffix on the kernel @@ -332,9 +332,9 @@ OUT "family" => "inet", }, "BC:76:4E:20:42:2B" => { - "family" => "lladdr" - } - } + "family" => "lladdr", + }, + }, } stdout = 'BC764E20422B = "{"label": "private-network"}"\n' allow(plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" )) |