Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rodjek/rspec-puppet
...
head fork: rodjek/rspec-puppet
  • 9 commits
  • 8 files changed
  • 0 commit comments
  • 3 contributors
Commits on Sep 04, 2012
@maxlinc maxlinc obj_name is a symbol c3c62f1
Commits on Nov 16, 2012
@agx agx Allow to set up pre conditions from an array
This improves readability on complex pre conditions and makes sure we
don't forget any newlines that cause weird and hard to debug syntax
errors (#62).
98bb99e
Commits on Nov 17, 2012
@rodjek Merge pull request #63 from agx/issue/62
Allow to set up pre conditions from an array
ea2a2a3
@rodjek Merge pull request #53 from maxlinc/master
failure_message_for_should - object name is a symbol
102a9e8
Commits on Jan 24, 2013
@rodjek Fix for Puppet > 3 && < 3.1
From @jmslagle's PR #61
d5c63b8
@rodjek Add puppetlabs_spec_helper as a dependency
Closes #56
0f5321f
@rodjek Stub out facts properly
Closes #28
bf2050e
@rodjek Noope d042310
@rodjek 0.1.6 a086d05
View
4 lib/rspec-puppet.rb
@@ -6,10 +6,6 @@
require 'rspec-puppet/example'
require 'rspec-puppet/setup'
-if Integer(Puppet.version.split('.').first) >= 3
- Puppet.initialize_settings
-end
-
RSpec.configure do |c|
c.add_setting :module_path, :default => '/etc/puppet/modules'
c.add_setting :manifest_dir, :default => nil
View
6 lib/rspec-puppet/example/class_example_group.rb
@@ -31,7 +31,11 @@ def catalogue
end
if self.respond_to? :pre_condition
- pre_cond = pre_condition
+ if pre_condition.kind_of?(Array)
+ pre_cond = pre_condition.join("\n")
+ else
+ pre_cond = pre_condition
+ end
else
pre_cond = ''
end
View
6 lib/rspec-puppet/example/define_example_group.rb
@@ -39,7 +39,11 @@ def catalogue
end
if self.respond_to? :pre_condition
- pre_cond = pre_condition
+ if pre_condition.kind_of?(Array)
+ pre_cond = pre_condition.join("\n")
+ else
+ pre_cond = pre_condition
+ end
else
pre_cond = ""
end
View
22 lib/rspec-puppet/example/function_example_group.rb
@@ -11,17 +11,23 @@ def subject
Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
Puppet[:libdir] = Dir["#{Puppet[:modulepath]}/*/lib"].entries.join(File::PATH_SEPARATOR)
+ nodename = self.respond_to?(:node) ? node : Puppet[:certname]
+ facts_val = {
+ 'hostname' => nodename.split('.').first,
+ 'fqdn' => nodename,
+ 'domain' => nodename.split('.').last,
+ }
+ facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
+ facts_val.each { |k, v| Facter.add(k) { setcode { v } } }
+
# if we specify a pre_condition, we should ensure that we compile that code
# into a catalog that is accessible from the scope where the function is called
if self.respond_to? :pre_condition
- Puppet[:code] = pre_condition
- nodename = self.respond_to?(:node) ? node : Puppet[:certname]
- facts_val = {
- 'hostname' => nodename.split('.').first,
- 'fqdn' => nodename,
- 'domain' => nodename.split('.').last,
- }
- facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
+ if pre_condition.kind_of?(Array)
+ Puppet[:code] = pre_condition.join("\n")
+ else
+ Puppet[:code] = pre_condition
+ end
# we need to get a compiler, b/c we can attach that to a scope
@compiler = build_compiler(nodename, facts_val)
else
View
2  lib/rspec-puppet/matchers/run.rb
@@ -47,7 +47,7 @@ module FunctionMatchers
end
failure_message_for_should do |func_obj|
- func_name = func_obj.name.gsub(/^function_/, '')
+ func_name = func_obj.name.to_s.gsub(/^function_/, '')
func_params = @params.inspect[1..-2]
if @expected_return
View
6 lib/rspec-puppet/support.rb
@@ -5,8 +5,14 @@ module Support
protected
def build_catalog_without_cache(nodename, facts_val, code)
+ if Integer(Puppet.version.split('.').first) >= 3
+ Puppet.initialize_settings
+ end
+
Puppet[:code] = code
+ facts_val.each { |k, v| Facter.add(k) { setcode { v } } }
+
node_obj = Puppet::Node.new(nodename)
node_obj.merge(facts_val)
View
2  rspec-puppet.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'rspec-puppet'
- s.version = '0.1.5'
+ s.version = '0.1.6'
s.homepage = 'https://github.com/rodjek/rspec-puppet/'
s.summary = 'RSpec tests for your Puppet manifests'
s.description = 'RSpec tests for your Puppet manifests'
View
4 spec/defines/sysctl_before_spec.rb
@@ -13,7 +13,9 @@
describe 'sysctl::before' do
let(:title) { 'test define' }
- let(:pre_condition) { 'class {"sysctl::common":}' }
+ let(:pre_condition) {
+ [ '# we need sysctl common',
+ 'class {"sysctl::common":}' ] }
let(:params) { { :value => "title" } }
it { should create_resource("sysctl::before", 'test define')\

No commit comments for this range

Something went wrong with that request. Please try again.