This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
/
default_spec.rb
140 lines (116 loc) · 4.43 KB
/
default_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# frozen_string_literal: true
require 'spec_helper'
describe 'opsworks_ruby::setup' do
describe package('ruby2.7') do
it { should be_installed }
end
describe package('libsqlite3-dev') do
it { should be_installed }
end
describe package('git') do
it { should be_installed }
end
describe package('nginx') do
it { should be_installed }
end
describe package('libxml2-dev') do
it { should be_installed }
end
describe package('tzdata') do
it { should be_installed }
end
describe package('zlib1g-dev') do
it { should be_installed }
end
describe file('/usr/local/bin/bundle') do
it { should be_symlink }
end
end
describe 'opsworks_ruby::configure' do
context 'webserver' do
describe file('/etc/logrotate.d/dummy_project-nginx-production') do
its(:content) do
should include '"/var/log/nginx/dummy-project.example.com.access.log" ' \
'"/var/log/nginx/dummy-project.example.com.error.log" {'
end
its(:content) { should include ' daily' }
its(:content) { should include ' rotate 30' }
its(:content) { should include ' missingok' }
its(:content) { should include ' compress' }
its(:content) { should include ' delaycompress' }
its(:content) { should include ' notifempty' }
its(:content) { should include ' copytruncate' }
its(:content) { should include ' sharedscripts' }
end
describe file('/etc/nginx/ssl/dummy-project.example.com.key') do
its(:content) { should include '-----BEGIN RSA PRIVATE KEY-----' }
end
describe file('/etc/nginx/ssl/dummy-project.example.com.crt') do
its(:content) { should include '-----BEGIN CERTIFICATE-----' }
end
describe file('/etc/nginx/ssl/dummy-project.example.com.ca') do
its(:content) { should include '-----BEGIN CERTIFICATE-----' }
end
describe file('/etc/nginx/sites-enabled/dummy_project.conf') do
it { should be_symlink }
end
describe file('/etc/nginx/sites-available/dummy_project.conf') do
its(:content) { should include 'upstream puma_dummy-project.example.com' }
its(:content) { should include 'ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";' }
its(:content) { should include 'root /srv/www/dummy_project/current/public;' }
end
end
context 'appserver' do
describe file('/srv/www/dummy_project/shared/config/puma.rb') do
its(:content) { should include 'workers 4' }
its(:content) { should include 'unix:///srv/www/dummy_project/shared/sockets/puma.sock' }
its(:content) { should include 'environment "production"' }
end
end
context 'framework' do
describe file('/etc/logrotate.d/dummy_project-rails-production') do
its(:content) { should include '"/srv/www/dummy_project/shared/log/*.log" {' }
its(:content) { should include ' daily' }
its(:content) { should include ' rotate 30' }
its(:content) { should include ' missingok' }
its(:content) { should include ' compress' }
its(:content) { should include ' delaycompress' }
its(:content) { should include ' notifempty' }
its(:content) { should include ' copytruncate' }
its(:content) { should include ' sharedscripts' }
end
describe file('/srv/www/dummy_project/current/config/database.yml') do
its(:content) { should include 'adapter: sqlite3' }
end
end
end
describe 'opsworks_ruby::deploy' do
context 'source' do
describe file('/tmp/ssh-git-wrapper.sh') do
its(:content) { should include 'exec ssh -o UserKnownHostsFile=/dev/null' }
end
describe file('/srv/www/dummy_project/current/.git') do
it { should_not exist }
end
end
context 'webserver' do
describe service('nginx') do
it { should be_running }
end
end
context 'appserver' do
describe command('pgrep -f puma | tr \'\n\' \' \'') do
its(:stdout) { should match(/(?:[0-9]+ ){2,4}/) }
end
end
context 'framework' do
describe command('ls -1 /srv/www/dummy_project/current/public/assets/application-*.css*') do
its(:stdout) { should match(/application-[0-9a-f]{64}.css/) }
its(:stdout) { should match(/application-[0-9a-f]{64}.css.gz/) }
end
describe command('ls -1 /srv/www/dummy_project/current/public/test/application-*.css*') do
its(:stdout) { should match(/application-[0-9a-f]{64}.css/) }
its(:stdout) { should match(/application-[0-9a-f]{64}.css.gz/) }
end
end
end