Support %cat checking $LOAD_PATH directories.
This commit is contained in:
parent
f72ff1ab88
commit
46c5e800ce
|
@ -124,6 +124,9 @@ class Pry
|
|||
abs_path = [File.expand_path(filename, Dir.pwd),
|
||||
File.expand_path(filename, Pry::INITIAL_PWD)
|
||||
].detect { |path| File.readable?(path) }
|
||||
abs_path ||= $LOAD_PATH.map do |path|
|
||||
File.expand_path(File.basename(filename), path)
|
||||
end.detect { |path| File.readable?(path) if path }
|
||||
abs_path or raise MethodSource::SourceNotFoundError,
|
||||
"Cannot open #{filename.inspect} for reading."
|
||||
end
|
||||
|
|
|
@ -46,6 +46,11 @@ describe Pry::Code do
|
|||
Pry::Code.from_file(File.basename(__FILE__)).code_type.should == :ruby
|
||||
end
|
||||
end
|
||||
|
||||
should 'find files that are relative to a directory in the $LOAD_PATH' do
|
||||
$LOAD_PATH << 'spec'
|
||||
Pry::Code.from_file(File.basename(__FILE__)).code_type.should == :ruby
|
||||
end
|
||||
end
|
||||
|
||||
describe '.from_method' do
|
||||
|
|
Loading…
Reference in New Issue