Sha256: fa2d4886c86ae612c99717758f7b298d8da9740511253a8909550c38d1108975

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

describe :syslog_log, :shared => true do
  platform_is_not [:windows, :darwin] do
    before :each do
      Syslog.opened?.should be_false
    end

    after :each do
      Syslog.opened?.should be_false
    end

    it "logs a message" do
      lambda {
        Syslog.open("rubyspec", Syslog::LOG_PERROR) do
          Syslog.send(@method, "Hello")
        end
      }.should output_to_fd("rubyspec: Hello\n", $stderr)
    end

    it "accepts sprintf arguments" do
      lambda {
        Syslog.open("rubyspec", Syslog::LOG_PERROR) do
          Syslog.send(@method, "Hello %s", "world")
          Syslog.send(@method, "%d dogs", 2)
        end
      }.should output_to_fd("rubyspec: Hello world\nrubyspec: 2 dogs\n", $stderr)
    end

    it "works as an alias for Syslog.log" do
      level = Syslog.const_get "LOG_#{@method.to_s.upcase}"
      response = "rubyspec: Hello\n"
      lambda {
        Syslog.open("rubyspec", Syslog::LOG_PERROR) do
          Syslog.send(@method, "Hello")
          Syslog.log(level, "Hello")
        end
        # make sure the same thing is written to $stderr.
      }.should output_to_fd(response * 2, $stderr)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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