Sha256: 20443f054a5896f618d57f40ada6f497dba2ad03c27c9c977f8f5c36b90e9fcb

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

shared_examples_for 'support service enabled matcher' do |valid_service|
  describe 'be_enabled' do
    describe service(valid_service) do
      it { should be_enabled }
    end

    describe service('invalid-service') do
      it { should_not be_enabled }
    end
  end
end

shared_examples_for 'support service enabled with level matcher' do |valid_service, level|
  describe 'be_enabled' do
    describe service(valid_service) do
      it { should be_enabled.with_level(level) }
    end

    describe service('invalid-service') do
      it { should_not be_enabled.with_level(level) }
    end
  end
end

shared_examples_for 'support service running matcher' do |valid_service|
  describe 'be_running' do
    describe service(valid_service) do
      it { should be_running }
    end

    describe service('invalid-daemon') do
      it { should_not be_running }
    end

    describe service(valid_service) do
      let(:stdout) { "#{valid_service} is stopped\r\n" }
      it { should be_running }
    end
  end
end

shared_examples_for 'support service running under supervisor matcher' do |valid_service|
  describe 'be_running.under("supervisor")' do
    describe service(valid_service) do
      let(:stdout) { "#{valid_service} RUNNING\r\n" }
      it { should be_running.under('supervisor') }
    end

    describe service(valid_service) do
      let(:stdout) { "#{valid_service} STOPPED\r\n" }
      it { should_not be_running.under('supervisor') }
    end

    describe service('invalid-daemon') do
      it { should_not be_running.under('supervisor') }
    end
  end
end

shared_examples_for 'support service running under unimplemented matcher' do |valid_service|
  describe 'be_running.under("not implemented")' do
    describe service(valid_service) do
      it {
        expect {
          should be_running.under('not implemented')
        }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/)
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
serverspec-0.6.16 spec/support/shared_service_examples.rb
serverspec-0.6.15 spec/support/shared_service_examples.rb