mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
e61354693f
Just discovered this nice feature of RSpec where it can load all files for us. Works with `bundle exec rake` and `bundle exec rspec spec/file_spec.rb`, which covers all use cases.
38 lines
1 KiB
Ruby
38 lines
1 KiB
Ruby
# These specs ensure that Pry doesn't require readline until the first time a
|
|
# REPL is started.
|
|
|
|
require "shellwords"
|
|
|
|
RSpec.describe "Readline" do
|
|
before :all do
|
|
@ruby = RbConfig.ruby.shellescape
|
|
@pry_dir = File.expand_path(File.join(__FILE__, '../../../lib')).shellescape
|
|
end
|
|
|
|
it "is not loaded on requiring 'pry'" do
|
|
code = <<-RUBY
|
|
require "pry"
|
|
p defined?(Readline)
|
|
RUBY
|
|
expect(`#@ruby -I #@pry_dir -e '#{code}'`).to eq("nil\n")
|
|
end
|
|
|
|
it "is loaded on invoking 'pry'" do
|
|
code = <<-RUBY
|
|
require "pry"
|
|
Pry.start self, input: StringIO.new("exit-all"), output: StringIO.new
|
|
puts defined?(Readline)
|
|
RUBY
|
|
expect(`#@ruby -I #@pry_dir -e '#{code}'`.end_with?("constant\n")).to eq(true)
|
|
end
|
|
|
|
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
|
|
expect(`#@ruby -I #@pry_dir -e '#{code}'`.end_with?("nil\n")).to eq(true)
|
|
end
|
|
end
|