Skip to content

Commit

Permalink
Test LoadError behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Feb 23, 2017
1 parent 48a9c46 commit 66ec746
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/test_rake_rake_test_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

class TestRakeRakeTestLoader < Rake::TestCase

def setup
super

@loader = File.join @rake_lib, 'rake/rake_test_loader.rb'
end

def test_pattern
orig_loaded_features = $:.dup
FileUtils.touch "foo.rb"
Expand All @@ -10,11 +16,26 @@ def test_pattern

ARGV.replace %w[foo.rb test_*.rb -v]

load File.join(@rake_lib, "rake/rake_test_loader.rb")
load @loader

assert_equal %w[-v], ARGV
ensure
$:.replace orig_loaded_features
end

def test_load_error
expected = <<-EXPECTED
cannot load such file -- #{File.join @tempdir, 'no_such_test_file.rb'}
EXPECTED

assert_output nil, expected do
ARGV.replace %w[no_such_test_file.rb]

assert_raises SystemExit do
load @loader
end
end
end
end

0 comments on commit 66ec746

Please sign in to comment.