pry-stack_explorer 0.4.9.3 → 0.6.1
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.
- checksums.yaml +5 -5
- data/README.md +47 -49
- data/lib/pry-stack_explorer/commands.rb +73 -21
- data/lib/pry-stack_explorer/version.rb +3 -3
- data/lib/pry-stack_explorer/when_started_hook.rb +3 -1
- data/lib/pry-stack_explorer.rb +3 -3
- metadata +28 -44
- data/.gemtest +0 -0
- data/.gitignore +0 -7
- data/.travis.yml +0 -29
- data/.yardopts +0 -1
- data/CHANGELOG +0 -0
- data/Gemfile +0 -2
- data/Rakefile +0 -112
- data/examples/example.rb +0 -45
- data/examples/example2.rb +0 -18
- data/examples/example3.rb +0 -46
- data/pry-stack_explorer.gemspec +0 -36
- data/test/helper.rb +0 -87
- data/test/test_commands.rb +0 -358
- data/test/test_frame_manager.rb +0 -65
- data/test/test_stack_explorer.rb +0 -393
- data/tester.rb +0 -27
data/examples/example2.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
unless Object.const_defined? :PryStackExplorer
|
2
|
-
$:.unshift File.expand_path '../../lib', __FILE__
|
3
|
-
require 'pry'
|
4
|
-
end
|
5
|
-
|
6
|
-
require 'pry-stack_explorer'
|
7
|
-
|
8
|
-
def alpha
|
9
|
-
x = "hello"
|
10
|
-
beta
|
11
|
-
puts x
|
12
|
-
end
|
13
|
-
|
14
|
-
def beta
|
15
|
-
binding.pry
|
16
|
-
end
|
17
|
-
|
18
|
-
alpha
|
data/examples/example3.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
unless Object.const_defined? :PryStackExplorer
|
2
|
-
$:.unshift File.expand_path '../../lib', __FILE__
|
3
|
-
require 'pry'
|
4
|
-
end
|
5
|
-
|
6
|
-
require 'pry-stack_explorer'
|
7
|
-
|
8
|
-
def b
|
9
|
-
x = 30
|
10
|
-
proc {
|
11
|
-
c
|
12
|
-
}.call
|
13
|
-
end
|
14
|
-
|
15
|
-
def c
|
16
|
-
u = 50
|
17
|
-
V.new.beta
|
18
|
-
end
|
19
|
-
|
20
|
-
# hello
|
21
|
-
class V
|
22
|
-
def beta
|
23
|
-
gamma
|
24
|
-
end
|
25
|
-
|
26
|
-
def gamma
|
27
|
-
zeta
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def zeta
|
32
|
-
vitamin = 100
|
33
|
-
binding.pry
|
34
|
-
end
|
35
|
-
#
|
36
|
-
|
37
|
-
proc {
|
38
|
-
class J
|
39
|
-
def alphabet(y)
|
40
|
-
x = 20
|
41
|
-
b
|
42
|
-
end
|
43
|
-
end
|
44
|
-
}.call
|
45
|
-
|
46
|
-
J.new.alphabet(122)
|
data/pry-stack_explorer.gemspec
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = "pry-stack_explorer"
|
3
|
-
s.version = "0.4.9.3"
|
4
|
-
|
5
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
-
s.authors = ["John Mair (banisterfiend)"]
|
7
|
-
s.date = Time.now.strftime('%Y-%m-%d')
|
8
|
-
s.description = "Walk the stack in a Pry session"
|
9
|
-
s.email = "jrmair@gmail.com"
|
10
|
-
s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "examples/example.rb", "examples/example2.rb", "examples/example3.rb", "lib/pry-stack_explorer.rb", "lib/pry-stack_explorer/commands.rb", "lib/pry-stack_explorer/frame_manager.rb", "lib/pry-stack_explorer/version.rb", "lib/pry-stack_explorer/when_started_hook.rb", "pry-stack_explorer.gemspec", "test/helper.rb", "test/test_commands.rb", "test/test_frame_manager.rb", "test/test_stack_explorer.rb", "tester.rb"]
|
11
|
-
s.homepage = "https://github.com/pry/pry-stack_explorer"
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.summary = "Walk the stack in a Pry session"
|
14
|
-
s.test_files = ["test/helper.rb", "test/test_commands.rb", "test/test_frame_manager.rb", "test/test_stack_explorer.rb"]
|
15
|
-
|
16
|
-
if s.respond_to? :specification_version then
|
17
|
-
s.specification_version = 4
|
18
|
-
|
19
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
20
|
-
s.add_runtime_dependency(%q<binding_of_caller>, [">= 0.7"])
|
21
|
-
s.add_runtime_dependency(%q<pry>, [">= 0.9.11"])
|
22
|
-
s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
|
23
|
-
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
24
|
-
else
|
25
|
-
s.add_dependency(%q<binding_of_caller>, [">= 0.7"])
|
26
|
-
s.add_dependency(%q<pry>, [">= 0.9.11"])
|
27
|
-
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
28
|
-
s.add_dependency(%q<rake>, ["~> 0.9"])
|
29
|
-
end
|
30
|
-
else
|
31
|
-
s.add_dependency(%q<binding_of_caller>, [">= 0.7"])
|
32
|
-
s.add_dependency(%q<pry>, [">= 0.9.11"])
|
33
|
-
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
34
|
-
s.add_dependency(%q<rake>, ["~> 0.9"])
|
35
|
-
end
|
36
|
-
end
|
data/test/helper.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'ostruct'
|
3
|
-
require 'pry'
|
4
|
-
|
5
|
-
unless Object.const_defined? 'PryStackExplorer'
|
6
|
-
$:.unshift File.expand_path '../../lib', __FILE__
|
7
|
-
require 'pry-stack_explorer'
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'bacon'
|
11
|
-
|
12
|
-
puts "Testing pry-stack_explorer version #{PryStackExplorer::VERSION}..."
|
13
|
-
puts "Ruby version: #{RUBY_VERSION}"
|
14
|
-
|
15
|
-
PE = PryStackExplorer
|
16
|
-
|
17
|
-
class << Pry
|
18
|
-
alias_method :orig_reset_defaults, :reset_defaults
|
19
|
-
def reset_defaults
|
20
|
-
orig_reset_defaults
|
21
|
-
|
22
|
-
Pry.color = false
|
23
|
-
Pry.pager = false
|
24
|
-
Pry.config.should_load_rc = false
|
25
|
-
Pry.config.should_load_plugins = false
|
26
|
-
Pry.config.history.should_load = false
|
27
|
-
Pry.config.history.should_save = false
|
28
|
-
Pry.config.auto_indent = false
|
29
|
-
Pry.config.hooks = Pry::Hooks.new
|
30
|
-
Pry.config.collision_warning = false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
AfterSessionHook = Pry.config.hooks.get_hook(:after_session, :delete_frame_manager)
|
35
|
-
WhenStartedHook = Pry.config.hooks.get_hook(:when_started, :save_caller_bindings)
|
36
|
-
|
37
|
-
Pry.reset_defaults
|
38
|
-
|
39
|
-
class InputTester
|
40
|
-
def initialize(*actions)
|
41
|
-
if actions.last.is_a?(Hash) && actions.last.keys == [:history]
|
42
|
-
@hist = actions.pop[:history]
|
43
|
-
end
|
44
|
-
@orig_actions = actions.dup
|
45
|
-
@actions = actions
|
46
|
-
end
|
47
|
-
|
48
|
-
def readline(*)
|
49
|
-
@actions.shift.tap{ |line| @hist << line if @hist }
|
50
|
-
end
|
51
|
-
|
52
|
-
def rewind
|
53
|
-
@actions = @orig_actions.dup
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Set I/O streams.
|
58
|
-
#
|
59
|
-
# Out defaults to an anonymous StringIO.
|
60
|
-
#
|
61
|
-
def redirect_pry_io(new_in, new_out = StringIO.new)
|
62
|
-
old_in = Pry.input
|
63
|
-
old_out = Pry.output
|
64
|
-
|
65
|
-
Pry.input = new_in
|
66
|
-
Pry.output = new_out
|
67
|
-
begin
|
68
|
-
yield
|
69
|
-
ensure
|
70
|
-
Pry.input = old_in
|
71
|
-
Pry.output = old_out
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def mock_pry(*args)
|
76
|
-
|
77
|
-
binding = args.first.is_a?(Binding) ? args.shift : binding()
|
78
|
-
|
79
|
-
input = InputTester.new(*args)
|
80
|
-
output = StringIO.new
|
81
|
-
|
82
|
-
redirect_pry_io(input, output) do
|
83
|
-
binding.pry
|
84
|
-
end
|
85
|
-
|
86
|
-
output.string
|
87
|
-
end
|
data/test/test_commands.rb
DELETED
@@ -1,358 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
|
4
|
-
class Top
|
5
|
-
attr_accessor :method_list, :middle
|
6
|
-
def initialize method_list
|
7
|
-
@method_list = method_list
|
8
|
-
end
|
9
|
-
def bing
|
10
|
-
@middle = Middle.new method_list
|
11
|
-
@middle.bong
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class Middle
|
16
|
-
attr_accessor :method_list, :bottom
|
17
|
-
def initialize method_list
|
18
|
-
@method_list = method_list
|
19
|
-
end
|
20
|
-
def bong
|
21
|
-
@bottom = Bottom.new method_list
|
22
|
-
@bottom.bang
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class Bottom
|
27
|
-
attr_accessor :method_list
|
28
|
-
def initialize method_list
|
29
|
-
@method_list = method_list
|
30
|
-
end
|
31
|
-
def bang
|
32
|
-
Pry.start(binding)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
describe PryStackExplorer::Commands do
|
38
|
-
|
39
|
-
before do
|
40
|
-
Pry.config.hooks.add_hook(:when_started, :save_caller_bindings, WhenStartedHook)
|
41
|
-
Pry.config.hooks.add_hook(:after_session, :delete_frame_manager, AfterSessionHook)
|
42
|
-
|
43
|
-
@o = Object.new
|
44
|
-
class << @o; attr_accessor :first_method, :second_method, :third_method; end
|
45
|
-
def @o.bing() bong end
|
46
|
-
def @o.bong() bang end
|
47
|
-
def @o.bang() Pry.start(binding) end
|
48
|
-
|
49
|
-
method_list = []
|
50
|
-
@top = Top.new method_list
|
51
|
-
end
|
52
|
-
|
53
|
-
after do
|
54
|
-
Pry.config.hooks.delete_hook(:when_started, :save_caller_bindings)
|
55
|
-
Pry.config.hooks.delete_hook(:after_session, :delete_frame_manager)
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "up" do
|
59
|
-
it 'should move up the call stack one frame at a time' do
|
60
|
-
redirect_pry_io(InputTester.new("@first_method = __method__",
|
61
|
-
"up",
|
62
|
-
"@second_method = __method__",
|
63
|
-
"up",
|
64
|
-
"@third_method = __method__",
|
65
|
-
"exit-all"), out=StringIO.new) do
|
66
|
-
@o.bing
|
67
|
-
end
|
68
|
-
|
69
|
-
@o.first_method.should == :bang
|
70
|
-
@o.second_method.should == :bong
|
71
|
-
@o.third_method.should == :bing
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should move up the call stack two frames at a time' do
|
75
|
-
redirect_pry_io(InputTester.new("@first_method = __method__",
|
76
|
-
"up 2",
|
77
|
-
"@second_method = __method__",
|
78
|
-
"exit-all"), out=StringIO.new) do
|
79
|
-
@o.bing
|
80
|
-
end
|
81
|
-
|
82
|
-
@o.first_method.should == :bang
|
83
|
-
@o.second_method.should == :bing
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "by method name regex" do
|
87
|
-
it 'should move to the method name that matches the regex' do
|
88
|
-
redirect_pry_io(InputTester.new("@first_method = __method__",
|
89
|
-
"up bi",
|
90
|
-
"@second_method = __method__",
|
91
|
-
"exit-all"), out=StringIO.new) do
|
92
|
-
@o.bing
|
93
|
-
end
|
94
|
-
|
95
|
-
@o.first_method.should == :bang
|
96
|
-
@o.second_method.should == :bing
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should move through all methods that match regex in order' do
|
100
|
-
redirect_pry_io(InputTester.new("@first_method = __method__",
|
101
|
-
"up b",
|
102
|
-
"@second_method = __method__",
|
103
|
-
"up b",
|
104
|
-
"@third_method = __method__",
|
105
|
-
"exit-all"), out=StringIO.new) do
|
106
|
-
@o.bing
|
107
|
-
end
|
108
|
-
|
109
|
-
@o.first_method.should == :bang
|
110
|
-
@o.second_method.should == :bong
|
111
|
-
@o.third_method.should == :bing
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'should error if it cant find frame to match regex' do
|
115
|
-
redirect_pry_io(InputTester.new("up conrad_irwin",
|
116
|
-
"exit-all"), out=StringIO.new) do
|
117
|
-
@o.bing
|
118
|
-
end
|
119
|
-
|
120
|
-
out.string.should =~ /Error: No frame that matches/
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
describe 'by Class#method name regex' do
|
126
|
-
it 'should move to the method and class that matches the regex' do
|
127
|
-
redirect_pry_io(InputTester.new("@method_list << self.class.to_s + '#' + __method__.to_s",
|
128
|
-
'up Middle#bong',
|
129
|
-
"@method_list << self.class.to_s + '#' + __method__.to_s",
|
130
|
-
"exit-all"), out=StringIO.new) do
|
131
|
-
@top.bing
|
132
|
-
end
|
133
|
-
|
134
|
-
@top.method_list.should == ['Bottom#bang', 'Middle#bong']
|
135
|
-
end
|
136
|
-
|
137
|
-
### ????? ###
|
138
|
-
# it 'should be case sensitive' do
|
139
|
-
# end
|
140
|
-
### ????? ###
|
141
|
-
|
142
|
-
it 'should allow partial class names' do
|
143
|
-
redirect_pry_io(InputTester.new("@method_list << self.class.to_s + '#' + __method__.to_s",
|
144
|
-
'up Mid#bong',
|
145
|
-
"@method_list << self.class.to_s + '#' + __method__.to_s",
|
146
|
-
"exit-all"), out=StringIO.new) do
|
147
|
-
@top.bing
|
148
|
-
end
|
149
|
-
|
150
|
-
@top.method_list.should == ['Bottom#bang', 'Middle#bong']
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'should allow partial method names' do
|
155
|
-
redirect_pry_io(InputTester.new("@method_list << self.class.to_s + '#' + __method__.to_s",
|
156
|
-
'up Middle#bo',
|
157
|
-
"@method_list << self.class.to_s + '#' + __method__.to_s",
|
158
|
-
"exit-all"), out=StringIO.new) do
|
159
|
-
@top.bing
|
160
|
-
end
|
161
|
-
|
162
|
-
@top.method_list.should == ['Bottom#bang', 'Middle#bong']
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'should error if it cant find frame to match regex' do
|
167
|
-
redirect_pry_io(InputTester.new('up Conrad#irwin',
|
168
|
-
"exit-all"), out=StringIO.new) do
|
169
|
-
@top.bing
|
170
|
-
end
|
171
|
-
|
172
|
-
out.string.should =~ /Error: No frame that matches/
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
describe "down" do
|
178
|
-
it 'should move down the call stack one frame at a time' do
|
179
|
-
def @o.bang() Pry.start(binding, :initial_frame => 1) end
|
180
|
-
|
181
|
-
redirect_pry_io(InputTester.new("@first_method = __method__",
|
182
|
-
"down",
|
183
|
-
"@second_method = __method__",
|
184
|
-
"exit-all"), out=StringIO.new) do
|
185
|
-
@o.bing
|
186
|
-
end
|
187
|
-
|
188
|
-
@o.first_method.should == :bong
|
189
|
-
@o.second_method.should == :bang
|
190
|
-
end
|
191
|
-
|
192
|
-
it 'should move down the call stack two frames at a time' do
|
193
|
-
def @o.bang() Pry.start(binding, :initial_frame => 2) end
|
194
|
-
|
195
|
-
redirect_pry_io(InputTester.new("@first_method = __method__",
|
196
|
-
"down 2",
|
197
|
-
"@second_method = __method__",
|
198
|
-
"exit-all"), out=StringIO.new) do
|
199
|
-
@o.bing
|
200
|
-
end
|
201
|
-
|
202
|
-
@o.first_method.should == :bing
|
203
|
-
@o.second_method.should == :bang
|
204
|
-
end
|
205
|
-
|
206
|
-
describe "by method name regex" do
|
207
|
-
it 'should move to the method name that matches the regex' do
|
208
|
-
redirect_pry_io(InputTester.new("frame -1",
|
209
|
-
"down bo",
|
210
|
-
"@first_method = __method__",
|
211
|
-
"exit-all"), out=StringIO.new) do
|
212
|
-
@o.bing
|
213
|
-
end
|
214
|
-
|
215
|
-
@o.first_method.should == :bong
|
216
|
-
end
|
217
|
-
|
218
|
-
it 'should move through all methods that match regex in order' do
|
219
|
-
redirect_pry_io(InputTester.new("frame bing",
|
220
|
-
"@first_method = __method__",
|
221
|
-
"down b",
|
222
|
-
"@second_method = __method__",
|
223
|
-
"down b",
|
224
|
-
"@third_method = __method__",
|
225
|
-
"exit-all"), out=StringIO.new) do
|
226
|
-
@o.bing
|
227
|
-
end
|
228
|
-
|
229
|
-
@o.first_method.should == :bing
|
230
|
-
@o.second_method.should == :bong
|
231
|
-
@o.third_method.should == :bang
|
232
|
-
end
|
233
|
-
|
234
|
-
it 'should error if it cant find frame to match regex' do
|
235
|
-
redirect_pry_io(InputTester.new("frame -1",
|
236
|
-
"down conrad_irwin",
|
237
|
-
"exit-all"), out=StringIO.new) do
|
238
|
-
@o.bing
|
239
|
-
end
|
240
|
-
|
241
|
-
out.string.should =~ /Error: No frame that matches/
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
describe 'by Class#method name regex' do
|
246
|
-
it 'should move to the method and class that matches the regex' do
|
247
|
-
redirect_pry_io(InputTester.new('frame Top#bing',
|
248
|
-
"@method_list << self.class.to_s + '#' + __method__.to_s",
|
249
|
-
'down Middle#bong',
|
250
|
-
"@method_list << self.class.to_s + '#' + __method__.to_s",
|
251
|
-
"exit-all"), out=StringIO.new) do
|
252
|
-
@top.bing
|
253
|
-
end
|
254
|
-
|
255
|
-
@top.method_list.should == ['Top#bing', 'Middle#bong']
|
256
|
-
end
|
257
|
-
|
258
|
-
### ????? ###
|
259
|
-
# it 'should be case sensitive' do
|
260
|
-
# end
|
261
|
-
### ????? ###
|
262
|
-
|
263
|
-
it 'should error if it cant find frame to match regex' do
|
264
|
-
redirect_pry_io(InputTester.new('down Conrad#irwin',
|
265
|
-
"exit-all"), out=StringIO.new) do
|
266
|
-
@top.bing
|
267
|
-
end
|
268
|
-
|
269
|
-
out.string.should =~ /Error: No frame that matches/
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
end
|
274
|
-
|
275
|
-
describe "frame" do
|
276
|
-
describe "by method name regex" do
|
277
|
-
it 'should jump to correct stack frame when given method name' do
|
278
|
-
redirect_pry_io(InputTester.new("frame bi",
|
279
|
-
"@first_method = __method__",
|
280
|
-
"exit-all"), out=StringIO.new) do
|
281
|
-
@o.bing
|
282
|
-
end
|
283
|
-
|
284
|
-
@o.first_method.should == :bing
|
285
|
-
end
|
286
|
-
|
287
|
-
it 'should NOT jump to frames lower down stack when given method name' do
|
288
|
-
redirect_pry_io(InputTester.new("frame -1",
|
289
|
-
"frame bang",
|
290
|
-
"exit-all"), out=StringIO.new) do
|
291
|
-
@o.bing
|
292
|
-
end
|
293
|
-
|
294
|
-
out.string.should =~ /Error: No frame that matches/
|
295
|
-
end
|
296
|
-
|
297
|
-
end
|
298
|
-
|
299
|
-
it 'should move to the given frame in the call stack' do
|
300
|
-
redirect_pry_io(InputTester.new("frame 2",
|
301
|
-
"@first_method = __method__",
|
302
|
-
"exit-all"), out=StringIO.new) do
|
303
|
-
@o.bing
|
304
|
-
end
|
305
|
-
|
306
|
-
@o.first_method.should == :bing
|
307
|
-
end
|
308
|
-
|
309
|
-
it 'should return info on current frame when given no parameters' do
|
310
|
-
redirect_pry_io(InputTester.new("frame",
|
311
|
-
"exit-all"), out=StringIO.new) do
|
312
|
-
@o.bing
|
313
|
-
end
|
314
|
-
|
315
|
-
out.string.should =~ /\#0.*?bang/
|
316
|
-
out.string.should.not =~ /\#1/
|
317
|
-
end
|
318
|
-
|
319
|
-
describe "negative indices" do
|
320
|
-
it 'should work with negative frame numbers' do
|
321
|
-
o = Object.new
|
322
|
-
class << o; attr_accessor :frame; end
|
323
|
-
def o.alpha() binding end
|
324
|
-
def o.beta() binding end
|
325
|
-
def o.gamma() binding end
|
326
|
-
|
327
|
-
call_stack = [o.alpha, o.beta, o.gamma]
|
328
|
-
method_names = call_stack.map { |v| v.eval('__method__') }.reverse
|
329
|
-
(1..3).each_with_index do |v, idx|
|
330
|
-
redirect_pry_io(InputTester.new("frame -#{v}",
|
331
|
-
"@frame = __method__",
|
332
|
-
"exit-all"), out=StringIO.new) do
|
333
|
-
Pry.start(o, :call_stack => call_stack)
|
334
|
-
end
|
335
|
-
o.frame.should == method_names[idx]
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
it 'should convert negative indices to their positive counterparts' do
|
340
|
-
o = Object.new
|
341
|
-
class << o; attr_accessor :frame_number; end
|
342
|
-
def o.alpha() binding end
|
343
|
-
def o.beta() binding end
|
344
|
-
def o.gamma() binding end
|
345
|
-
|
346
|
-
call_stack = [o.alpha, o.beta, o.gamma]
|
347
|
-
(1..3).each_with_index do |v, idx|
|
348
|
-
redirect_pry_io(InputTester.new("frame -#{v}",
|
349
|
-
"@frame_number = PryStackExplorer.frame_manager(_pry_).binding_index",
|
350
|
-
"exit-all"), out=StringIO.new) do
|
351
|
-
Pry.start(o, :call_stack => call_stack)
|
352
|
-
end
|
353
|
-
o.frame_number.should == call_stack.size - v
|
354
|
-
end
|
355
|
-
end
|
356
|
-
end
|
357
|
-
end
|
358
|
-
end
|
data/test/test_frame_manager.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
Pry.config.output = StringIO.new
|
4
|
-
|
5
|
-
describe PryStackExplorer::FrameManager do
|
6
|
-
|
7
|
-
before do
|
8
|
-
@pry_instance = Pry.new
|
9
|
-
@bindings = [binding, binding, binding, binding]
|
10
|
-
@bindings.each_with_index { |v, i| v.eval("x = #{i}") }
|
11
|
-
@pry_instance.binding_stack.push @bindings.last
|
12
|
-
@frame_manager = PE::FrameManager.new(@bindings, @pry_instance)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "creation" do
|
16
|
-
it "should make bindings accessible via 'bindings' method" do
|
17
|
-
@frame_manager.bindings.should == @bindings
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should set binding_index to 0" do
|
21
|
-
@frame_manager.binding_index.should == 0
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should set current_frame to first frame" do
|
25
|
-
@frame_manager.current_frame.should == @bindings.first
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "FrameManager#change_frame_to" do
|
30
|
-
it 'should change the frame to the given one' do
|
31
|
-
@frame_manager.change_frame_to(1)
|
32
|
-
|
33
|
-
@frame_manager.binding_index.should == 1
|
34
|
-
@frame_manager.current_frame.should == @bindings[1]
|
35
|
-
@pry_instance.binding_stack.last.should == @frame_manager.current_frame
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should accept negative indices when specifying frame' do
|
39
|
-
@frame_manager.change_frame_to(-1)
|
40
|
-
|
41
|
-
# negative index is converted to a positive one inside change_frame_to
|
42
|
-
@frame_manager.binding_index.should == @bindings.size - 1
|
43
|
-
|
44
|
-
@frame_manager.current_frame.should == @bindings[-1]
|
45
|
-
@pry_instance.binding_stack.last.should == @frame_manager.current_frame
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "FrameManager#refresh_frame" do
|
50
|
-
it 'should change the Pry frame to the active one in the FrameManager' do
|
51
|
-
@frame_manager.binding_index = 2
|
52
|
-
@frame_manager.refresh_frame
|
53
|
-
|
54
|
-
@pry_instance.binding_stack.last.should == @frame_manager.current_frame
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "FrameManager is Enumerable" do
|
59
|
-
it 'should perform an Enumerable#map on the frames' do
|
60
|
-
@frame_manager.map { |v| v.eval("x") }.should == (0..(@bindings.size - 1)).to_a
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|