Class: Mu::Xtractr::Term::Test

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/mu/xtractr/test/tc_term.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#termObject (readonly)

Returns the value of attribute term.



23
24
25
# File 'lib/mu/xtractr/test/tc_term.rb', line 23

def term
  @term
end

#xtractrObject (readonly)

Returns the value of attribute xtractr.



22
23
24
# File 'lib/mu/xtractr/test/tc_term.rb', line 22

def xtractr
  @xtractr
end

Instance Method Details

#setupObject



25
26
27
28
# File 'lib/mu/xtractr/test/tc_term.rb', line 25

def setup
    @xtractr = Xtractr.new
    @term = xtractr.field('http.request.method').terms.first
end

#test_attributesObject



34
35
36
37
38
# File 'lib/mu/xtractr/test/tc_term.rb', line 34

def test_attributes
    assert_kind_of(Field, term.field)
    assert_equal('get', term.value)
    assert_equal(116, term.frequency)
end

#test_eachObject



40
41
42
43
44
45
46
# File 'lib/mu/xtractr/test/tc_term.rb', line 40

def test_each
    assert_equal(term.method(:each), term.method(:each_packet))
    term.each_with_index do |pkt, i|
        assert_kind_of(Packet, pkt)
        break if i < 16
    end
end

#test_inspectObject



53
54
55
# File 'lib/mu/xtractr/test/tc_term.rb', line 53

def test_inspect
    assert_nothing_raised { term.inspect }
end

#test_packetsObject



48
49
50
51
# File 'lib/mu/xtractr/test/tc_term.rb', line 48

def test_packets
    packets = term.packets
    assert_equal("http.request.method:get", packets.q)
end

#test_TermObject



30
31
32
# File 'lib/mu/xtractr/test/tc_term.rb', line 30

def test_Term
    assert(Term.ancestors.include?(Enumerable), "Term doesn't mixin Enumerable")
end