Skip to content

Commit

Permalink
Merge pull request #50 from pry/feat-stack-command
Browse files Browse the repository at this point in the history
Rename command to 'stack'
  • Loading branch information
joallard committed Jun 27, 2020
2 parents 2a280ba + 3c3346f commit 497153d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
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

0 comments on commit 497153d

Please sign in to comment.