pry-stack_explorer 0.4.9.2 → 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 +45 -126
- data/lib/pry-stack_explorer/commands.rb +74 -22
- 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 +5 -4
- metadata +34 -50
- data/.gemtest +0 -0
- data/.gitignore +0 -7
- data/.travis.yml +0 -15
- 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 -40
- 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/Rakefile
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
$:.unshift 'lib'
|
2
|
-
|
3
|
-
dlext = RbConfig::CONFIG['DLEXT']
|
4
|
-
direc = File.dirname(__FILE__)
|
5
|
-
|
6
|
-
PROJECT_NAME = "pry-stack_explorer"
|
7
|
-
|
8
|
-
require 'rake/clean'
|
9
|
-
require 'rubygems/package_task'
|
10
|
-
require "#{PROJECT_NAME}/version"
|
11
|
-
|
12
|
-
CLOBBER.include("**/*~", "**/*#*", "**/*.log")
|
13
|
-
CLEAN.include("**/*#*", "**/*#*.*", "**/*_flymake*.*", "**/*_flymake",
|
14
|
-
"**/*.rbc", "**/.#*.*")
|
15
|
-
|
16
|
-
def apply_spec_defaults(s)
|
17
|
-
s.name = PROJECT_NAME
|
18
|
-
s.summary = "Walk the stack in a Pry session"
|
19
|
-
s.version = PryStackExplorer::VERSION
|
20
|
-
s.date = Time.now.strftime '%Y-%m-%d'
|
21
|
-
s.author = "John Mair (banisterfiend)"
|
22
|
-
s.email = 'jrmair@gmail.com'
|
23
|
-
s.description = s.summary
|
24
|
-
s.require_path = 'lib'
|
25
|
-
s.add_dependency("binding_of_caller",">= 0.7")
|
26
|
-
s.add_dependency("pry",">=0.9.11")
|
27
|
-
s.add_development_dependency("bacon","~>1.1.0")
|
28
|
-
s.add_development_dependency('rake', '~> 0.9')
|
29
|
-
s.homepage = "https://github.com/pry/pry-stack_explorer"
|
30
|
-
s.files = `git ls-files`.split("\n")
|
31
|
-
s.test_files = `git ls-files -- test/*`.split("\n")
|
32
|
-
end
|
33
|
-
|
34
|
-
desc "run pry with plugin enabled"
|
35
|
-
task :pry do
|
36
|
-
exec("pry -rubygems -I#{direc}/lib/ -r #{direc}/lib/#{PROJECT_NAME}")
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "Run example"
|
40
|
-
task :example do
|
41
|
-
sh "ruby -rubygems -I#{direc}/lib/ #{direc}/examples/example.rb "
|
42
|
-
end
|
43
|
-
|
44
|
-
desc "Run example2"
|
45
|
-
task :example2 do
|
46
|
-
sh "ruby -I#{direc}/lib/ #{direc}/examples/example2.rb "
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "Run example3"
|
50
|
-
task :example3 do
|
51
|
-
sh "ruby -I#{direc}/lib/ #{direc}/examples/example3.rb "
|
52
|
-
end
|
53
|
-
|
54
|
-
desc "Show version"
|
55
|
-
task :version do
|
56
|
-
puts "PryStackExplorer version: #{PryStackExplorer::VERSION}"
|
57
|
-
end
|
58
|
-
|
59
|
-
desc "run tests"
|
60
|
-
task :default => :test
|
61
|
-
|
62
|
-
desc "run tests"
|
63
|
-
task :test do
|
64
|
-
sh "bacon -Itest -rubygems -a -q"
|
65
|
-
end
|
66
|
-
|
67
|
-
desc "generate gemspec"
|
68
|
-
task :gemspec => "ruby:gemspec"
|
69
|
-
|
70
|
-
namespace :ruby do
|
71
|
-
spec = Gem::Specification.new do |s|
|
72
|
-
apply_spec_defaults(s)
|
73
|
-
s.platform = Gem::Platform::RUBY
|
74
|
-
end
|
75
|
-
|
76
|
-
Gem::PackageTask.new(spec) do |pkg|
|
77
|
-
pkg.need_zip = false
|
78
|
-
pkg.need_tar = false
|
79
|
-
end
|
80
|
-
|
81
|
-
desc "Generate gemspec file"
|
82
|
-
task :gemspec do
|
83
|
-
File.open("#{spec.name}.gemspec", "w") do |f|
|
84
|
-
f << spec.to_ruby
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
desc "build all platform gems at once"
|
90
|
-
task :gems => [:clean, :rmgems, :gemspec, "ruby:gem"]
|
91
|
-
|
92
|
-
desc "remove all platform gems"
|
93
|
-
task :rmgems => ["ruby:clobber_package"]
|
94
|
-
|
95
|
-
desc "reinstall gem"
|
96
|
-
task :reinstall => :gems do
|
97
|
-
sh "gem uninstall pry-stack_explorer" rescue nil
|
98
|
-
sh "gem install -l #{direc}/pkg/#{PROJECT_NAME}-#{PryStackExplorer::VERSION}.gem"
|
99
|
-
end
|
100
|
-
|
101
|
-
task :install => :reinstall
|
102
|
-
|
103
|
-
desc "build and push latest gems"
|
104
|
-
task :pushgems => :gems do
|
105
|
-
chdir("#{File.dirname(__FILE__)}/pkg") do
|
106
|
-
Dir["*.gem"].each do |gemfile|
|
107
|
-
sh "gem push #{gemfile}"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
task :pushgem => :pushgems
|
data/examples/example.rb
DELETED
@@ -1,45 +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 alphabet(y)
|
9
|
-
x = 20
|
10
|
-
b
|
11
|
-
end
|
12
|
-
|
13
|
-
def b
|
14
|
-
x = 30
|
15
|
-
proc {
|
16
|
-
c
|
17
|
-
}.call
|
18
|
-
end
|
19
|
-
|
20
|
-
def c
|
21
|
-
u = 50
|
22
|
-
binding.pry
|
23
|
-
end
|
24
|
-
|
25
|
-
# hello
|
26
|
-
def beta
|
27
|
-
gamma
|
28
|
-
end
|
29
|
-
|
30
|
-
def gamma
|
31
|
-
zeta
|
32
|
-
end
|
33
|
-
|
34
|
-
def zeta
|
35
|
-
vitamin = 100
|
36
|
-
binding.pry
|
37
|
-
end
|
38
|
-
#
|
39
|
-
|
40
|
-
proc {
|
41
|
-
class J
|
42
|
-
alphabet(22)
|
43
|
-
end
|
44
|
-
}.call
|
45
|
-
|
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,40 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: pry-stack_explorer 0.4.9.2 ruby lib
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = "pry-stack_explorer"
|
6
|
-
s.version = "0.4.9.2"
|
7
|
-
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.authors = ["John Mair (banisterfiend)"]
|
10
|
-
s.date = "2015-02-16"
|
11
|
-
s.description = "Walk the stack in a Pry session"
|
12
|
-
s.email = "jrmair@gmail.com"
|
13
|
-
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"]
|
14
|
-
s.homepage = "https://github.com/pry/pry-stack_explorer"
|
15
|
-
s.require_paths = ["lib"]
|
16
|
-
s.rubygems_version = "2.1.11"
|
17
|
-
s.summary = "Walk the stack in a Pry session"
|
18
|
-
s.test_files = ["test/helper.rb", "test/test_commands.rb", "test/test_frame_manager.rb", "test/test_stack_explorer.rb"]
|
19
|
-
|
20
|
-
if s.respond_to? :specification_version then
|
21
|
-
s.specification_version = 4
|
22
|
-
|
23
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
24
|
-
s.add_runtime_dependency(%q<binding_of_caller>, [">= 0.7"])
|
25
|
-
s.add_runtime_dependency(%q<pry>, [">= 0.9.11"])
|
26
|
-
s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
|
27
|
-
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
28
|
-
else
|
29
|
-
s.add_dependency(%q<binding_of_caller>, [">= 0.7"])
|
30
|
-
s.add_dependency(%q<pry>, [">= 0.9.11"])
|
31
|
-
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
32
|
-
s.add_dependency(%q<rake>, ["~> 0.9"])
|
33
|
-
end
|
34
|
-
else
|
35
|
-
s.add_dependency(%q<binding_of_caller>, [">= 0.7"])
|
36
|
-
s.add_dependency(%q<pry>, [">= 0.9.11"])
|
37
|
-
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
38
|
-
s.add_dependency(%q<rake>, ["~> 0.9"])
|
39
|
-
end
|
40
|
-
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
|