mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
prevent LoadError being raised when using auto completions + Bundler. (#1896)
* Prevent Bundler from raising a LoadError when accessing input completions. The scenario: - $ mkdir foogem - $ cd foogem - $ echo "source 'https://rubygems.org'" > Gemfile - $ bundle install - $ pry -rbundler/setup - type "foo".<tab> into Pry Notice that a LoadError is raised when trying to require "pry/input_completer". This happens because Pry is not in the Gemfile, so once the sandbox is initialized by Bundler any require for a Pry file is doomed to file. Couple that with the fact that '_pry_.config.completer' is not loaded until a user uses tab completion, and we end up with this broken situation.
This commit is contained in:
parent
dc8aacb26b
commit
85850f47e0
4 changed files with 21 additions and 1 deletions
|
@ -96,6 +96,7 @@ require 'tempfile'
|
|||
require 'pathname'
|
||||
|
||||
require 'pry/version'
|
||||
require 'pry/input_completer'
|
||||
require 'pry/repl'
|
||||
require 'pry/code'
|
||||
require 'pry/ring'
|
||||
|
|
|
@ -115,7 +115,6 @@ class Pry
|
|||
Pry::Config.from_hash(Pry::Command::Ls::DEFAULT_OPTIONS)
|
||||
},
|
||||
completer: proc {
|
||||
require "pry/input_completer"
|
||||
Pry::InputCompleter
|
||||
},
|
||||
gist: proc {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'bundler/setup'
|
||||
Bundler.require :default, :test
|
||||
require 'pry/testable'
|
||||
require 'English'
|
||||
require_relative 'spec_helpers/mock_pry'
|
||||
require_relative 'spec_helpers/repl_tester'
|
||||
|
||||
|
|
19
spec/integration/bundler_spec.rb
Normal file
19
spec/integration/bundler_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
RSpec.describe 'Bundler' do
|
||||
let(:ruby) { RbConfig.ruby.shellescape }
|
||||
let(:pry_dir) { File.expand_path(File.join(__FILE__, '../../../lib')).shellescape }
|
||||
|
||||
context "when Pry requires Gemfile, which doesn't specify Pry as a dependency" do
|
||||
it "loads auto-completion correctly" do
|
||||
code = <<-RUBY
|
||||
require "pry"
|
||||
require "bundler/inline"
|
||||
gemfile(true) do
|
||||
source "https://rubygems.org"
|
||||
end
|
||||
exit 42 if Pry.config.completer
|
||||
RUBY
|
||||
`#{ruby} -I#{pry_dir} -e'#{code}'`
|
||||
expect($CHILD_STATUS.exitstatus).to eq(42)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue