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:
commit
dc6ce461bb
2 changed files with 12 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue