From d53d973ebbdddf39fc61d1b4126f41b64f4265a2 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Wed, 24 Apr 2013 22:13:48 +0100 Subject: [PATCH] Add system tests for ensure parameter Signed-off-by: Ken Barber --- spec/system/class_spec.rb | 74 ++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 12 deletions(-) diff --git a/spec/system/class_spec.rb b/spec/system/class_spec.rb index 8ba8415..6199c2f 100644 --- a/spec/system/class_spec.rb +++ b/spec/system/class_spec.rb @@ -1,23 +1,73 @@ require 'spec_helper_system' describe "firewall class:" do - let(:pp) do - pp = <<-EOS - class { 'firewall': } - EOS + context 'no params:' do + let(:pp) do + pp = <<-EOS.gsub(/^\s{8}/,'') + class { 'firewall': } + EOS + end + + it "should run without event" do + puppet_apply(pp) do |r| + r[:stderr].should == '' + r[:exit_code].should_not eq(1) + end + end + + it "should be idempotent" do + puppet_apply(pp) do |r| + r[:stderr].should == '' + r[:exit_code].should == 0 + end + end end - it "should run without event" do - puppet_apply(pp) do |r| - r[:stderr].should == '' - r[:exit_code].should_not eq(1) + context 'ensure => stopped:' do + let(:pp) do + pp = <<-EOS.gsub(/^\s{8}/,'') + class { 'firewall': + ensure => stopped, + } + EOS + end + + it "should run without event" do + puppet_apply(pp) do |r| + r[:stderr].should == '' + r[:exit_code].should_not eq(1) + end + end + + it "should be idempotent" do + puppet_apply(pp) do |r| + r[:stderr].should == '' + r[:exit_code].should == 0 + end end end - it "should be idempotent" do - puppet_apply(pp) do |r| - r[:stderr].should == '' - r[:exit_code].should == 0 + context 'ensure => running:' do + let(:pp) do + pp = <<-EOS.gsub(/^\s{8}/,'') + class { 'firewall': + ensure => running, + } + EOS + end + + it "should run without event" do + puppet_apply(pp) do |r| + r[:stderr].should == '' + r[:exit_code].should_not eq(1) + end + end + + it "should be idempotent" do + puppet_apply(pp) do |r| + r[:stderr].should == '' + r[:exit_code].should == 0 + end end end end -- 2.45.2