Skip to content

Commit

Permalink
Merge pull request #250 from dylanahsmith/re-raise-load-error-without…
Browse files Browse the repository at this point in the history
…-path

Re-raise a LoadError that didn't come from require in the test loader
  • Loading branch information
hsbt authored Jan 26, 2018
2 parents e5c5ac5 + da34100 commit e2934c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rake/rake_test_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
false
end
rescue LoadError => e
raise unless e.path
abort "\nFile does not exist: #{e.path}\n\n"
end
end
Expand Down
16 changes: 15 additions & 1 deletion test/test_rake_rake_test_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_pattern
$:.replace orig_loaded_features
end

def test_load_error
def test_load_error_from_require
out, err = capture_io do
ARGV.replace %w[no_such_test_file.rb]

Expand All @@ -44,4 +44,18 @@ def test_load_error

assert_match expected, err
end

def test_load_error_raised_explicitly
File.write("error_test.rb", "raise LoadError, 'explicitly raised'")
out, err = capture_io do
ARGV.replace %w[error_test.rb]

exc = assert_raises(LoadError) do
load @loader
end
assert_equal "explicitly raised", exc.message
end
assert_empty out
assert_empty err
end
end

0 comments on commit e2934c0

Please sign in to comment.