Sha256: 538f4b777fa491db2ae08c2dfa46ceb053948742c7941f3a0fa33ff53ce06423

Contents?: true

Size: 812 Bytes

Versions: 5

Compression:

Stored size: 812 Bytes

Contents

require 'spec_helper'

describe NagiosPlugin::StatusError do
  def create_status(status, msg = '')
    NagiosPlugin::StatusError.new(status, msg)
  end

  %w[ok warning critical unknown].each_with_index do |s,i|
    context "when #{s}" do
      before { @status = create_status(s.to_sym) }

      it 'should include status in the exception message' do
        @status.to_s.should include(s.upcase)
      end

      it "should convert to #{i}" do
        @status.to_i.should eql(i)
      end
    end
  end

  context 'when initialized with invalid status' do
    before { @status = create_status(:invalid) }

    it 'should include unknown status in the exception message' do
      @status.to_s.should include('UNKNOWN')
    end

    it 'should convert to 3' do
      @status.to_i.should eql(3)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nagiosplugin-1.3.0 spec/nagiosplugin/status_error_spec.rb
nagiosplugin-1.2.0 spec/nagiosplugin/status_error_spec.rb
nagiosplugin-1.1.2 spec/nagiosplugin/status_error_spec.rb
nagiosplugin-1.1.1 spec/nagiosplugin/status_error_spec.rb
nagiosplugin-1.1.0 spec/nagiosplugin/status_error_spec.rb