extract meta attribute tests for reuse
This commit is contained in:
parent
daf3022e96
commit
5df9f7cf95
21
spec/helpers/meta_examples.rb
Normal file
21
spec/helpers/meta_examples.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
shared_examples "with meta attributes" do
|
||||||
|
describe "#meta_string" do
|
||||||
|
it "should return empty string with nil meta" do
|
||||||
|
fixture.meta = nil
|
||||||
|
expect(fixture.meta_string).to eq("")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return empty string with empty meta" do
|
||||||
|
fixture.meta = {}
|
||||||
|
expect(fixture.meta_string).to eq("")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return a resource meta string" do
|
||||||
|
fixture.meta = {
|
||||||
|
"foo" => "bar",
|
||||||
|
"baz" => "qux",
|
||||||
|
}
|
||||||
|
expect(fixture.meta_string).to eq(%'meta baz="qux" foo="bar"')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,7 +1,12 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require File.expand_path('../../../../libraries/pacemaker/resource/primitive', File.dirname(__FILE__))
|
require File.expand_path('../../../../libraries/pacemaker/resource/primitive',
|
||||||
require File.expand_path('../../../fixtures/keystone_primitive', File.dirname(__FILE__))
|
File.dirname(__FILE__))
|
||||||
require File.expand_path('../../../helpers/common_object_examples', File.dirname(__FILE__))
|
require File.expand_path('../../../fixtures/keystone_primitive',
|
||||||
|
File.dirname(__FILE__))
|
||||||
|
require File.expand_path('../../../helpers/common_object_examples',
|
||||||
|
File.dirname(__FILE__))
|
||||||
|
require File.expand_path('../../../helpers/meta_examples',
|
||||||
|
File.dirname(__FILE__))
|
||||||
|
|
||||||
describe Pacemaker::Resource::Primitive do
|
describe Pacemaker::Resource::Primitive do
|
||||||
let(:fixture) { Chef::RSpec::Pacemaker::Config::KEYSTONE_PRIMITIVE.dup }
|
let(:fixture) { Chef::RSpec::Pacemaker::Config::KEYSTONE_PRIMITIVE.dup }
|
||||||
@ -47,26 +52,6 @@ describe Pacemaker::Resource::Primitive do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#meta_string" do
|
|
||||||
it "should return empty string with nil meta" do
|
|
||||||
fixture.meta = nil
|
|
||||||
expect(fixture.meta_string).to eq("")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should return empty string with empty meta" do
|
|
||||||
fixture.meta = {}
|
|
||||||
expect(fixture.meta_string).to eq("")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should return a resource meta string" do
|
|
||||||
fixture.meta = {
|
|
||||||
"foo" => "bar",
|
|
||||||
"baz" => "qux",
|
|
||||||
}
|
|
||||||
expect(fixture.meta_string).to eq(%'meta baz="qux" foo="bar"')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#op_string" do
|
describe "#op_string" do
|
||||||
it "should return empty string with nil op" do
|
it "should return empty string with nil op" do
|
||||||
fixture.op = nil
|
fixture.op = nil
|
||||||
@ -89,6 +74,8 @@ describe Pacemaker::Resource::Primitive do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it_should_behave_like "with meta attributes"
|
||||||
|
|
||||||
describe "#definition_string" do
|
describe "#definition_string" do
|
||||||
it "should return the definition string" do
|
it "should return the definition string" do
|
||||||
expect(fixture.definition_string).to eq(fixture_definition)
|
expect(fixture.definition_string).to eq(fixture_definition)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user