binding_of_caller 0.6.3 → 0.7.3.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test.rb DELETED
@@ -1,91 +0,0 @@
1
- unless Object.const_defined? :BindingOfCaller
2
- $:.unshift File.expand_path '../../lib', __FILE__
3
- require 'binding_of_caller'
4
- require 'binding_of_caller/version'
5
- end
6
-
7
- puts "Testing binding_of_caller version #{BindingOfCaller::VERSION}..."
8
- puts "Ruby version: #{RUBY_VERSION}"
9
-
10
- describe BindingOfCaller do
11
- describe "of_caller" do
12
- it "should fetch immediate caller's binding when 0 is passed" do
13
- o = Object.new
14
- def o.a
15
- var = 1
16
- binding.of_caller(0).eval('var')
17
- end
18
-
19
- o. a.should == 1
20
- end
21
-
22
- it "should fetch parent of caller's binding when 1 is passed" do
23
- o = Object.new
24
- def o.a
25
- var = 1
26
- b
27
- end
28
-
29
- def o.b
30
- binding.of_caller(1).eval('var')
31
- end
32
-
33
- o.a.should == 1
34
- end
35
-
36
- it "should modify locals in parent of caller's binding" do
37
- o = Object.new
38
- def o.a
39
- var = 1
40
- b
41
- var
42
- end
43
-
44
- def o.b
45
- binding.of_caller(1).eval('var = 20')
46
- end
47
-
48
- o.a.should == 20
49
- end
50
-
51
- it "should raise an exception when retrieving an out of band binding" do
52
- o = Object.new
53
- def o.a
54
- binding.of_caller(100)
55
- end
56
-
57
- lambda { o.a }.should.raise RuntimeError
58
- end
59
- end
60
-
61
- describe "frame_count" do
62
- it 'frame_count should equal callers.count' do
63
- binding.frame_count.should == binding.callers.count
64
- end
65
- end
66
-
67
- describe "frame_type" do
68
- it 'should return the correct frame types' do
69
- o = Object.new
70
-
71
- # method frame
72
- def o.a
73
- b
74
- end
75
-
76
- # method frame
77
- def o.b
78
- # block frame
79
- proc do
80
- binding.callers
81
- end.call
82
- end
83
- caller_bindings = o.a
84
- caller_bindings[0].frame_type.should == :block
85
- caller_bindings[1].frame_type.should == :method
86
- caller_bindings[2].frame_type.should == :method
87
- end
88
-
89
- end
90
- end
91
-