diff options
| author | mo khan <mo@mokhan.ca> | 2015-05-01 22:00:01 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-05-01 22:00:01 -0600 |
| commit | 861c12f1f71fe0c97862171d6682d60cc3b5eeca (patch) | |
| tree | b333b3f25717fdbe8671ee51019d380afb1945e8 /spec | |
| parent | 685ad1b0014a15718d7cd96067001c6f8e6b8a55 (diff) | |
finish off the nginx recipe.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/nginx_spec.rb | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/spec/nginx_spec.rb b/spec/nginx_spec.rb index bb22d82..acd23c6 100644 --- a/spec/nginx_spec.rb +++ b/spec/nginx_spec.rb @@ -1,7 +1,8 @@ describe 'mokhan-myface::nginx' do - let(:chef_run) do + let(:domain) { "www.example.com" } + let(:chef_run) do ChefSpec::SoloRunner.new do |node| - node.set['nginx']['domain'] = 'www.example.com' + node.set['nginx']['domain'] = domain end.converge(described_recipe) end @@ -17,12 +18,12 @@ describe 'mokhan-myface::nginx' do end it 'copies the ssl certificate' do - expect(chef_run).to create_cookbook_file("/etc/nginx/ssl/www.example.com.crt") + expect(chef_run).to create_cookbook_file("/etc/nginx/ssl/#{domain}.crt") .with_mode("0644") end it 'copies the ssl private key' do - expect(chef_run).to create_cookbook_file("/etc/nginx/ssl/www.example.com.key") + expect(chef_run).to create_cookbook_file("/etc/nginx/ssl/#{domain}.key") .with_mode("0644") end @@ -30,4 +31,38 @@ describe 'mokhan-myface::nginx' do expect(chef_run).to create_cookbook_file("/etc/nginx/conf.d/blacklist.conf") .with_mode("0644") end + + it 'adds the configuration for the website' do + expect(chef_run).to create_template("/etc/nginx/sites-available/#{domain}") + .with_mode("0644") + end + + it 'restarts nginxj' do + resource = chef_run.template("/etc/nginx/sites-available/#{domain}") + expect(resource).to notify('service[nginx]').to(:restart).delayed + end + + it 'starts nginx' do + expect(chef_run).to start_service('nginx') + end + + it 'creates a symlink to the sites-enabled directory' do + expect(chef_run).to create_link("/etc/nginx/sites-enabled/#{domain}") + end + + it 'deletes the default website' do + expect(chef_run).to delete_file("/etc/nginx/sites-enabled/default") + end + + it 'installs logrotate' do + expect(chef_run).to install_package('logrotate') + end + + it 'creates the log directory for nginx' do + expect(chef_run).to create_directory('/var/log/nginx').with_mode('0755') + end + + it 'adds the logrotate config for rotating nginx logs' do + expect(chef_run).to create_template("/etc/logrotate.d/nginx") + end end |
