Sha256: 7a7e5674acb6bfccb3daa5bc3f4a3790a9ce5bd568dc5dceac2a52a0fc73a308

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

require 'syslog'

describe "Syslog::Constants" do
  platform_is_not :windows do

    before :all do

    @constants = %w(LOG_AUTHPRIV LOG_USER LOG_LOCAL2 LOG_NOTICE LOG_NDELAY
                    LOG_SYSLOG LOG_ALERT LOG_FTP LOG_LOCAL5 LOG_ERR LOG_AUTH
                    LOG_LOCAL1 LOG_ODELAY LOG_NEWS LOG_DAEMON LOG_LOCAL4
                    LOG_CRIT LOG_INFO LOG_PERROR LOG_LOCAL0 LOG_CONS LOG_LPR
                    LOG_LOCAL7 LOG_WARNING LOG_CRON LOG_LOCAL3 LOG_EMERG
                    LOG_NOWAIT LOG_UUCP LOG_PID LOG_KERN LOG_MAIL LOG_LOCAL6
                    LOG_DEBUG)
    end

    it "includes the Syslog constants" do
      @constants.each do |c|
        Syslog::Constants.should have_constant(c)
      end
    end

  end

  # The masks are defined in <syslog.h>

  describe "Syslog::Constants.LOG_MASK" do
    it "returns the mask value for a priority" do
      Syslog::Constants.LOG_MASK(Syslog::LOG_DEBUG).should == 128
      Syslog::Constants.LOG_MASK(Syslog::LOG_WARNING).should == 16
    end

    not_compliant_on :rubinius do
      it "works on undefined constants" do
        Syslog::Constants.LOG_MASK(1337).should == 33554432
        Syslog::Constants.LOG_MASK(7331).should == 8
      end
    end
  end

  describe "Syslog::Constants.LOG_UPTO" do
    it "returns a mask for the priorities up to a given argument" do
      Syslog::Constants.LOG_UPTO(Syslog::LOG_ALERT).should == 3
      Syslog::Constants.LOG_UPTO(Syslog::LOG_DEBUG).should == 255
    end

    not_compliant_on :rubinius do
      it "works on undefined constants" do
        Syslog::Constants.LOG_UPTO(1337).should == 67108863
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubysl-syslog-3.0 spec/constants_spec.rb
rubysl-syslog-2.1.0 spec/constants_spec.rb
rubysl-syslog-1.0.0 spec/constants_spec.rb
rubysl-syslog-2.0.1 spec/constants_spec.rb