PageRenderTime 222ms CodeModel.GetById 120ms app.highlight 6ms RepoModel.GetById 95ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/binding/test_caller.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 44 lines | 32 code | 10 blank | 2 comment | 0 complexity | 6a239adf41f3e4fd2a6bb3b464c707d7 MD5 | raw file
 1require 'facets/binding/caller.rb'
 2require 'test/unit'
 3
 4class TestBindingCallStack < Test::Unit::TestCase
 5
 6  def setup
 7    a = 1
 8    b = 2
 9    x = "hello"
10    # the line number must be updated if it moves
11    @bind = binding; @this_line_no = __LINE__
12    @this_file_name = File.basename( __FILE__ ) # why does it equal basename only?
13  end
14
15  def test___LINE__
16    assert_equal( @this_line_no, @bind.__LINE__ )
17  end
18
19  def test___FILE__
20    assert_equal( @this_file_name, File.basename( @bind.__FILE__ ) )
21  end
22
23  def test___DIR__
24    assert_equal( File.dirname( @bind.__FILE__ ), @bind.__DIR__ )
25  end
26
27  def test_callstack
28    assert_instance_of( Array, @bind.callstack )
29  end
30
31  def test_caller
32    # how to test?
33    assert_nothing_raised{ @bind.caller }
34  end
35
36  def test_callee
37    assert_equal( :setup, @bind.__callee__ )
38  end
39
40  def test_method
41    assert_equal( 'setup', @bind.__method__ )
42  end
43
44end