From fad6cf997704688d535a5b45e0c6a361a7c69cf1 Mon Sep 17 00:00:00 2001 From: Lee Jarvis Date: Fri, 29 Apr 2011 15:55:35 +0100 Subject: [PATCH] simplify test running do not require rubygems inside tests shift test into load path move test logic into helper so any new tests just require this helper and can also be run independently --- Rakefile | 2 +- test/test.rb | 11 ++--------- test/test_helper.rb | 7 +++++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Rakefile b/Rakefile index 05aca9e9..22f8e6e1 100644 --- a/Rakefile +++ b/Rakefile @@ -31,7 +31,7 @@ def apply_spec_defaults(s) end task :test do - sh "bacon #{direc}/test/test.rb" + sh "bacon -Itest -rubygems test/test.rb" end desc "run pry" diff --git a/test/test.rb b/test/test.rb index fa4fd662..c212e25c 100644 --- a/test/test.rb +++ b/test/test.rb @@ -1,11 +1,4 @@ -direc = File.dirname(__FILE__) - -$LOAD_PATH.unshift "#{direc}/../lib" - -require 'rubygems' -require 'bacon' -require "pry" -require "#{direc}/test_helper" +require 'test_helper' puts "Ruby Version #{RUBY_VERSION}" puts "Testing Pry #{Pry::VERSION}" @@ -135,7 +128,7 @@ describe Pry do it "should run the rc file only once" do Pry.should_load_rc = true - Pry::RC_FILES << "#{direc}/testrc" + Pry::RC_FILES << File.expand_path("../testrc", __FILE__) Pry.start(self, :input => StringIO.new("exit\n"), :output => Pry::NullOutput) TEST_RC.should == [0] diff --git a/test/test_helper.rb b/test/test_helper.rb index 351e3d90..67594c19 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,10 @@ +unless Object.const_defined? 'Pry' + $:.unshift File.expand_path '../../lib', __FILE__ + require 'pry' +end + +require 'bacon' + # Ensure we do not execute any rc files Pry::RC_FILES.clear Pry.color = false