Project

General

Profile

Bug #10724 » test_tracepoint_with_domain_name.rb

deivid (David Rodríguez), 01/09/2015 10:43 AM

 
1
require 'test/unit'
2

    
3
class TestTracepointWithDomainName < Test::Unit::TestCase
4
  def setup
5
    require 'domain_name'
6
  end
7

    
8
  def test_tracepoint_with_domain_name_gem
9
    events = []
10
  
11
    tracepoint = TracePoint.new(:call, :return) do |tp|
12
      events << [ tp.event, tp.method_id]
13
    end
14
  
15
    tracepoint.enable { DomainName.new('google.com') }
16
  
17
    expected_events = [ [:call, :initialize],
18
                        [:call, :normalize],
19
                        [:call, :to_nfc],
20
                        [:return, :to_nfc],
21
                        [:call, :encode_hostname],
22
                        [:return, :encode_hostname],
23
                        [:return, :normalize],
24
                        [:call, :etld_data],
25
                        [:return, :etld_data],
26
                        [:return, :initialize]
27
                      ]
28

    
29
    assert_equal expected_events, events
30
  end
31
end