Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Rename 'show-stack' to 'stack' (#50, #8)

## v0.5.1 (21 May 2020)
* Fix exception in started hook

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Unlike `ruby-debug`, pry-stack_explorer incurs no runtime cost and
enables navigation right up the call-stack to the birth of the
program.

The `up`, `down`, `frame` and `show-stack` commands are provided. See
The `up`, `down`, `frame` and `stack` commands are provided. See
Pry's in-session help for more information on any of these commands.

## Usage
Expand All @@ -26,7 +26,7 @@ Provides commands available in Pry sessions.
Commands:
* `up`/`down` - Move up or down the call stack
* `frame [n]` - Go to frame *n*
* `show-stack` - Show call stack
* `stack` - Show call stack


## Install
Expand Down
11 changes: 8 additions & 3 deletions lib/pry-stack_explorer/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,15 @@ def process
end
end

create_command "show-stack", "Show all frames" do
create_command "stack", "Show all frames" do
include FrameHelpers

banner <<-BANNER
Usage: show-stack [OPTIONS]
Usage: stack [OPTIONS]
Show all accessible stack frames.
e.g: show-stack -v
e.g: stack -v

alias: show-stack
BANNER

def options(opt)
Expand Down Expand Up @@ -309,5 +311,8 @@ def process
end

end

alias_command "show-stack", "stack"

end
end
14 changes: 14 additions & 0 deletions test/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ def bang
Pry.config.hooks.delete_hook(:after_session, :delete_frame_manager)
end

describe "stack" do
it "outputs the call stack" do
output = issue_pry_commands("stack"){ bingbong.bing }

expect(output).to match(/bang.*?bong.*?bing/m)
end

it "supports 'show-stack' as an alias" do
output = issue_pry_commands("show-stack"){ bingbong.bing }

expect(output).to match(/bang.*?bong.*?bing/m)
end
end

describe "up" do
it 'should move up the call stack one frame at a time' do
redirect_pry_io(InputTester.new("@methods << __method__",
Expand Down
6 changes: 3 additions & 3 deletions test/stack_explorer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def o.==(other)

describe ":call_stack option" do
it 'should invoke a session with the call stack set' do
redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do
redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do
@o.bing
end

Expand All @@ -112,7 +112,7 @@ def o.bing() bong end
def o.bong() bang end
def o.bang() Pry.start(binding, :call_stack => false) end

redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do
redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do
o.bing
end

Expand All @@ -125,7 +125,7 @@ def o.alpha() binding end
def o.beta() binding end
def o.gamma() binding end

redirect_pry_io(StringIO.new("show-stack\nexit\n"), out=StringIO.new) do
redirect_pry_io(StringIO.new("stack\nexit\n"), out=StringIO.new) do
Pry.start(binding, :call_stack => [o.beta, o.gamma, o.alpha])
end

Expand Down