
It's really ugly to have to keep repeating File.dirname(__FILE__), so we use a temporary variable, even in the case of a single require. This minimises long "requires" lines and "requires" statements with needing line-breaks, and should make search-and-replace a bit easier if we later want to migrate to __dir__ (Ruby >= 2.0) or require_relative. http://stackoverflow.com/questions/4333286/ruby-require-vs-require-relative-best-practice-to-workaround-running-in-both I've deliberately rejected the pattern: require File.expand_path('../relative/path', __FILE__) because it relies on inconsistent semantics and inconsistent documentation in File.expand_path: http://stackoverflow.com/questions/4333286/ruby-require-vs-require-relative-best-practice-to-workaround-running-in-both#comment34147297_4333552
64 lines
1.6 KiB
Ruby
64 lines
1.6 KiB
Ruby
require 'spec_helper'
|
|
|
|
this_dir = File.dirname(__FILE__)
|
|
require File.expand_path('../../../../libraries/pacemaker/resource/clone', this_dir)
|
|
require File.expand_path('../../../fixtures/clone_resource', this_dir)
|
|
require File.expand_path('../../../helpers/cib_object', this_dir)
|
|
require File.expand_path('../../../helpers/meta_examples', this_dir)
|
|
|
|
describe Pacemaker::Resource::Clone do
|
|
let(:fixture) { Chef::RSpec::Pacemaker::Config::CLONE_RESOURCE.dup }
|
|
let(:fixture_definition) {
|
|
Chef::RSpec::Pacemaker::Config::CLONE_RESOURCE_DEFINITION
|
|
}
|
|
|
|
before(:each) do
|
|
Mixlib::ShellOut.any_instance.stub(:run_command)
|
|
end
|
|
|
|
def object_type
|
|
'clone'
|
|
end
|
|
|
|
def pacemaker_object_class
|
|
Pacemaker::Resource::Clone
|
|
end
|
|
|
|
def fields
|
|
%w(name rsc)
|
|
end
|
|
|
|
it_should_behave_like "a CIB object"
|
|
|
|
it_should_behave_like "with meta attributes"
|
|
|
|
describe "#definition_string" do
|
|
it "should return the definition string" do
|
|
expect(fixture.definition_string).to eq(fixture_definition)
|
|
end
|
|
|
|
it "should return a short definition string" do
|
|
clone = pacemaker_object_class.new('foo')
|
|
clone.definition = \
|
|
%!clone clone1 primitive1 meta globally-unique="true"!
|
|
clone.parse_definition
|
|
expect(clone.definition_string).to eq(<<'EOF'.chomp)
|
|
clone clone1 primitive1 \
|
|
meta globally-unique="true"
|
|
EOF
|
|
end
|
|
end
|
|
|
|
describe "#parse_definition" do
|
|
before(:each) do
|
|
@parsed = pacemaker_object_class.new(fixture.name)
|
|
@parsed.definition = fixture_definition
|
|
@parsed.parse_definition
|
|
end
|
|
|
|
it "should parse the rsc" do
|
|
expect(@parsed.rsc).to eq(fixture.rsc)
|
|
end
|
|
end
|
|
end
|