summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-01-29 14:05:42 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2014-01-29 14:05:42 -0800
commit652389fbd848861997b9b0c67fae7b2f5ecef064 (patch)
tree7cdde53b9b00b965052b2d4d9786768c003d47a6
parent0fb2730a4c77264d6d5267eb3261f2912a25791f (diff)
downloadchef-652389fbd848861997b9b0c67fae7b2f5ecef064.tar.gz
fix rspec_reset problem
follows the pattern in the rspec-mocks spec tests of defining a helper module: https://github.com/rspec/rspec-mocks/blob/cee433c89125a3984df33c87eb61985613adce9b/spec/spec_helper.rb
-rw-r--r--spec/spec_helper.rb11
-rw-r--r--spec/unit/daemon_spec.rb2
-rw-r--r--spec/unit/provider/deploy/revision_spec.rb2
-rw-r--r--spec/unit/provider/mount/mount_spec.rb2
-rw-r--r--spec/unit/shell_spec.rb2
5 files changed, 15 insertions, 4 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9114c35eaf..3bae699cae 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -86,6 +86,15 @@ Dir["spec/support/**/*.rb"].
map { |f| f.gsub(%r[spec/], '')}.
each { |f| require f }
+module VerifyAndResetHelpers
+ def verify(object)
+ RSpec::Mocks.proxy_for(object).verify
+ end
+
+ def reset(object)
+ RSpec::Mocks.proxy_for(object).reset
+ end
+end
OHAI_SYSTEM = Ohai::System.new
OHAI_SYSTEM.require_plugin("os")
@@ -150,6 +159,8 @@ RSpec.configure do |config|
config.run_all_when_everything_filtered = true
config.treat_symbols_as_metadata_keys_with_true_values = true
+ config.include VerifyAndResetHelpers
+
config.before(:each) do
Chef::Config.reset
end
diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb
index 8d66e08511..69ca2ed321 100644
--- a/spec/unit/daemon_spec.rb
+++ b/spec/unit/daemon_spec.rb
@@ -79,7 +79,7 @@ describe Chef::Daemon do
end
it "changes the working directory to root" do
- Dir.rspec_reset
+ reset Dir
Dir.should_receive(:chdir).with("/").and_return(0)
Chef::Daemon.change_privilege
end
diff --git a/spec/unit/provider/deploy/revision_spec.rb b/spec/unit/provider/deploy/revision_spec.rb
index 13eaee6867..e7be723d28 100644
--- a/spec/unit/provider/deploy/revision_spec.rb
+++ b/spec/unit/provider/deploy/revision_spec.rb
@@ -37,7 +37,7 @@ describe Chef::Provider::Deploy::Revision do
after do
# Make sure we don't keep any state in our tests
- FileUtils.rspec_reset
+ reset FileUtils
FileUtils.rm_rf @temp_dir if File.directory?( @temp_dir )
end
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index cf0e8791de..38b907749e 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -263,7 +263,7 @@ describe Chef::Provider::Mount::Mount do
describe "mount_fs" do
it "should mount the filesystem if it is not mounted" do
- @provider.rspec_reset
+ reset @provider
@provider.should_receive(:shell_out!).with("mount -t ext3 -o defaults /dev/sdz1 /tmp/foo")
@provider.mount_fs()
end
diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb
index fd4241732f..969c526ef4 100644
--- a/spec/unit/shell_spec.rb
+++ b/spec/unit/shell_spec.rb
@@ -42,7 +42,7 @@ describe Shell do
before do
Shell.irb_conf = {}
- Shell::ShellSession.instance.rspec_reset
+ reset Shell::ShellSession.instance
Shell::ShellSession.instance.stub!(:reset!)
end