Skip to content

Commit

Permalink
Unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnytdevops committed Dec 4, 2015
1 parent ef6bd3d commit 8289fc5
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions spec/unit/classes/firewall_linux_redhat_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
require 'spec_helper'

RSpec.shared_examples "ensures iptables service" do
context 'default' do
it { should contain_service('iptables').with(
:ensure => 'running',
:enable => 'true'
)}
end

context 'ensure => stopped' do
let(:params) {{ :ensure => 'stopped' }}
it { should contain_service('iptables').with(
:ensure => 'stopped'
)}
end
context 'enable => false' do
let(:params) {{ :enable => 'false' }}
it { should contain_service('iptables').with(
:enable => 'false'
)}
end
end

describe 'firewall::linux::redhat', :type => :class do
%w{RedHat CentOS Fedora}.each do |os|
oldreleases = (os == 'Fedora' ? ['14'] : ['6.5'])
Expand All @@ -15,6 +37,8 @@

it { should_not contain_service('firewalld') }
it { should_not contain_package('iptables-services') }

it_behaves_like "ensures iptables service"
end
end

Expand All @@ -36,27 +60,8 @@
:ensure => 'present',
:before => 'Service[iptables]'
)}
end
end

describe 'ensure' do
context 'default' do
it { should contain_service('iptables').with(
:ensure => 'running',
:enable => 'true'
)}
end
context 'ensure => stopped' do
let(:params) {{ :ensure => 'stopped' }}
it { should contain_service('iptables').with(
:ensure => 'stopped'
)}
end
context 'enable => false' do
let(:params) {{ :enable => 'false' }}
it { should contain_service('iptables').with(
:enable => 'false'
)}
it_behaves_like "ensures iptables service"
end
end
end
Expand Down

0 comments on commit 8289fc5

Please sign in to comment.