Skip to content

Commit

Permalink
Merge pull request #63 from agx/issue/62
Browse files Browse the repository at this point in the history
Allow to set up pre conditions from an array
  • Loading branch information
timtim123456 committed Nov 17, 2012
2 parents 695b9a4 + 98bb99e commit ea2a2a3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/rspec-puppet/example/class_example_group.rb
Expand Up @@ -31,7 +31,11 @@ def catalogue
end end


if self.respond_to? :pre_condition 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 else
pre_cond = '' pre_cond = ''
end end
Expand Down
6 changes: 5 additions & 1 deletion lib/rspec-puppet/example/define_example_group.rb
Expand Up @@ -39,7 +39,11 @@ def catalogue
end end


if self.respond_to? :pre_condition 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 else
pre_cond = "" pre_cond = ""
end end
Expand Down
6 changes: 5 additions & 1 deletion lib/rspec-puppet/example/function_example_group.rb
Expand Up @@ -14,7 +14,11 @@ def subject
# if we specify a pre_condition, we should ensure that we compile that code # 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 # into a catalog that is accessible from the scope where the function is called
if self.respond_to? :pre_condition if self.respond_to? :pre_condition
Puppet[:code] = pre_condition if pre_condition.kind_of?(Array)
Puppet[:code] = pre_condition.join("\n")
else
Puppet[:code] = pre_condition
end
nodename = self.respond_to?(:node) ? node : Puppet[:certname] nodename = self.respond_to?(:node) ? node : Puppet[:certname]
facts_val = { facts_val = {
'hostname' => nodename.split('.').first, 'hostname' => nodename.split('.').first,
Expand Down
4 changes: 3 additions & 1 deletion spec/defines/sysctl_before_spec.rb
Expand Up @@ -13,7 +13,9 @@


describe 'sysctl::before' do describe 'sysctl::before' do
let(:title) { 'test define' } let(:title) { 'test define' }
let(:pre_condition) { 'class {"sysctl::common":}' } let(:pre_condition) {
[ '# we need sysctl common',
'class {"sysctl::common":}' ] }
let(:params) { { :value => "title" } } let(:params) { { :value => "title" } }


it { should create_resource("sysctl::before", 'test define')\ it { should create_resource("sysctl::before", 'test define')\
Expand Down

0 comments on commit ea2a2a3

Please sign in to comment.