summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBarrett Ingram <bingram@eab.com>2020-03-22 14:43:20 -0500
committerBarrett Ingram <bingram@eab.com>2020-03-22 14:43:20 -0500
commita164846c4dc69386432a19a684ea64c2a9e737b5 (patch)
treeaa49fac24fb64c4e70b6a5b4a2cdbb8295e2b8b9 /spec
parent0b3b71e71415f9e7a234fe97466c61d9641dc7da (diff)
downloadpry-a164846c4dc69386432a19a684ea64c2a9e737b5.tar.gz
Improve help listing for regex aliases
This commit improves the appearance of regex aliases in the help index by storing the result of calling #inspect on the regex as the listing. For example, consider the `whereami` alias `/whereami[!?]+/`. Previously this would appear in the help index as `(?-mix:whereami[!?]+)`. This commit fixes this so it appears as `/whereami[!?]+/`.
Diffstat (limited to 'spec')
-rw-r--r--spec/command_set_spec.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/spec/command_set_spec.rb b/spec/command_set_spec.rb
index fc67d140..c5243999 100644
--- a/spec/command_set_spec.rb
+++ b/spec/command_set_spec.rb
@@ -185,11 +185,16 @@ RSpec.describe Pry::CommandSet do
expect(new_command.description).to eq('Alias for `test`')
end
- it "sets aliased command's listing" do
+ it "sets aliased command's listing for string alias" do
new_command = subject.alias_command('new-test', 'test')
expect(new_command.options).to include(listing: 'new-test')
end
+ it "sets aliased command's listing for regex alias" do
+ new_command = subject.alias_command(/test[!?]+/, 'test')
+ expect(new_command.options[:listing].to_s).to eq('/test[!?]+/')
+ end
+
it "sets group for the aliased command automatically" do
new_command = subject.alias_command('new-test', 'test')
expect(new_command.group).to eq('Aliases')