Skip to content

Commit 8863ad1

Browse files
committed
fix(spec): stricter expectations for execution error changes
1 parent 87d2184 commit 8863ad1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

spec/command_spec.cr

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ describe Cling::Command do
9898
end
9999

100100
it "fails on missing arguments" do
101-
expect_raises Cling::CommandError do
101+
expect_raises Cling::ExecutionError, "Error while executing command error handler:\n\
102+
Missing required argument: first" do
102103
arguments_command.execute ""
103104
end
104105
end
@@ -109,13 +110,15 @@ describe Cling::Command do
109110
end
110111

111112
it "fails on unknown values" do
112-
expect_raises Cling::ValueNotFound do
113+
expect_raises Cling::ExecutionError, "Error while executing command error handler:\n\
114+
Value not found for key: second" do
113115
arguments_command.execute "foo"
114116
end
115117
end
116118

117119
it "fails on missing options" do
118-
expect_raises Cling::CommandError do
120+
expect_raises Cling::ExecutionError, "Error while executing command error handler:\n\
121+
Missing required options: double-foo, bar" do
119122
options_command.execute ""
120123
end
121124
end
@@ -125,7 +128,8 @@ describe Cling::Command do
125128
end
126129

127130
it "fails on unknown options" do
128-
expect_raises Cling::CommandError do
131+
expect_raises Cling::ExecutionError, "Error while executing command error handler:\n\
132+
Unknown option: double-bar" do
129133
options_command.execute "--double-foo --double-bar"
130134
end
131135
end

src/cling/executor.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module Cling::Executor
4141
def self.handle(command : Command, results : Array(Parser::Result)) : Int32
4242
resolved_command = resolve_command command, results
4343
unless resolved_command
44+
# TODO: should this be an ExecutionError?
4445
command.on_error CommandError.new("Command '#{results.first.value}' not found")
4546
return 1
4647
end

0 commit comments

Comments
 (0)