2014-03-14 01:22:21 -04:00
|
|
|
# These specs ensure that Pry doesn't require readline until the first time a
|
|
|
|
# REPL is started.
|
|
|
|
|
|
|
|
require "shellwords"
|
|
|
|
|
2017-11-10 19:12:39 -05:00
|
|
|
RSpec.describe "Readline" do
|
|
|
|
before :all do
|
2018-10-12 12:54:00 -04:00
|
|
|
@ruby = RbConfig.ruby.shellescape
|
2014-03-14 01:22:21 -04:00
|
|
|
@pry_dir = File.expand_path(File.join(__FILE__, '../../../lib')).shellescape
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is not loaded on requiring 'pry'" do
|
2014-03-14 02:31:17 -04:00
|
|
|
code = <<-RUBY
|
2014-03-14 01:22:21 -04:00
|
|
|
require "pry"
|
2014-03-14 02:31:17 -04:00
|
|
|
p defined?(Readline)
|
|
|
|
RUBY
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(`#@ruby -I #@pry_dir -e '#{code}'`).to eq("nil\n")
|
2014-03-14 01:22:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is loaded on invoking 'pry'" do
|
2014-03-14 02:31:17 -04:00
|
|
|
code = <<-RUBY
|
2014-03-14 01:22:21 -04:00
|
|
|
require "pry"
|
2014-04-29 02:00:04 -04:00
|
|
|
Pry.start self, input: StringIO.new("exit-all"), output: StringIO.new
|
2014-03-14 02:31:17 -04:00
|
|
|
puts defined?(Readline)
|
|
|
|
RUBY
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(`#@ruby -I #@pry_dir -e '#{code}'`.end_with?("constant\n")).to eq(true)
|
2014-03-14 01:22:21 -04:00
|
|
|
end
|
2014-04-29 02:00:04 -04:00
|
|
|
|
|
|
|
it "is not loaded on invoking 'pry' if Pry.input is set" do
|
|
|
|
code = <<-RUBY
|
|
|
|
require "pry"
|
|
|
|
Pry.input = StringIO.new("exit-all")
|
|
|
|
Pry.start self, output: StringIO.new
|
|
|
|
p defined?(Readline)
|
|
|
|
RUBY
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(`#@ruby -I #@pry_dir -e '#{code}'`.end_with?("nil\n")).to eq(true)
|
2014-04-29 02:00:04 -04:00
|
|
|
end
|
2014-03-14 01:22:21 -04:00
|
|
|
end
|