Skip to content

Commit

Permalink
Merge pull request #378 from 3flex/rspec2.99-updates
Browse files Browse the repository at this point in the history
Convert specs to RSpec 2.99.1 syntax with Transpec
  • Loading branch information
3flex committed Aug 22, 2014
2 parents a2dd6cd + 32bc360 commit 0adf7f7
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 244 deletions.
60 changes: 30 additions & 30 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,66 +26,66 @@
}
end

it { should contain_class("nginx::params") }
it { is_expected.to contain_class("nginx::params") }

it { should contain_file("/etc/nginx").only_with(
it { is_expected.to contain_file("/etc/nginx").only_with(
:path => "/etc/nginx",
:ensure => 'directory',
:owner => 'root',
:group => 'root',
:mode => '0644'
)}
it { should contain_file("/etc/nginx/conf.d").only_with(
it { is_expected.to contain_file("/etc/nginx/conf.d").only_with(
:path => '/etc/nginx/conf.d',
:ensure => 'directory',
:owner => 'root',
:group => 'root',
:mode => '0644'
)}
it { should contain_file("/etc/nginx/conf.mail.d").only_with(
it { is_expected.to contain_file("/etc/nginx/conf.mail.d").only_with(
:path => '/etc/nginx/conf.mail.d',
:ensure => 'directory',
:owner => 'root',
:group => 'root',
:mode => '0644'
)}
it { should contain_file("/etc/nginx/conf.d/vhost_autogen.conf").with_ensure('absent') }
it { should contain_file("/etc/nginx/conf.mail.d/vhost_autogen.conf").with_ensure('absent') }
it { should contain_file("/var/nginx").with(
it { is_expected.to contain_file("/etc/nginx/conf.d/vhost_autogen.conf").with_ensure('absent') }
it { is_expected.to contain_file("/etc/nginx/conf.mail.d/vhost_autogen.conf").with_ensure('absent') }
it { is_expected.to contain_file("/var/nginx").with(
:ensure => 'directory',
:owner => 'root',
:group => 'root',
:mode => '0644'
)}
it { should contain_file("/var/nginx/client_body_temp").with(
it { is_expected.to contain_file("/var/nginx/client_body_temp").with(
:ensure => 'directory',
:group => 'root',
:mode => '0644'
)}
it { should contain_file("/var/nginx/proxy_temp").with(
it { is_expected.to contain_file("/var/nginx/proxy_temp").with(
:ensure => 'directory',
:group => 'root',
:mode => '0644'
)}
it { should contain_file('/etc/nginx/sites-enabled/default').with_ensure('absent') }
it { should contain_file("/etc/nginx/nginx.conf").with(
it { is_expected.to contain_file('/etc/nginx/sites-enabled/default').with_ensure('absent') }
it { is_expected.to contain_file("/etc/nginx/nginx.conf").with(
:ensure => 'file',
:owner => 'root',
:group => 'root',
:mode => '0644'
)}
it { should contain_file("/etc/nginx/conf.d/proxy.conf").with(
it { is_expected.to contain_file("/etc/nginx/conf.d/proxy.conf").with(
:ensure => 'file',
:owner => 'root',
:group => 'root',
:mode => '0644'
)}
it { should contain_file("/tmp/nginx.d").with(
it { is_expected.to contain_file("/tmp/nginx.d").with(
:ensure => 'absent',
:purge => true,
:recurse => true
)}
it { should contain_file("/tmp/nginx.mail.d").with(
it { is_expected.to contain_file("/tmp/nginx.mail.d").with(
:ensure => 'absent',
:purge => true,
:recurse => true
Expand All @@ -108,9 +108,9 @@
:operatingsystem => facts[:operatingsystem],
}
end
it { should contain_file("/var/nginx/client_body_temp").with(:owner => 'www-data')}
it { should contain_file("/var/nginx/proxy_temp").with(:owner => 'www-data')}
it { should contain_file("/etc/nginx/nginx.conf").with_content %r{^user www-data;}}
it { is_expected.to contain_file("/var/nginx/client_body_temp").with(:owner => 'www-data')}
it { is_expected.to contain_file("/var/nginx/proxy_temp").with(:owner => 'www-data')}
it { is_expected.to contain_file("/etc/nginx/nginx.conf").with_content %r{^user www-data;}}
end
end
end
Expand All @@ -137,9 +137,9 @@
:operatingsystem => facts[:operatingsystem],
}
end
it { should contain_file("/var/nginx/client_body_temp").with(:owner => 'nginx')}
it { should contain_file("/var/nginx/proxy_temp").with(:owner => 'nginx')}
it { should contain_file("/etc/nginx/nginx.conf").with_content %r{^user nginx;}}
it { is_expected.to contain_file("/var/nginx/client_body_temp").with(:owner => 'nginx')}
it { is_expected.to contain_file("/var/nginx/proxy_temp").with(:owner => 'nginx')}
it { is_expected.to contain_file("/etc/nginx/nginx.conf").with_content %r{^user nginx;}}
end
end
end
Expand Down Expand Up @@ -250,11 +250,11 @@
context "when #{param[:attr]} is #{param[:value]}" do
let :params do { param[:attr].to_sym => param[:value] } end

it { should contain_file("/etc/nginx/nginx.conf").with_mode('0644') }
it { is_expected.to contain_file("/etc/nginx/nginx.conf").with_mode('0644') }
it param[:title] do
verify_contents(subject, "/etc/nginx/nginx.conf", Array(param[:match]))
Array(param[:notmatch]).each do |item|
should contain_file("/etc/nginx/nginx.conf").without_content(item)
is_expected.to contain_file("/etc/nginx/nginx.conf").without_content(item)
end
end
end
Expand Down Expand Up @@ -306,11 +306,11 @@
context "when #{param[:attr]} is #{param[:value]}" do
let :params do { param[:attr].to_sym => param[:value] } end

it { should contain_file("/etc/nginx/conf.d/proxy.conf").with_mode('0644') }
it { is_expected.to contain_file("/etc/nginx/conf.d/proxy.conf").with_mode('0644') }
it param[:title] do
verify_contents(subject, "/etc/nginx/conf.d/proxy.conf", Array(param[:match]))
Array(param[:notmatch]).each do |item|
should contain_file("/etc/nginx/conf.d/proxy.conf").without_content(item)
is_expected.to contain_file("/etc/nginx/conf.d/proxy.conf").without_content(item)
end
end
end
Expand All @@ -319,15 +319,15 @@

context "when confd_purge true" do
let(:params) {{:confd_purge => true}}
it { should contain_file('/etc/nginx/conf.d').with(
it { is_expected.to contain_file('/etc/nginx/conf.d').with(
:purge => true,
:recurse => true
)}
end

context "when confd_purge false" do
let(:params) {{:confd_purge => false}}
it { should contain_file('/etc/nginx/conf.d').without([
it { is_expected.to contain_file('/etc/nginx/conf.d').without([
'ignore',
'purge',
'recurse'
Expand All @@ -336,24 +336,24 @@

context "when vhost_purge true" do
let(:params) {{:vhost_purge => true}}
it { should contain_file('/etc/nginx/sites-available').with(
it { is_expected.to contain_file('/etc/nginx/sites-available').with(
:purge => true,
:recurse => true
)}
it { should contain_file('/etc/nginx/sites-enabled').with(
it { is_expected.to contain_file('/etc/nginx/sites-enabled').with(
:purge => true,
:recurse => true
)}
end

context "when vhost_purge false" do
let(:params) {{:vhost_purge => false}}
it { should contain_file('/etc/nginx/sites-available').without([
it { is_expected.to contain_file('/etc/nginx/sites-available').without([
'ignore',
'purge',
'recurse'
])}
it { should contain_file('/etc/nginx/sites-enabled').without([
it { is_expected.to contain_file('/etc/nginx/sites-enabled').without([
'ignore',
'purge',
'recurse'
Expand Down
28 changes: 14 additions & 14 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
end

shared_examples "a Linux OS" do
it { should compile.with_all_deps }
it { should contain_class('nginx') }
it { should contain_anchor('nginx::begin') }
it { should contain_nginx__package.that_requires('Anchor[nginx::begin]') }
it { should contain_nginx__config.that_requires('Class[nginx::package]') }
it { should contain_nginx__service.that_subscribes_to('Anchor[nginx::begin]') }
it { should contain_nginx__service.that_subscribes_to('Class[nginx::package]') }
it { should contain_nginx__service.that_subscribes_to('Class[nginx::config]') }
it { should contain_anchor('nginx::end').that_requires('Class[nginx::service]') }
it { should contain_class("nginx::params") }
it { should contain_nginx__resource__upstream("upstream1") }
it { should contain_nginx__resource__vhost("test2.local") }
it { should contain_nginx__resource__location("test2.local") }
it { should contain_nginx__resource__mailhost("smtp.test2.local") }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('nginx') }
it { is_expected.to contain_anchor('nginx::begin') }
it { is_expected.to contain_nginx__package.that_requires('Anchor[nginx::begin]') }
it { is_expected.to contain_nginx__config.that_requires('Class[nginx::package]') }
it { is_expected.to contain_nginx__service.that_subscribes_to('Anchor[nginx::begin]') }
it { is_expected.to contain_nginx__service.that_subscribes_to('Class[nginx::package]') }
it { is_expected.to contain_nginx__service.that_subscribes_to('Class[nginx::config]') }
it { is_expected.to contain_anchor('nginx::end').that_requires('Class[nginx::service]') }
it { is_expected.to contain_class("nginx::params") }
it { is_expected.to contain_nginx__resource__upstream("upstream1") }
it { is_expected.to contain_nginx__resource__vhost("test2.local") }
it { is_expected.to contain_nginx__resource__location("test2.local") }
it { is_expected.to contain_nginx__resource__mailhost("smtp.test2.local") }
end

context "Debian OS" do
Expand Down
68 changes: 34 additions & 34 deletions spec/classes/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@
let(:facts) {{ :operatingsystem => operatingsystem, :osfamily => 'RedHat' }}

context "using defaults" do
it { should contain_package('nginx') }
it { should contain_yumrepo('nginx-release').with(
it { is_expected.to contain_package('nginx') }
it { is_expected.to contain_yumrepo('nginx-release').with(
'baseurl' => 'http://nginx.org/packages/rhel/6/$basearch/',
'descr' => 'nginx repo',
'enabled' => '1',
'gpgcheck' => '1',
'priority' => '1',
'gpgkey' => 'http://nginx.org/keys/nginx_signing.key'
)}
it { should contain_file('/etc/yum.repos.d/nginx-release.repo') }
it { should contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::redhat]') }
it { should contain_anchor('nginx::package::end').that_requires('Class[nginx::package::redhat]') }
it { is_expected.to contain_file('/etc/yum.repos.d/nginx-release.repo') }
it { is_expected.to contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::redhat]') }
it { is_expected.to contain_anchor('nginx::package::end').that_requires('Class[nginx::package::redhat]') }
end

context "manage_repo => false" do
let(:params) {{ :manage_repo => false }}
it { should contain_package('nginx') }
it { should_not contain_yumrepo('nginx-release') }
it { should_not contain_file('/etc/yum.repos.d/nginx-release.repo') }
it { is_expected.to contain_package('nginx') }
it { is_expected.not_to contain_yumrepo('nginx-release') }
it { is_expected.not_to contain_file('/etc/yum.repos.d/nginx-release.repo') }
end

context "lsbmajdistrelease = 5" do
let(:facts) {{ :operatingsystem => operatingsystem, :osfamily => 'RedHat', :lsbmajdistrelease => 5 }}
it { should contain_package('nginx') }
it { should contain_yumrepo('nginx-release').with(
it { is_expected.to contain_package('nginx') }
it { is_expected.to contain_yumrepo('nginx-release').with(
'baseurl' => 'http://nginx.org/packages/rhel/5/$basearch/'
)}
it { should contain_file('/etc/yum.repos.d/nginx-release.repo') }
it { is_expected.to contain_file('/etc/yum.repos.d/nginx-release.repo') }
end

describe 'installs the requested package version' do
let(:facts) {{ :operatingsystem => 'redhat', :osfamily => 'redhat' }}
let(:params) {{ :package_ensure => '3.0.0' }}

it 'installs 3.0.0 exactly' do
should contain_package('nginx').with({
is_expected.to contain_package('nginx').with({
'ensure' => '3.0.0'
})
end
Expand All @@ -57,23 +57,23 @@
}}

context "using defaults" do
it { should contain_package('nginx') }
it { should_not contain_package('passenger') }
it { should contain_apt__source('nginx').with(
it { is_expected.to contain_package('nginx') }
it { is_expected.not_to contain_package('passenger') }
it { is_expected.to contain_apt__source('nginx').with(
'location' => "http://nginx.org/packages/#{operatingsystem}",
'repos' => 'nginx',
'key' => '7BD9BF62',
'key_source' => 'http://nginx.org/keys/nginx_signing.key'
)}
it { should contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::debian]') }
it { should contain_anchor('nginx::package::end').that_requires('Class[nginx::package::debian]') }
it { is_expected.to contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::debian]') }
it { is_expected.to contain_anchor('nginx::package::end').that_requires('Class[nginx::package::debian]') }
end

context "package_source => 'passenger'" do
let(:params) {{ :package_source => 'passenger' }}
it { should contain_package('nginx') }
it { should contain_package('passenger') }
it { should contain_apt__source('nginx').with(
it { is_expected.to contain_package('nginx') }
it { is_expected.to contain_package('passenger') }
it { is_expected.to contain_apt__source('nginx').with(
'location' => 'https://oss-binaries.phusionpassenger.com/apt/passenger',
'repos' => "main",
'key' => '561F9B9CAC40B2F7',
Expand All @@ -83,9 +83,9 @@

context "manage_repo => false" do
let(:params) {{ :manage_repo => false }}
it { should contain_package('nginx') }
it { should_not contain_apt__source('nginx') }
it { should_not contain_package('passenger') }
it { is_expected.to contain_package('nginx') }
it { is_expected.not_to contain_apt__source('nginx') }
it { is_expected.not_to contain_package('passenger') }
end
end

Expand All @@ -94,10 +94,10 @@
[
'nginx',
].each do |package|
it { should contain_package("#{package}") }
it { is_expected.to contain_package("#{package}") }
end
it { should contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::suse]') }
it { should contain_anchor('nginx::package::end').that_requires('Class[nginx::package::suse]') }
it { is_expected.to contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::suse]') }
it { is_expected.to contain_anchor('nginx::package::end').that_requires('Class[nginx::package::suse]') }
end


Expand All @@ -121,27 +121,27 @@

context 'amazon with facter < 1.7.2' do
let(:facts) {{ :operatingsystem => 'Amazon', :osfamily => 'Linux' }}
it { should contain_package('nginx') }
it { should contain_yumrepo('nginx-release').with(
it { is_expected.to contain_package('nginx') }
it { is_expected.to contain_yumrepo('nginx-release').with(
'baseurl' => 'http://nginx.org/packages/rhel/6/$basearch/',
'descr' => 'nginx repo',
'enabled' => '1',
'gpgcheck' => '1',
'priority' => '1',
'gpgkey' => 'http://nginx.org/keys/nginx_signing.key'
)}
it { should contain_file('/etc/yum.repos.d/nginx-release.repo') }
it { should contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::redhat]') }
it { should contain_anchor('nginx::package::end').that_requires('Class[nginx::package::redhat]') }
it { is_expected.to contain_file('/etc/yum.repos.d/nginx-release.repo') }
it { is_expected.to contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::redhat]') }
it { is_expected.to contain_anchor('nginx::package::end').that_requires('Class[nginx::package::redhat]') }
end

context 'fedora' do
# fedora is identical to the rest of osfamily RedHat except for not
# including nginx-release
let(:facts) {{ :operatingsystem => 'Fedora', :osfamily => 'RedHat', :lsbmajdistrelease => 6 }}
it { should contain_package('nginx') }
it { should_not contain_yumrepo('nginx-release') }
it { should_not contain_file('/etc/yum.repos.d/nginx-release.repo') }
it { is_expected.to contain_package('nginx') }
it { is_expected.not_to contain_yumrepo('nginx-release') }
it { is_expected.not_to contain_file('/etc/yum.repos.d/nginx-release.repo') }
end

context 'other' do
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
:operatingsystem => 'debian',
} end

it { should contain_nginx__params }
it { should have_class_count(1) } #only nginx::params itself
it { should have_resource_count(0) } #params class should never declare resources
it { is_expected.to contain_nginx__params }
it { is_expected.to have_class_count(1) } #only nginx::params itself
it { is_expected.to have_resource_count(0) } #params class should never declare resources

end
end
Loading

0 comments on commit 0adf7f7

Please sign in to comment.