Sha256: eb845047c6024daab37537244013e9cd8ba6b0c6e47d66b685ae4036f45fa8a4

Contents?: true

Size: 2 KB

Versions: 1

Compression:

Stored size: 2 KB

Contents

require 'helper'

class TestLogLine < Test::Unit::TestCase

  context "NginxTail::LogLine" do

    should "initialize itself correctly from a parsable log line" do
      raw_line = random_raw_line
      log_line = NginxTail::LogLine.new(raw_line)
      assert_equal raw_line, log_line.raw_line
      assert log_line.parsable
    end

    should "initialize itself correctly from a non-parsable log line" do
      raw_line = "foo bar blegga"
      log_line = NginxTail::LogLine.new(raw_line)
      assert_equal raw_line, log_line.raw_line
      assert !log_line.parsable
    end

    should "implement non-abbreviated alias for $remote_addr" do
      remote_addr = random_ip_address
      log_line = random_log_line(:remote_addr => remote_addr)
      assert_equal remote_addr, log_line.remote_addr
      assert_equal remote_addr, log_line.remote_address
    end

    should "implement a getter method for each (sub-)component" do
      (NginxTail::LogLine::COMPONENTS + NginxTail::LogLine::SUBCOMPONENTS).each do |component|
        getter_method = component.to_s
        assert NginxTail::LogLine.instance_methods.map(&:to_s).include?(getter_method), "getter '#{getter_method}' should exist"
      end
    end

    should "NOT implement a setter method for any (sub-)component" do
      (NginxTail::LogLine::COMPONENTS + NginxTail::LogLine::SUBCOMPONENTS).each do |component|
        setter_method = component.to_s + "="
        assert !NginxTail::LogLine.instance_methods.map(&:to_s).include?(setter_method), "setter '#{setter_method}' should NOT exist"
      end
    end

    should "include an extension module for each (sub-)component" do
      (NginxTail::LogLine::COMPONENTS + NginxTail::LogLine::SUBCOMPONENTS).each do |component|
        ntail_module = NginxTail::Inflections.component_to_ntail_module(component)
        next unless ntail_module # e.g. some Apache components...
        assert NginxTail::LogLine.included_modules.include?(ntail_module), "module '#{ntail_module.name}' should be included"
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ntail-1.3.2 test/ntail/test_log_line.rb