2014-03-21 18:12:40 +00:00

67 lines
1.8 KiB
Ruby

require 'spec_helper'
require File.expand_path('../../../../libraries/pacemaker/constraint/location',
File.dirname(__FILE__))
require File.expand_path('../../../fixtures/location_constraint', File.dirname(__FILE__))
require File.expand_path('../../../helpers/cib_object', File.dirname(__FILE__))
describe Pacemaker::Constraint::Location do
let(:fixture) { Chef::RSpec::Pacemaker::Config::LOCATION_CONSTRAINT.dup }
let(:fixture_definition) {
Chef::RSpec::Pacemaker::Config::LOCATION_CONSTRAINT_DEFINITION
}
before(:each) do
Mixlib::ShellOut.any_instance.stub(:run_command)
end
def object_type
'location'
end
def pacemaker_object_class
Pacemaker::Constraint::Location
end
def fields
%w(name rsc score node)
end
it_should_behave_like "a CIB object"
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
location = pacemaker_object_class.new('foo')
location.definition = \
%!location location1 primitive1 -inf: node1!
location.parse_definition
expect(location.definition_string).to eq(<<'EOF'.chomp)
location location1 primitive1 -inf: node1
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
it "should parse the score" do
expect(@parsed.score).to eq(fixture.score)
end
it "should parse the node" do
expect(@parsed.node).to eq(fixture.node)
end
end
end