Files
cookbook-pacemaker/spec/providers/group_spec.rb
Adam Spiers c0e3907ba0 tidy up requires
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
2014-03-25 18:37:50 +00:00

66 lines
1.7 KiB
Ruby

require 'spec_helper'
this_dir = File.dirname(__FILE__)
require File.expand_path('../helpers/runnable_resource', this_dir)
require File.expand_path('../fixtures/resource_group', this_dir)
describe "Chef::Provider::PacemakerGroup" do
# for use inside examples:
let(:fixture) { Chef::RSpec::Pacemaker::Config::RESOURCE_GROUP.dup }
# for use outside examples (e.g. when invoking shared_examples)
fixture = Chef::RSpec::Pacemaker::Config::RESOURCE_GROUP.dup
def lwrp_name
'group'
end
include_context "a Pacemaker LWRP"
before(:each) do
@resource.members fixture.members.dup
@resource.meta Hash[fixture.meta.dup]
end
def cib_object_class
Pacemaker::Resource::Group
end
include Chef::RSpec::Pacemaker::CIBObject
describe ":create action" do
def test_modify(expected_cmds)
yield
stub_shellout(fixture.definition_string)
provider.run_action :create
expected_cmds.each do |cmd|
expect(@chef_run).to run_execute(cmd)
end
expect(@resource).to be_updated
end
it "should modify the group if it has a member resource added" do
expected = fixture.dup
expected.members = expected.members.dup + %w(resource3)
expected_configure_cmd_args = [expected.reconfigure_command]
test_modify(expected_configure_cmd_args) do
@resource.members expected.members
end
end
it "should modify the group if it has different member resources" do
fixture.members = %w(resource1 resource3)
expected_configure_cmd_args = [fixture.reconfigure_command]
test_modify(expected_configure_cmd_args) do
@resource.members fixture.members
end
end
end
it_should_behave_like "a runnable resource", fixture
end