From 0ac14ce0df00cd397e7d8939466ea534e8bedf94 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 4 Feb 2014 13:01:47 +0000 Subject: [PATCH] move shared examples for action on non-existent resource to common.rb --- spec/helpers/common.rb | 18 ++++++++++++++++++ spec/providers/primitive_spec.rb | 16 ---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/spec/helpers/common.rb b/spec/helpers/common.rb index 307b1f3..ddd5944 100644 --- a/spec/helpers/common.rb +++ b/spec/helpers/common.rb @@ -1,5 +1,23 @@ require 'mixlib/shellout' +# Shared code used to test providers of CIB objects + +shared_examples "action on non-existent resource" do |action, cmd, expected_error| + it "should not attempt to #{action.to_s} a non-existent resource" do + expect_definition("") + + if expected_error + expect { provider.run_action action }.to \ + raise_error(RuntimeError, expected_error) + else + provider.run_action action + end + + expect(@chef_run).not_to run_execute(cmd) + expect(@resource).not_to be_updated + end +end + module Chef::RSpec module Pacemaker module Common diff --git a/spec/providers/primitive_spec.rb b/spec/providers/primitive_spec.rb index 3ca6074..bb802e4 100644 --- a/spec/providers/primitive_spec.rb +++ b/spec/providers/primitive_spec.rb @@ -132,22 +132,6 @@ describe "Chef::Provider::PacemakerPrimitive" do end end - shared_examples "action on non-existent resource" do |action, cmd, expected_error| - it "should not attempt to #{action.to_s} a non-existent resource" do - expect_definition("") - - if expected_error - expect { provider.run_action action }.to \ - raise_error(RuntimeError, expected_error) - else - provider.run_action action - end - - expect(@chef_run).not_to run_execute(cmd) - expect(@resource).not_to be_updated - end - end - describe ":delete action" do it_should_behave_like "action on non-existent resource", \ :delete, "crm configure delete #{rsc.name}", nil