1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Merge pull request #2098 from barrettkingram/whereami_bug_fix

Fix whereami -c bug when class definition is not beginning of line
This commit is contained in:
Kyrylo Silin 2020-03-20 19:52:23 +08:00 committed by GitHub
commit dc6ce461bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -103,7 +103,7 @@ class Pry
def class_regexes
mod_type_string = wrapped.class.to_s.downcase
[/^\s*#{mod_type_string}\s+(?:(?:\w*)::)*?#{wrapped.name.split(/::/).last}/,
[/(^|=)\s*#{mod_type_string}\s+(?:(?:\w*)::)*?#{wrapped.name.split(/::/).last}/,
/^\s*(::)?#{wrapped.name.split(/::/).last}\s*?=\s*?#{wrapped.class}/,
/^\s*(::)?#{wrapped.name.split(/::/).last}\.(class|instance)_eval/]
end

View file

@ -218,6 +218,17 @@ describe "whereami" do
end
Object.remove_const(:Cor)
end
it 'should show class when -c option used, and beginning of the class is on the' \
'same line as another expression' do
out = class Cor
def blimey; end
pry_eval(binding, 'whereami -c')
end
expect(out).to match(/class Cor/)
expect(out).to match(/blimey/)
Object.remove_const(:Cor)
end
end
it 'should not show line numbers or marker when -n switch is used' do