From c2ccf482b91e41b504583c1039b011f0f69371f0 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 2 Dec 2009 02:52:37 -0500 Subject: [PATCH] Extract common requires in test files to test/test_helper.rb Run individual spec files with RUBYLIB=test ruby test/ (Thanks mislav) --- Rakefile | 2 ++ test/fake/file_test.rb | 4 +--- test/fake/symlink_test.rb | 4 +--- test/fakefs_test.rb | 4 +--- test/safe_test.rb | 4 +--- test/test_helper.rb | 3 +++ test/verify.rb | 3 +-- 7 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 test/test_helper.rb diff --git a/Rakefile b/Rakefile index e664de4..e20047d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'test') + desc "Run tests" task :test do Dir['test/**/*_test.rb'].each { |file| require file } diff --git a/test/fake/file_test.rb b/test/fake/file_test.rb index 4dc5930..77c4290 100644 --- a/test/fake/file_test.rb +++ b/test/fake/file_test.rb @@ -1,6 +1,4 @@ -$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') -require 'fakefs/safe' -require 'test/unit' +require "test_helper" class FakeFileTest < Test::Unit::TestCase include FakeFS diff --git a/test/fake/symlink_test.rb b/test/fake/symlink_test.rb index d63208b..8eae46d 100644 --- a/test/fake/symlink_test.rb +++ b/test/fake/symlink_test.rb @@ -1,6 +1,4 @@ -$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') -require 'fakefs/safe' -require 'test/unit' +require "test_helper" class FakeSymlinkTest < Test::Unit::TestCase include FakeFS diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 6de4556..a0863a4 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -1,6 +1,4 @@ -$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') -require 'fakefs/safe' -require 'test/unit' +require "test_helper" class FakeFSTest < Test::Unit::TestCase include FakeFS diff --git a/test/safe_test.rb b/test/safe_test.rb index 4d9ace3..9db2de0 100644 --- a/test/safe_test.rb +++ b/test/safe_test.rb @@ -1,6 +1,4 @@ -$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') -require 'fakefs/safe' -require 'test/unit' +require "test_helper" class FakeFSSafeTest < Test::Unit::TestCase def setup diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..745419d --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,3 @@ +$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') +require 'fakefs/safe' +require 'test/unit' diff --git a/test/verify.rb b/test/verify.rb index 8e5cb05..dddb993 100644 --- a/test/verify.rb +++ b/test/verify.rb @@ -3,8 +3,7 @@ # USAGE # # $ ruby test/verify.rb | grep "not implemented" -require 'fakefs/safe' -require 'test/unit' +require "test_helper" class FakeFSVerifierTest < Test::Unit::TestCase (RealFile.methods - Class.new.methods).each do |name|