extract test expectations helper code for reuse
This commit is contained in:
24
spec/helpers/common.rb
Normal file
24
spec/helpers/common.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
require 'mixlib/shellout'
|
||||||
|
|
||||||
|
module Chef::RSpec
|
||||||
|
module Pacemaker
|
||||||
|
module Common
|
||||||
|
# "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 expect_definition(definition)
|
||||||
|
Mixlib::ShellOut.any_instance.stub(:run_command)
|
||||||
|
Mixlib::ShellOut.any_instance.stub(:error!)
|
||||||
|
expect_any_instance_of(Mixlib::ShellOut) \
|
||||||
|
.to receive(:stdout) \
|
||||||
|
.and_return(definition)
|
||||||
|
end
|
||||||
|
|
||||||
|
def expect_exists(exists)
|
||||||
|
expect_any_instance_of(cib_object_class) \
|
||||||
|
.to receive(:exists?) \
|
||||||
|
.and_return(exists)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@@ -1,5 +1,6 @@
|
|||||||
require 'chef/application'
|
require 'chef/application'
|
||||||
require_relative File.join(%w(.. spec_helper))
|
require_relative File.join(%w(.. spec_helper))
|
||||||
|
require_relative File.join(%w(.. helpers common))
|
||||||
require_relative File.join(%w(.. fixtures keystone_primitive))
|
require_relative File.join(%w(.. fixtures keystone_primitive))
|
||||||
|
|
||||||
describe "Chef::Provider::PacemakerPrimitive" do
|
describe "Chef::Provider::PacemakerPrimitive" do
|
||||||
@@ -26,27 +27,12 @@ describe "Chef::Provider::PacemakerPrimitive" do
|
|||||||
|
|
||||||
let (:provider) { Chef::Provider::PacemakerPrimitive.new(@resource, @run_context) }
|
let (:provider) { Chef::Provider::PacemakerPrimitive.new(@resource, @run_context) }
|
||||||
|
|
||||||
# "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 expect_definition(definition)
|
|
||||||
Mixlib::ShellOut.any_instance.stub(:run_command)
|
|
||||||
Mixlib::ShellOut.any_instance.stub(:error!)
|
|
||||||
expect_any_instance_of(Mixlib::ShellOut) \
|
|
||||||
.to receive(:stdout) \
|
|
||||||
.and_return(definition)
|
|
||||||
end
|
|
||||||
|
|
||||||
def expect_exists(exists)
|
|
||||||
expect_any_instance_of(Pacemaker::Resource::Primitive) \
|
|
||||||
.to receive(:exists?) \
|
|
||||||
.and_return(exists)
|
|
||||||
end
|
|
||||||
|
|
||||||
def cib_object_class
|
def cib_object_class
|
||||||
Pacemaker::Resource::Primitive
|
Pacemaker::Resource::Primitive
|
||||||
end
|
end
|
||||||
|
|
||||||
|
include Chef::RSpec::Pacemaker::Common
|
||||||
|
|
||||||
def expect_running(running)
|
def expect_running(running)
|
||||||
expect_any_instance_of(cib_object_class) \
|
expect_any_instance_of(cib_object_class) \
|
||||||
.to receive(:running?) \
|
.to receive(:running?) \
|
||||||
|
Reference in New Issue
Block a user