From 683b5988f433ef973ee23ec649ab290e693669d4 Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Tue, 13 Jan 2015 12:23:19 +0100 Subject: [PATCH] rspec for #25 --- spec/classes/repo_spec.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index 7f7b822..ab7c404 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -37,4 +37,38 @@ it_behaves_like 'debian', 'Ubuntu', 'precise' end + shared_examples 'redhat' do |operatingsystem, lsbdistcodename, mrel| + let(:params) {{ + :source => 'mesosphere', + }} + + let(:osrel) { lsbdistcodename} + + let(:facts) {{ + :operatingsystem => operatingsystem, + :osfamily => 'RedHat', + :lsbdistcodename => lsbdistcodename, + :operatingsystemmajrelease => lsbdistcodename, + :lsbdistid => operatingsystem, + }} + + it { should contain_package('mesosphere-el-repo').with({ + 'ensure' => 'present', + 'provider' => 'rpm', + 'source' => "http://repos.mesosphere.io/el/#{osrel}/noarch/RPMS/mesosphere-el-repo-#{osrel}-#{mrel}.noarch.rpm", + })} + + context "undef source" do + let(:params) {{ + :source => 'undef', + }} + it { should_not contain_package('mesosphere-el-repo') } + end + end + + context 'on RedHat based systems' do + it_behaves_like 'redhat', 'CentOS', '6', '2' + it_behaves_like 'redhat', 'CentOS', '7', '1' + end + end \ No newline at end of file