File: month.rb

package info (click to toggle)
grok 1.20110708.1-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,388 kB
  • sloc: ansic: 3,469; ruby: 987; makefile: 276; sh: 124; yacc: 106
file content (24 lines) | stat: -rw-r--r-- 727 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'grok'
require 'test/unit'

class MonthPatternsTest < Test::Unit::TestCase
  def setup
    @grok = Grok.new
    path = "#{File.dirname(__FILE__)}/../../../patterns/base"
    @grok.add_patterns_from_file(path)
    @grok.compile("%{MONTH}")
  end

  def test_months
    months = ["Jan", "January", "Feb", "February", "Mar", "March", "Apr",
              "April", "May", "Jun", "June", "Jul", "July", "Aug", "August",
              "Sep", "September", "Oct", "October", "Nov", "November", "Dec",
              "December"]
    months.each do |month|
      match = @grok.match(month)
      assert_not_equal(false, match, "Expected #{month} to match")
      assert_equal(month, match.captures["MONTH"][0])
    end
  end

end