shared_examples need to include Chef::RSpec::Pacemaker::CIBObject
This commit is contained in:
@@ -5,7 +5,32 @@ require 'mixlib/shellout'
|
|||||||
require File.expand_path('../../libraries/pacemaker/cib_object',
|
require File.expand_path('../../libraries/pacemaker/cib_object',
|
||||||
File.dirname(__FILE__))
|
File.dirname(__FILE__))
|
||||||
|
|
||||||
|
module Chef::RSpec
|
||||||
|
module Pacemaker
|
||||||
|
module CIBObject
|
||||||
|
# "crm configure show" is executed by load_current_resource, and
|
||||||
|
# again later on for the :create action, to see whether to create or
|
||||||
|
# modify.
|
||||||
|
def shellout_double(definition)
|
||||||
|
shellout = double(Mixlib::ShellOut)
|
||||||
|
shellout.stub(:environment).and_return({})
|
||||||
|
shellout.stub(:run_command)
|
||||||
|
shellout.stub(:error!)
|
||||||
|
expect(shellout).to receive(:stdout).and_return(definition)
|
||||||
|
shellout
|
||||||
|
end
|
||||||
|
|
||||||
|
def expect_definitions(*definitions)
|
||||||
|
doubles = definitions.map { |d| shellout_double(d) }
|
||||||
|
Mixlib::ShellOut.stub(:new).and_return(*doubles)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
shared_examples "a CIB object" do
|
shared_examples "a CIB object" do
|
||||||
|
include Chef::RSpec::Pacemaker::CIBObject
|
||||||
|
|
||||||
def expect_to_match_fixture(obj)
|
def expect_to_match_fixture(obj)
|
||||||
expect(obj.is_a? pacemaker_object_class).to eq(true)
|
expect(obj.is_a? pacemaker_object_class).to eq(true)
|
||||||
fields.each do |field|
|
fields.each do |field|
|
||||||
@@ -34,6 +59,8 @@ shared_examples "a CIB object" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
shared_examples "action on non-existent resource" do |action, cmd, expected_error|
|
shared_examples "action on non-existent resource" do |action, cmd, expected_error|
|
||||||
|
include Chef::RSpec::Pacemaker::CIBObject
|
||||||
|
|
||||||
it "should not attempt to #{action.to_s} a non-existent resource" do
|
it "should not attempt to #{action.to_s} a non-existent resource" do
|
||||||
expect_definitions("")
|
expect_definitions("")
|
||||||
|
|
||||||
@@ -48,26 +75,3 @@ shared_examples "action on non-existent resource" do |action, cmd, expected_erro
|
|||||||
expect(@resource).not_to be_updated
|
expect(@resource).not_to be_updated
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Chef::RSpec
|
|
||||||
module Pacemaker
|
|
||||||
module CIBObject
|
|
||||||
# "crm configure show" is executed by load_current_resource, and
|
|
||||||
# again later on for the :create action, to see whether to create or
|
|
||||||
# modify.
|
|
||||||
def shellout_double(definition)
|
|
||||||
shellout = double(Mixlib::ShellOut)
|
|
||||||
shellout.stub(:environment).and_return({})
|
|
||||||
shellout.stub(:run_command)
|
|
||||||
shellout.stub(:error!)
|
|
||||||
expect(shellout).to receive(:stdout).and_return(definition)
|
|
||||||
shellout
|
|
||||||
end
|
|
||||||
|
|
||||||
def expect_definitions(*definitions)
|
|
||||||
doubles = definitions.map { |d| shellout_double(d) }
|
|
||||||
Mixlib::ShellOut.stub(:new).and_return(*doubles)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
Reference in New Issue
Block a user