Skip to content

Commit

Permalink
Spec: Fixing Rubocop offences
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Watson committed Aug 29, 2018
1 parent b653bbf commit 7ae3c58
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 119 deletions.
39 changes: 18 additions & 21 deletions spec/classes/newrelic_infra_spec.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
require 'spec_helper'

describe 'newrelic::infra', :type => :class do

describe 'newrelic::infra', 'type' => 'class' do
let(:facts) do
{
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
'major' => '7'
}
{
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
'major' => '7',
},
},
}
}
end


let(:params) do
{
:license_key => '1234567890qwerty',
}
{
'license_key' => '1234567890qwerty',
}
end


it { is_expected.to compile }
it { should contain_package('newrelic-infra') }
it { should contain_service('newrelic-infra').that_requires('Package[newrelic-infra]') }
it { should contain_file('/etc/newrelic-infra.yml').with_content("license_key: 1234567890qwerty\n") }
it { is_expected.to contain_package('newrelic-infra') }
it { is_expected.to contain_service('newrelic-infra').that_requires('Package[newrelic-infra]') }
it { is_expected.to contain_file('/etc/newrelic-infra.yml').with_content("license_key: 1234567890qwerty\n") }

context 'with manage_repo => true' do
let(:params)do
super().merge({ 'manage_repo' => true })
let(:params) do
super().merge('manage_repo' => true)
end

it { should contain_class('newrelic::repo::infra') }
it { is_expected.to contain_class('newrelic::repo::infra') }
end
end
26 changes: 13 additions & 13 deletions spec/classes/newrelic_java_spec.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
require 'spec_helper'

describe 'newrelic::agent::java', :type => :class do
let(:facts) do
describe 'newrelic::agent::java', type: :class do
let(:facts) do
{
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
'major' => '7'
}
'major' => '7',
},
},
'operatingsystem' => 'Centos',
'path' => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin:/root/.local/bin:/root/bin'
}
'path' => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin:/root/.local/bin:/root/bin',
}
end

let(:params) do
{
:license_key => '1234567890qwerty',
:manage_config => true
license_key: '1234567890qwerty',
manage_config: true,
}
end

it { is_expected.to compile }
it { should contain_package('unzip') }
it { should contain_exec('wget-newrelic-java-agent')}
it { should contain_exec('chown-newrelic-install-dir')}
it { should contain_exec('unzip-newrelic-java-agent-zip')}
it { should contain_file('/opt/newrelic/newrelic.yml')}
it { is_expected.to contain_package('unzip') }
it { is_expected.to contain_exec('wget-newrelic-java-agent') }
it { is_expected.to contain_exec('chown-newrelic-install-dir') }
it { is_expected.to contain_exec('unzip-newrelic-java-agent-zip') }
it { is_expected.to contain_file('/opt/newrelic/newrelic.yml') }
end
38 changes: 19 additions & 19 deletions spec/classes/newrelic_php_spec.rb
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
require 'spec_helper'

describe 'newrelic::agent::php', :type => :class do
let(:facts) do
describe 'newrelic::agent::php', type: :class do
let(:facts) do
{
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
'major' => '7'
}
'major' => '7',
},
},
'operatingsystem' => 'Centos',
'path' => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin:/root/.local/bin:/root/bin'
}
'path' => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin:/root/.local/bin:/root/bin',
}
end

let(:params) do
{
:license_key => '1234567890qwerty',
:conf_dir => '/opt/rh/php54/root/etc/php.d',
license_key: '1234567890qwerty',
conf_dir: '/opt/rh/php54/root/etc/php.d',
}
end

it { is_expected.to compile }
it { should contain_class('newrelic::params') }
it { should contain_class('newrelic::repo::legacy') }
it { should contain_package('newrelic-php5') }
it { should contain_package('php-cli') }
it { should contain_file('/etc/newrelic/newrelic.cfg') }
it { should contain_file('/opt/rh/php54/root/etc/php.d/newrelic.ini') }
it { should contain_exec('newrelic install') }
it { should contain_exec('newrelic_kill') }

it { is_expected.to contain_class('newrelic::params') }
it { is_expected.to contain_class('newrelic::repo::legacy') }
it { is_expected.to contain_package('newrelic-php5') }
it { is_expected.to contain_package('php-cli') }
it { is_expected.to contain_file('/etc/newrelic/newrelic.cfg') }
it { is_expected.to contain_file('/opt/rh/php54/root/etc/php.d/newrelic.ini') }
it { is_expected.to contain_exec('newrelic install') }
it { is_expected.to contain_exec('newrelic_kill') }

context 'startup_mode => external' do
let(:params) do
super().merge({ 'startup_mode' => 'external' })
super().merge('startup_mode' => 'external')
end
it { should contain_service('newrelic-daemon') }

it { is_expected.to contain_service('newrelic-daemon') }
end
end
35 changes: 16 additions & 19 deletions spec/classes/newrelic_repo_infra_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
require 'spec_helper'

describe 'newrelic::repo::infra', :type => :class do

describe 'newrelic::repo::infra', type: :class do
context 'OS Family => RedHat' do
let(:facts) do
{
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
'major' => '7'
}
}
}
end
'major' => '7',
},
},
}
end

it { is_expected.to compile }
it { should contain_yumrepo('newrelic-infra') }
it { is_expected.to contain_yumrepo('newrelic-infra') }
end

context 'OS Family => Debian' do
Expand All @@ -25,19 +24,17 @@
'lsbdistcodename' => 'wheezy',
'osfamily' => 'Debian',
'os' => {
'family' => 'Debian',
'name' => 'Debian',
'release' => {
'full' => '7.0'
}
'family' => 'Debian',
'name' => 'Debian',
'release' => {
'full' => '7.0',
},
},
}
end
}
end

it { is_expected.to compile }
it { should contain_apt__source('newrelic-infra') }
it { should contain_package('apt-transport-https') }
it { is_expected.to contain_apt__source('newrelic-infra') }
it { is_expected.to contain_package('apt-transport-https') }
end


end
30 changes: 14 additions & 16 deletions spec/classes/newrelic_repo_legacy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
require 'spec_helper'

describe 'newrelic::repo::legacy', :type => :class do

describe 'newrelic::repo::legacy', type: :class do
context 'OS Family => Redhat' do
let(:facts) do
{
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
'major' => '7'
}
}
'major' => '7',
},
},
}
end

it { is_expected.to compile }
it { should contain_package('newrelic-repo-5-3.noarch') }
it { is_expected.to contain_package('newrelic-repo-5-3.noarch') }
end

context 'OS Family => Debian' do
let(:facts) do
{
'os' => {
'family' => 'Debian',
'name' => 'Debian',
'release' => {
'full' => '7.0'
}
'family' => 'Debian',
'name' => 'Debian',
'release' => {
'full' => '7.0',
},
},
'osfamily' => 'Debian',
'lsbdistcodename' => 'wheezy'
}
end
'lsbdistcodename' => 'wheezy',
}
end

it { is_expected.to compile }
it { should contain_apt__source('newrelic') }
it { is_expected.to contain_apt__source('newrelic') }
end

end
32 changes: 15 additions & 17 deletions spec/classes/newrelic_server_linux_spec.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
require 'spec_helper'

describe 'newrelic::server::linux', :type => :class do
describe 'newrelic::server::linux', type: :class do
let(:facts) do
{
'path' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/puppetlabs/bin:/snap/bin:/opt/puppetlabs/bin/',
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
'major' => '7'
}
}
}
'major' => '7',
},
},
}
end

let(:params) do
{
:license_key => '1234567890qwerty',
license_key: '1234567890qwerty',
}
end

it { is_expected.to compile }
it { should contain_class('newrelic::repo::legacy') }
it { should contain_service('newrelic-sysmond') }
it { should contain_package('newrelic-sysmond') }
it { should contain_file('/var/log/newrelic') }
it { should contain_file('/etc/newrelic/nrsysmond.cfg') }
it { should contain_exec('install_newrelic_license_key') }
it { is_expected.to contain_class('newrelic::repo::legacy') }
it { is_expected.to contain_service('newrelic-sysmond') }
it { is_expected.to contain_package('newrelic-sysmond') }
it { is_expected.to contain_file('/var/log/newrelic') }
it { is_expected.to contain_file('/etc/newrelic/nrsysmond.cfg') }
it { is_expected.to contain_exec('install_newrelic_license_key') }

context 'with manage_repo => true' do
let(:params)do
super().merge({ 'manage_repo' => true })
let(:params) do
super().merge('manage_repo' => true)
end

it { should contain_class('newrelic::repo::legacy') }
it { is_expected.to contain_class('newrelic::repo::legacy') }
end


end
19 changes: 9 additions & 10 deletions spec/classes/newrelic_spec.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
require 'spec_helper'

describe 'newrelic', :type => :class do
describe 'newrelic', type: :class do
let(:facts) do
{
'os' => {
'family' => 'RedHat',
'name' => 'CentOS',
'release' => {
'major' => '7'
}
}
}
'major' => '7',
},
},
}
end

let(:params) do
{
:license_key => '1234567890qwerty',
}
{
license_key: '1234567890qwerty',
}
end

it { is_expected.to compile }
it { should contain_class('newrelic::params') }

it { is_expected.to contain_class('newrelic::params') }
end
7 changes: 3 additions & 4 deletions spec/defines/newrelic_ini.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
let(:title) { '/opt/rh/php54/root/etc/php.d' }

it { is_expected.to compile }
it { should contain_defines__newrelic__php__newrelic_ini('/opt/rh/php54/root/etc/php.d') }
it { should contain_exec('/usr/bin/newrelic-install /opt/rh/php54/root/etc/php.d') }
it { should contain_file('/opt/rh/php54/root/etc/php.d/newrelic.ini') }

it { is_expected.to contain_defines__newrelic__php__newrelic_ini('/opt/rh/php54/root/etc/php.d') }
it { is_expected.to contain_exec('/usr/bin/newrelic-install /opt/rh/php54/root/etc/php.d') }
it { is_expected.to contain_file('/opt/rh/php54/root/etc/php.d/newrelic.ini') }
end

0 comments on commit 7ae3c58

Please sign in to comment.