summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-07-15 12:09:57 -0700
committeradamedx <adamed@opscode.com>2013-08-19 11:51:16 -0700
commit990ed7c49d4d94cb759a0ddb1c2532c06c513cd5 (patch)
tree0f2fdaf38aa819d5200cc0aaf812ff536d374ee6
parentdd73d9ffa3a68430886c82c1effc79fc15feac54 (diff)
downloadohai-990ed7c49d4d94cb759a0ddb1c2532c06c513cd5.tar.gz
replace all calls to `mock` with `double`
`mock` is deprecated in RSpec 2.14.x
-rw-r--r--spec/unit/mixin/ec2_metadata_spec.rb14
-rw-r--r--spec/unit/plugins/darwin/platform_spec.rb12
-rw-r--r--spec/unit/plugins/dmi_spec.rb4
-rw-r--r--spec/unit/plugins/ec2_spec.rb52
-rw-r--r--spec/unit/plugins/eucalyptus_spec.rb16
-rw-r--r--spec/unit/plugins/gce_spec.rb16
-rw-r--r--spec/unit/plugins/linux/cpu_spec.rb6
-rw-r--r--spec/unit/plugins/linux/filesystem_spec.rb38
-rw-r--r--spec/unit/plugins/linux/lsb_spec.rb12
-rw-r--r--spec/unit/plugins/linux/uptime_spec.rb4
-rw-r--r--spec/unit/plugins/linux/virtualization_spec.rb6
-rw-r--r--spec/unit/plugins/sigar/network_route_spec.rb4
-rw-r--r--spec/unit/plugins/solaris2/network_spec.rb4
-rw-r--r--spec/unit/plugins/solaris2/platform_spec.rb4
-rw-r--r--spec/unit/plugins/solaris2/virtualization_spec.rb12
15 files changed, 102 insertions, 102 deletions
diff --git a/spec/unit/mixin/ec2_metadata_spec.rb b/spec/unit/mixin/ec2_metadata_spec.rb
index b3f21087..1f5a65a2 100644
--- a/spec/unit/mixin/ec2_metadata_spec.rb
+++ b/spec/unit/mixin/ec2_metadata_spec.rb
@@ -22,7 +22,7 @@ require 'ohai/mixin/ec2_metadata'
describe Ohai::Mixin::Ec2Metadata do
let(:mixin) {
metadata_object = Object.new.extend(Ohai::Mixin::Ec2Metadata)
- http_client = mock("Net::HTTP client")
+ http_client = double("Net::HTTP client")
http_client.stub(:get).and_return(response)
metadata_object.stub(:http_client).and_return(http_client)
metadata_object
@@ -30,7 +30,7 @@ describe Ohai::Mixin::Ec2Metadata do
context "#best_api_version" do
context "with a sorted list of metadata versions" do
- let(:response) { mock("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "200") }
+ let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "200") }
it "returns the most recent version" do
mixin.best_api_version.should == "2012-01-12"
@@ -38,7 +38,7 @@ describe Ohai::Mixin::Ec2Metadata do
end
context "with an unsorted list of metadata versions" do
- let(:response) { mock("Net::HTTP Response", :body => "1.0\n2009-04-04\n2007-03-01\n2011-05-01\n2008-09-01\nUnsupported", :code => "200") }
+ let(:response) { double("Net::HTTP Response", :body => "1.0\n2009-04-04\n2007-03-01\n2011-05-01\n2008-09-01\nUnsupported", :code => "200") }
it "returns the most recent version (using string sort)" do
mixin.best_api_version.should == "2011-05-01"
@@ -46,7 +46,7 @@ describe Ohai::Mixin::Ec2Metadata do
end
context "when no supported versions are found" do
- let(:response) { mock("Net::HTTP Response", :body => "2020-01-01\nUnsupported", :code => "200") }
+ let(:response) { double("Net::HTTP Response", :body => "2020-01-01\nUnsupported", :code => "200") }
it "raises an error" do
lambda { mixin.best_api_version}.should raise_error
@@ -54,7 +54,7 @@ describe Ohai::Mixin::Ec2Metadata do
end
context "when the response code is 404" do
- let(:response) { mock("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "404") }
+ let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "404") }
it "raises an error" do
lambda { mixin.best_api_version}.should raise_error
@@ -62,7 +62,7 @@ describe Ohai::Mixin::Ec2Metadata do
end
context "when the response code is unexpected" do
- let(:response) { mock("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "418") }
+ let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "418") }
it "raises an error" do
lambda { mixin.best_api_version}.should raise_error
@@ -72,7 +72,7 @@ describe Ohai::Mixin::Ec2Metadata do
context "#metadata_get" do
context "when the response code is unexpected" do
- let(:response) { mock("Net::HTTP Response", :body => "", :code => "418") }
+ let(:response) { double("Net::HTTP Response", :body => "", :code => "418") }
it "raises an error" do
lambda { mixin.metadata_get('', '2012-01-12') }.should raise_error(RuntimeError)
diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb
index 460c1ce7..f98b4cf5 100644
--- a/spec/unit/plugins/darwin/platform_spec.rb
+++ b/spec/unit/plugins/darwin/platform_spec.rb
@@ -26,13 +26,13 @@ describe Ohai::System, "Darwin plugin platform" do
@plugin.stub(:require_plugin).and_return(true)
@plugin[:os] = "darwin"
@pid = 10
- @stdin = mock("STDIN", { :close => true })
- @stdout = mock("STDOUT")
+ @stdin = double("STDIN", { :close => true })
+ @stdout = double("STDOUT")
@stdout.stub(:each).
and_yield("ProductName: Mac OS X").
and_yield("ProductVersion: 10.5.5").
and_yield("BuildVersion: 9F33")
- @stderr = mock("STDERR")
+ @stderr = double("STDERR")
@plugin.stub(:popen4).with("/usr/bin/sw_vers").and_yield(@pid, @stdin, @stdout, @stderr)
end
@@ -76,13 +76,13 @@ describe Ohai::System, "Darwin plugin platform" do
@plugin.stub(:require_plugin).and_return(true)
@plugin[:os] = "darwin"
@pid = 10
- @stdin = mock("STDIN", { :close => true })
- @stdout = mock("STDOUT")
+ @stdin = double("STDIN", { :close => true })
+ @stdout = double("STDOUT")
@stdout.stub(:each).
and_yield("ProductName: Mac OS X Server").
and_yield("ProductVersion: 10.6.8").
and_yield("BuildVersion: 10K549")
- @stderr = mock("STDERR")
+ @stderr = double("STDERR")
@plugin.stub(:popen4).with("/usr/bin/sw_vers").and_yield(@pid, @stdin, @stdout, @stderr)
end
diff --git a/spec/unit/plugins/dmi_spec.rb b/spec/unit/plugins/dmi_spec.rb
index 73d689a5..8f233d72 100644
--- a/spec/unit/plugins/dmi_spec.rb
+++ b/spec/unit/plugins/dmi_spec.rb
@@ -96,9 +96,9 @@ describe Ohai::System, "plugin dmi" do
@ohai = Ohai::System.new
@plugin = Ohai::DSL::Plugin.new(@ohai, File.join(PLUGIN_PATH, "dmi.rb"))
@plugin.stub(:require_plugin).and_return(true)
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
+ @stderr = double("STDERR")
@stdout = StringIO.new(DMI_OUT)
@status = 0
@plugin.stub(:popen4).with("dmidecode").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb
index f78d1ffe..ae018f0e 100644
--- a/spec/unit/plugins/ec2_spec.rb
+++ b/spec/unit/plugins/ec2_spec.rb
@@ -37,33 +37,33 @@ describe Ohai::System, "plugin ec2" do
shared_examples_for "ec2" do
before(:each) do
- @http_client = mock("Net::HTTP client")
+ @http_client = double("Net::HTTP client")
@plugin.stub(:http_client).and_return(@http_client)
IO.stub(:select).and_return([[],[1],[]])
- t = mock("connection")
+ t = double("connection")
t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
Socket.stub(:new).and_return(t)
@http_client.should_receive(:get).
with("/").twice.
- and_return(mock("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
end
it "should recursively fetch all the ec2 metadata" do
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/").
- and_return(mock("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/instance_type").
- and_return(mock("Net::HTTP Response", :body => "c1.medium", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "c1.medium", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/ami_id").
- and_return(mock("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/security-groups").
- and_return(mock("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/user-data/").
- and_return(mock("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
@plugin[:ec2].should_not be_nil
@@ -75,25 +75,25 @@ describe Ohai::System, "plugin ec2" do
it "should parse ec2 network/ directory as a multi-level hash" do
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/").
- and_return(mock("Net::HTTP Response", :body => "network/", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "network/", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/network/").
- and_return(mock("Net::HTTP Response", :body => "interfaces/", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "interfaces/", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/network/interfaces/").
- and_return(mock("Net::HTTP Response", :body => "macs/", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "macs/", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/network/interfaces/macs/").
- and_return(mock("Net::HTTP Response", :body => "12:34:56:78:9a:bc/", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "12:34:56:78:9a:bc/", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/network/interfaces/macs/12:34:56:78:9a:bc/").
- and_return(mock("Net::HTTP Response", :body => "public_hostname", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "public_hostname", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/network/interfaces/macs/12:34:56:78:9a:bc/public_hostname").
- and_return(mock("Net::HTTP Response", :body => "server17.opscode.com", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "server17.opscode.com", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/user-data/").
- and_return(mock("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
@plugin[:ec2].should_not be_nil
@@ -103,19 +103,19 @@ describe Ohai::System, "plugin ec2" do
it "should parse ec2 iam/ directory and its JSON files properly" do
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/").
- and_return(mock("Net::HTTP Response", :body => "iam/", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "iam/", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/iam/").
- and_return(mock("Net::HTTP Response", :body => "security-credentials/", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "security-credentials/", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/iam/security-credentials/").
- and_return(mock("Net::HTTP Response", :body => "MyRole", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "MyRole", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/iam/security-credentials/MyRole").
- and_return(mock("Net::HTTP Response", :body => "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "{\n \"Code\" : \"Success\",\n \"LastUpdated\" : \"2012-08-22T07:47:22Z\",\n \"Type\" : \"AWS-HMAC\",\n \"AccessKeyId\" : \"AAAAAAAA\",\n \"SecretAccessKey\" : \"SSSSSSSS\",\n \"Token\" : \"12345678\",\n \"Expiration\" : \"2012-08-22T11:25:52Z\"\n}", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/user-data/").
- and_return(mock("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
@plugin[:ec2].should_not be_nil
@@ -126,7 +126,7 @@ describe Ohai::System, "plugin ec2" do
it "should ignore \"./\" and \"../\" on ec2 metadata paths to avoid infinity loops" do
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/").
- and_return(mock("Net::HTTP Response", :body => ".\n./\n..\n../\npath1/.\npath2/./\npath3/..\npath4/../", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => ".\n./\n..\n../\npath1/.\npath2/./\npath3/..\npath4/../", :code => "200"))
@http_client.should_not_receive(:get).
with("/2012-01-12/meta-data/.")
@@ -141,19 +141,19 @@ describe Ohai::System, "plugin ec2" do
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/path1/").
- and_return(mock("Net::HTTP Response", :body => "", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/path2/").
- and_return(mock("Net::HTTP Response", :body => "", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/path3/").
- and_return(mock("Net::HTTP Response", :body => "", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/path4/").
- and_return(mock("Net::HTTP Response", :body => "", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/user-data/").
- and_return(mock("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@plugin.run
diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb
index 2b2944cd..310f0990 100644
--- a/spec/unit/plugins/eucalyptus_spec.rb
+++ b/spec/unit/plugins/eucalyptus_spec.rb
@@ -36,32 +36,32 @@ describe Ohai::System, "plugin eucalyptus" do
shared_examples_for "eucalyptus" do
before(:each) do
- @http_client = mock("Net::HTTP client")
+ @http_client = double("Net::HTTP client")
@plugin.stub(:http_client).and_return(@http_client)
@http_client.should_receive(:get).
with("/").twice.
- and_return(mock("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/").
- and_return(mock("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/instance_type").
- and_return(mock("Net::HTTP Response", :body => "c1.medium", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "c1.medium", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/ami_id").
- and_return(mock("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/meta-data/security-groups").
- and_return(mock("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
@http_client.should_receive(:get).
with("/2012-01-12/user-data/").
- and_return(mock("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
+ and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
end
it "should recursively fetch all the eucalyptus metadata" do
IO.stub(:select).and_return([[],[1],[]])
- t = mock("connection")
+ t = double("connection")
t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
Socket.stub(:new).and_return(t)
@plugin.run
diff --git a/spec/unit/plugins/gce_spec.rb b/spec/unit/plugins/gce_spec.rb
index 7cab041a..64eb58ec 100644
--- a/spec/unit/plugins/gce_spec.rb
+++ b/spec/unit/plugins/gce_spec.rb
@@ -34,10 +34,10 @@ describe Ohai::System, "plugin gce" do
shared_examples_for "gce" do
before(:each) do
- @http_client = mock("Net::HTTP client")
+ @http_client = double("Net::HTTP client")
@plugin.stub(:http_client).and_return(@http_client)
IO.stub(:select).and_return([[],[1],[]])
- t = mock("connection")
+ t = double("connection")
t.stub(:connect_nonblock).and_raise(Errno::EINPROGRESS)
Socket.stub(:new).and_return(t)
Socket.stub(:pack_sockaddr_in).and_return(nil)
@@ -46,17 +46,17 @@ describe Ohai::System, "plugin gce" do
it "should recursively fetch metadata" do
@http_client.should_receive(:get).
with("/0.1/meta-data/").
- and_return(mock("Net::HTTPOK",
+ and_return(double("Net::HTTPOK",
:body => "domain\nhostname\ndescription", :code=>"200"))
@http_client.should_receive(:get).
with("/0.1/meta-data/domain").
- and_return(mock("Net::HTTPOK", :body => "test-domain", :code=>"200"))
+ and_return(double("Net::HTTPOK", :body => "test-domain", :code=>"200"))
@http_client.should_receive(:get).
with("/0.1/meta-data/hostname").
- and_return(mock("Net::HTTPOK", :body => "test-host", :code=>"200"))
+ and_return(double("Net::HTTPOK", :body => "test-host", :code=>"200"))
@http_client.should_receive(:get).
with("/0.1/meta-data/description").
- and_return(mock("Net::HTTPOK", :body => "test-description", :code=>"200"))
+ and_return(double("Net::HTTPOK", :body => "test-description", :code=>"200"))
@plugin.run
@@ -69,10 +69,10 @@ describe Ohai::System, "plugin gce" do
it "should properly parse json metadata" do
@http_client.should_receive(:get).
with("/0.1/meta-data/").
- and_return(mock("Net::HTTP Response", :body => "attached-disks\n", :code=>"200"))
+ and_return(double("Net::HTTP Response", :body => "attached-disks\n", :code=>"200"))
@http_client.should_receive(:get).
with("/0.1/meta-data/attached-disks").
- and_return(mock("Net::HTTP Response", :body => '{"disks":[{"deviceName":"boot",
+ and_return(double("Net::HTTP Response", :body => '{"disks":[{"deviceName":"boot",
"index":0,"mode":"READ_WRITE","type":"EPHEMERAL"}]}', :code=>"200"))
@plugin.run
diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb
index 0aff9572..74a6d60a 100644
--- a/spec/unit/plugins/linux/cpu_spec.rb
+++ b/spec/unit/plugins/linux/cpu_spec.rb
@@ -25,8 +25,8 @@ describe Ohai::System, "Linux cpu plugin" do
@plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/cpu.rb", PLUGIN_PATH))
@plugin.stub(:require_plugin).and_return(true)
@plugin[:os] = "linux"
- @mock_file = mock("/proc/cpuinfo")
- @mock_file.stub(:each).
+ @double_file = double("/proc/cpuinfo")
+ @double_file.stub(:each).
and_yield("processor : 0").
and_yield("vendor_id : GenuineIntel").
and_yield("cpu family : 6").
@@ -46,7 +46,7 @@ describe Ohai::System, "Linux cpu plugin" do
and_yield("flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov").
and_yield("bogomips : 2575.86").
and_yield("clflush size : 32")
- File.stub(:open).with("/proc/cpuinfo").and_return(@mock_file)
+ File.stub(:open).with("/proc/cpuinfo").and_return(@double_file)
end
it "should set cpu[:total] to 1" do
diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb
index f5a9d1a5..e424174a 100644
--- a/spec/unit/plugins/linux/filesystem_spec.rb
+++ b/spec/unit/plugins/linux/filesystem_spec.rb
@@ -37,10 +37,10 @@ describe Ohai::System, "Linux filesystem plugin" do
describe "when gathering filesystem usage data from df" do
before(:each) do
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
@stdout.stub(:each).
@@ -95,10 +95,10 @@ describe Ohai::System, "Linux filesystem plugin" do
describe "when gathering mounted filesystem data from mount" do
before(:each) do
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
@stdout.stub(:each).
@@ -145,10 +145,10 @@ describe Ohai::System, "Linux filesystem plugin" do
describe "when gathering filesystem type data from blkid" do
before(:each) do
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
@stdout.stub(:each).
@@ -180,10 +180,10 @@ describe Ohai::System, "Linux filesystem plugin" do
describe "when gathering filesystem uuid data from blkid" do
before(:each) do
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
@stdout.stub(:each).
@@ -215,10 +215,10 @@ describe Ohai::System, "Linux filesystem plugin" do
describe "when gathering filesystem label data from blkid" do
before(:each) do
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
@stdout.stub(:each).
@@ -249,9 +249,9 @@ describe Ohai::System, "Linux filesystem plugin" do
describe "when gathering data from /proc/mounts" do
before(:each) do
File.stub(:exists?).with("/proc/mounts").and_return(true)
- @mock_file = mock("/proc/mounts")
- @mock_file.stub(:read_nonblock).and_return(@mock_file)
- @mock_file.stub(:each_line).
+ @double_file = double("/proc/mounts")
+ @double_file.stub(:read_nonblock).and_return(@double_file)
+ @double_file.stub(:each_line).
and_yield("rootfs / rootfs rw 0 0").
and_yield("none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0").
and_yield("none /proc proc rw,nosuid,nodev,noexec,relatime 0 0").
@@ -268,7 +268,7 @@ describe Ohai::System, "Linux filesystem plugin" do
and_yield("/dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0").
and_yield("fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0").
and_yield("binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0")
- File.stub(:open).with("/proc/mounts").and_return(@mock_file)
+ File.stub(:open).with("/proc/mounts").and_return(@double_file)
end
it "should set mount to value from /proc/mounts" do
diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb
index 869e5cd5..8f2646c7 100644
--- a/spec/unit/plugins/linux/lsb_spec.rb
+++ b/spec/unit/plugins/linux/lsb_spec.rb
@@ -32,13 +32,13 @@ describe Ohai::System, "Linux lsb plugin" do
describe "on systems with /etc/lsb-release" do
before(:each) do
- @mock_file = mock("/etc/lsb-release")
- @mock_file.stub(:each).
+ @double_file = double("/etc/lsb-release")
+ @double_file.stub(:each).
and_yield("DISTRIB_ID=Ubuntu").
and_yield("DISTRIB_RELEASE=8.04").
and_yield("DISTRIB_CODENAME=hardy").
and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
- File.stub(:open).with("/etc/lsb-release").and_return(@mock_file)
+ File.stub(:open).with("/etc/lsb-release").and_return(@double_file)
File.stub(:exists?).with("/etc/lsb-release").and_return(true)
end
@@ -68,10 +68,10 @@ describe Ohai::System, "Linux lsb plugin" do
File.stub(:exists?).with("/etc/lsb-release").and_return(false)
File.stub(:exists?).with("/usr/bin/lsb_release").and_return(true)
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
end
diff --git a/spec/unit/plugins/linux/uptime_spec.rb b/spec/unit/plugins/linux/uptime_spec.rb
index ec998827..2c8fbcde 100644
--- a/spec/unit/plugins/linux/uptime_spec.rb
+++ b/spec/unit/plugins/linux/uptime_spec.rb
@@ -25,8 +25,8 @@ describe Ohai::System, "Linux plugin uptime" do
@plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("linux/uptime.rb", PLUGIN_PATH))
@plugin[:os] = "linux"
@plugin.require_plugin("uptime")
- @mock_file = mock("/proc/uptime", { :gets => "18423 989" })
- File.stub(:open).with("/proc/uptime").and_return(@mock_file)
+ @double_file = double("/proc/uptime", { :gets => "18423 989" })
+ File.stub(:open).with("/proc/uptime").and_return(@double_file)
@plugin.stub(:require_plugin).and_return(true)
end
diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb
index 503cef69..800f37f9 100644
--- a/spec/unit/plugins/linux/virtualization_spec.rb
+++ b/spec/unit/plugins/linux/virtualization_spec.rb
@@ -122,10 +122,10 @@ describe Ohai::System, "Linux virtualization platform" do
describe "when we are parsing dmidecode" do
before(:each) do
File.should_receive(:exists?).with("/usr/sbin/dmidecode").and_return(true)
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
end
diff --git a/spec/unit/plugins/sigar/network_route_spec.rb b/spec/unit/plugins/sigar/network_route_spec.rb
index 98f6c600..a2ce993c 100644
--- a/spec/unit/plugins/sigar/network_route_spec.rb
+++ b/spec/unit/plugins/sigar/network_route_spec.rb
@@ -118,7 +118,7 @@ describe Ohai::System, "Sigar network route plugin" do
@sigar.should_receive(:net_interface_stat).with("eth0").and_return(net_stat)
@sigar.should_receive(:arp_list).once.and_return([net_arp])
- # Since we mock net_route_list here, flags never gets called
+ # Since we double net_route_list here, flags never gets called
@sigar.should_receive(:net_route_list).once.and_return([net_route])
Sigar.should_receive(:new).at_least(2).times.and_return(@sigar)
@plugin.require_plugin("os")
@@ -134,7 +134,7 @@ describe Ohai::System, "Sigar network route plugin" do
it "should set the route details" do
@net_route_conf.each_pair do |k,v|
- # Work around the above mocking of net_route_list skipping the call to flags()
+ # Work around the above doubleing of net_route_list skipping the call to flags()
if k == :flags
v="U"
@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k] = v
diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb
index 268be494..a06f43d2 100644
--- a/spec/unit/plugins/solaris2/network_spec.rb
+++ b/spec/unit/plugins/solaris2/network_spec.rb
@@ -100,7 +100,7 @@ ROUTE_GET
describe "gathering IP layer address info" do
before do
- @stdout = mock("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
+ @stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
@plugin.stub(:popen4).with("route -n get default").and_yield(nil,StringIO.new, @stdout, nil)
@plugin.stub(:popen4).with("ifconfig -a").and_yield(nil, StringIO.new, @ifconfig_lines, nil)
@plugin.run
@@ -131,7 +131,7 @@ ROUTE_GET
describe "setting the node's default IP address attribute" do
before do
- @stdout = mock("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
+ @stdout = double("Pipe, stdout, cmd=`route get default`", :read => @solaris_route_get)
@plugin.stub(:popen4).with("route -n get default").and_yield(nil,StringIO.new, @stdout, nil)
@plugin.run
end
diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb
index 334b5ded..9739e033 100644
--- a/spec/unit/plugins/solaris2/platform_spec.rb
+++ b/spec/unit/plugins/solaris2/platform_spec.rb
@@ -43,9 +43,9 @@ OEM# = 0
Origin# = 1
NumCPU = 16
UNAME_X
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
+ @stderr = double("STDERR")
@status = 0
@uname_x_lines = uname_x.split("\n")
diff --git a/spec/unit/plugins/solaris2/virtualization_spec.rb b/spec/unit/plugins/solaris2/virtualization_spec.rb
index 71f6a01e..8a568d8e 100644
--- a/spec/unit/plugins/solaris2/virtualization_spec.rb
+++ b/spec/unit/plugins/solaris2/virtualization_spec.rb
@@ -35,10 +35,10 @@ describe Ohai::System, "Solaris virtualization platform" do
describe "when we are checking for kvm" do
before(:each) do
File.should_receive(:exists?).with("/usr/sbin/psrinfo").and_return(true)
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 10
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
end
@@ -65,10 +65,10 @@ describe Ohai::System, "Solaris virtualization platform" do
describe "when we are parsing smbios" do
before(:each) do
File.should_receive(:exists?).with("/usr/sbin/smbios").and_return(true)
- @stdin = mock("STDIN", { :close => true })
+ @stdin = double("STDIN", { :close => true })
@pid = 20
- @stderr = mock("STDERR")
- @stdout = mock("STDOUT")
+ @stderr = double("STDERR")
+ @stdout = double("STDOUT")
@status = 0
end