|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +# Set defaults, use debian as base |
| 4 | + |
| 5 | +# Override by OS Family |
| 6 | +case platform[:family] |
| 7 | +when 'redhat', 'centos', 'fedora' |
| 8 | + server_available = '/etc/nginx/conf.d' |
| 9 | + server_enabled = '/etc/nginx/conf.d' |
| 10 | + passenger_mod = '/usr/lib64/nginx/modules/ngx_http_passenger_module.so' |
| 11 | + passenger_root = '/usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini' |
| 12 | + passenger_config_file = '/etc/nginx/conf.d/passenger.conf' |
| 13 | + should_not_exist_file = '/etc/nginx/conf.d/mod-http-passenger.conf' |
| 14 | +when 'debian', 'ubuntu' |
| 15 | + server_available = '/etc/nginx/sites-available' |
| 16 | + server_enabled = '/etc/nginx/sites-enabled' |
| 17 | + passenger_mod = '/usr/lib/nginx/modules/ngx_http_passenger_module.so' |
| 18 | + passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini' |
| 19 | + passenger_config_file = '/etc/nginx/conf.d/mod-http-passenger.conf' |
| 20 | + should_not_exist_file = '/etc/nginx/conf.d/passenger.conf' |
| 21 | +end |
| 22 | + |
| 23 | +control 'Passenger configuration' do |
| 24 | + title 'should match desired lines' |
| 25 | + |
| 26 | + # main configuration |
| 27 | + describe file('/etc/nginx/nginx.conf') do |
| 28 | + its('content') { should include "load_module #{passenger_mod}" } |
| 29 | + end |
| 30 | + |
| 31 | + describe file(passenger_config_file) do |
| 32 | + it { should be_file } |
| 33 | + it { should be_owned_by 'root' } |
| 34 | + it { should be_grouped_into 'root' } |
| 35 | + its('mode') { should cmp '0644' } |
| 36 | + its('content') { should include "passenger_root #{passenger_root};" } |
| 37 | + its('content') { should include 'passenger_ruby /usr/bin/ruby;' } |
| 38 | + end |
| 39 | + |
| 40 | + describe file(should_not_exist_file) do |
| 41 | + it { should_not exist } |
| 42 | + end |
| 43 | + |
| 44 | + # sites configuration |
| 45 | + [server_available, server_enabled].each do |dir| |
| 46 | + describe file "#{dir}/default" do |
| 47 | + it { should_not exist } |
| 48 | + end |
| 49 | + |
| 50 | + describe file "#{dir}/mysite" do |
| 51 | + it { should be_file } |
| 52 | + it { should be_owned_by 'root' } |
| 53 | + it { should be_grouped_into 'root' } |
| 54 | + its('mode') { should cmp '0644' } |
| 55 | + its('content') { should include 'passenger_enabled on;' } |
| 56 | + end |
| 57 | + end |
| 58 | +end |
0 commit comments