module RSpec::Puppet::Augeas::RunAugeasExampleGroup::ClassMethods

Public Instance Methods

describe_augeas(*args, &block) click to toggle source

Synonym for run_augeas

# File lib/rspec-puppet-augeas/example/run_augeas_example_group.rb, line 49
def describe_augeas(*args, &block)
  run_augeas(*args, &block)
end
run_augeas(*args, &block) click to toggle source

new example group, much like ‘describe’

title (arg #1) must match title of Augeas resource
args may be hash containing:
  :fixture =>
    String -> relative path of source fixture file
    Hash   -> { "/dest/path" => "source/fixture/path", ... }
  :target  => path of destination file to be modified
  :lens    => lens used for opening target
# File lib/rspec-puppet-augeas/example/run_augeas_example_group.rb, line 15
def run_augeas(*args, &block)
  options = args.last.is_a?(::Hash) ? args.pop : {}
  args << { :type => :augeas }

  title = "Augeas[#{args.shift}]"
  describe(title, *args) do
    # inside here (the type augeas block), subject will be initialised
    # to the augeas resource object

    # initialise arguments passed into the run_augeas block
    target = options.delete(:target)
    let(:target) do
      target || resource[:incl]
    end

    lens = options.delete(:lens)
    let(:lens) do
      lens || resource[:lens]
    end

    fixture = options.delete(:fixture)
    let(:fixture) do
      if fixture and !fixture.is_a? Hash
        raise ArgumentError, ":target must be supplied" unless self.target
        fixture = { self.target => fixture.to_s }
      end
      fixture
    end

    class_exec(&block)
  end
end