class Resource
Monky patch Puppet
Public Instance Methods
to_rspec()
click to toggle source
# File lib/puppet-catalog_rspec/resource.rb, line 5 def to_rspec type = self.type.downcase.tr(':', '_') puts "it { is_expected.to contain_#{type}('#{title}')" properties puts '}' puts '' end
Private Instance Methods
properties()
click to toggle source
# File lib/puppet-catalog_rspec/resource.rb, line 15 def properties hash = to_hash keys = hash.keys max_length = keys.map(&:length).max hash.each do |k, v| case k when :name # Skip name next when :require [v].flatten.each { |r| puts " .that_requires('#{r}')" } when :before [v].flatten.each { |r| puts " .that_comes_before('#{r}')" } when :notify [v].flatten.each { |r| puts " .that_notifies('#{r}')" } when :subscribe [v].flatten.each { |r| puts " .that_subscribes_to('#{v}')" } else puts " .with(#{("'#{k}'").ljust(max_length + 2)} => '#{v}')" end end end