From a0a462573e433c324fdd5c1d8bc0bef61d71d613 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Thu, 13 Mar 2014 22:22:21 -0700 Subject: [PATCH] Move Readline-loading specs inside normal suite This simplifies our Rake and Travis config. --- .travis.yml | 1 - Rakefile | 2 +- spec/isolation/readline_spec.rb | 17 ----------------- spec/regression/readline_spec.rb | 28 ++++++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 19 deletions(-) delete mode 100644 spec/isolation/readline_spec.rb create mode 100644 spec/regression/readline_spec.rb diff --git a/.travis.yml b/.travis.yml index 321fb5eb..0faaabab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ rvm: script: - rake spec - - bundle exec bacon spec/isolation/readline_spec.rb matrix: allow_failures: diff --git a/Rakefile b/Rakefile index 6bc2c58d..d00a9369 100644 --- a/Rakefile +++ b/Rakefile @@ -33,7 +33,7 @@ task :test do if explicit_list = ENV['run'] explicit_list.split(',') else - (Dir['spec/**/*_spec.rb'] - Dir["spec/isolation/*_spec.rb"]).shuffle! + Dir['spec/**/*_spec.rb'].shuffle! end run_specs paths end diff --git a/spec/isolation/readline_spec.rb b/spec/isolation/readline_spec.rb deleted file mode 100644 index 7f5fb79f..00000000 --- a/spec/isolation/readline_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "bundler/setup" -require "bacon" -describe "Readline" do - describe "on require of 'pry'" do - it "is not made available" do - require('pry').should.be.true - defined?(Readline).should.be.nil - end - end - - describe "on invoke of 'pry'" do - it "is made available" do - Pry.start self, input: StringIO.new("exit-all\n"), output: StringIO.new - defined?(Readline).should == "constant" - end - end -end diff --git a/spec/regression/readline_spec.rb b/spec/regression/readline_spec.rb new file mode 100644 index 00000000..d268e05a --- /dev/null +++ b/spec/regression/readline_spec.rb @@ -0,0 +1,28 @@ +# These specs ensure that Pry doesn't require readline until the first time a +# REPL is started. + +require "helper" +require "shellwords" + +describe "Readline" do + before do + @ruby = RbConfig.ruby.shellescape + @pry_dir = File.expand_path(File.join(__FILE__, '../../../lib')).shellescape + end + + it "is not loaded on requiring 'pry'" do + `#@ruby -I #@pry_dir -e ' + require "pry" + p defined? Readline + '`.should == "nil\n" + end + + it "is loaded on invoking 'pry'" do + `#@ruby -I #@pry_dir -e ' + require "pry" + Pry.start self, input: StringIO.new("exit-all\n"), output: StringIO.new + puts # put newline after ANSI junk printed by readline + p defined?(Readline) + '`.split("\n").last.should == '"constant"' + end +end