|
| 1 | +require 'serverspec' |
| 2 | + |
| 3 | +# Required by serverspec |
| 4 | +set :backend, :exec |
| 5 | + |
| 6 | +describe 'Package Service' do |
| 7 | + describe package('nginx') do |
| 8 | + it { should be_installed } |
| 9 | + end |
| 10 | + |
| 11 | + describe service('nginx') do |
| 12 | + it { should be_enabled } |
| 13 | + it { should be_running } |
| 14 | + end |
| 15 | + |
| 16 | + describe port(1180) do |
| 17 | + it { should be_listening } |
| 18 | + end |
| 19 | + |
| 20 | + describe port(1280) do |
| 21 | + it { should be_listening } |
| 22 | + end |
| 23 | + |
| 24 | +end |
| 25 | + |
| 26 | +describe 'NGinx sites-enabled' do |
| 27 | + |
| 28 | + describe file('/etc/nginx/sites-enabled/default') do |
| 29 | + it { should be_symlink } |
| 30 | + it { should be_linked_to '/etc/nginx/sites-available/default' } |
| 31 | + end |
| 32 | + |
| 33 | + describe file('/etc/nginx/sites-enabled/test2.conf') do |
| 34 | + it { should be_symlink } |
| 35 | + it { should be_linked_to '/etc/nginx/sites-available/test2.conf' } |
| 36 | + end |
| 37 | + |
| 38 | + describe file('/etc/nginx/sites-enabled/test3.conf') do |
| 39 | + it { should be_symlink } |
| 40 | + it { should be_linked_to '/etc/nginx/sites-available/test3.conf' } |
| 41 | + end |
| 42 | + |
| 43 | + describe file('/etc/nginx/sites-enabled/remove_me.conf') do |
| 44 | + it { should_not exist } |
| 45 | + end |
| 46 | + |
| 47 | +end |
| 48 | + |
| 49 | +describe 'NGinx http content' do |
| 50 | + |
| 51 | + describe command "curl -s -L http://127.0.0.1:1180" do |
| 52 | + its(:exit_status) { should eq 0 } |
| 53 | + its(:stdout) { should match "Hello test2" } |
| 54 | + end |
| 55 | + |
| 56 | + describe command "curl -s -L http://127.0.0.1:1280" do |
| 57 | + its(:exit_status) { should eq 0 } |
| 58 | + its(:stdout) { should match "Hello test3" } |
| 59 | + end |
| 60 | + |
| 61 | +end |
0 commit comments