Skip to content

Commit

Permalink
Drop custom error
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlackArroVV committed Nov 26, 2024
1 parent fdd3fca commit 3a454e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
8 changes: 1 addition & 7 deletions lib/que/command_line_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,7 @@ def parse(
end

args.each do |file|
begin
require file
rescue LoadError => e
output.puts "Could not load file '#{file}': #{e}"
output.puts "Your file path should look like you're running a script, e.g. `./path/to/file.rb`" unless file.start_with?('./')
return 1
end
require File.expand_path(file)
end

Que.logger ||= Logger.new(STDOUT)
Expand Down
23 changes: 2 additions & 21 deletions spec/que/command_line_interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def write_file
it "should infer the default require file if it exists" do
filename = write_file

assert_successful_invocation "", default_require_file: "./#{filename}.rb"
assert_successful_invocation "", default_require_file: "#{filename}.rb"

assert_equal(
{filename => true},
Expand Down Expand Up @@ -161,32 +161,13 @@ def write_file

it "should raise an error if any of the files don't exist" do
name = write_file
code = execute "./#{name} ./nonexistent_file"
assert_equal 1, code

assert_equal ["Could not load file './nonexistent_file': cannot load such file -- ./nonexistent_file"], output.messages
assert_raises(LoadError) { execute "#{name} ./nonexistent_file" }

assert_equal(
{name => true},
LOADED_FILES
)
end

it "should raise an error if file is not leading with ./" do
name = write_file
code = execute "#{name}"
assert_equal 1, code

assert_equal [
"Could not load file '#{name}': cannot load such file -- #{name}",
"Your file path should look like you're running a script, e.g. `./path/to/file.rb`"
], output.messages

assert_equal(
{},
LOADED_FILES
)
end
end

describe "should start up a locker" do
Expand Down

0 comments on commit 3a454e8

Please sign in to comment.