Update null value error message for celery script

pull/1245/head
Rick Carlino 2019-06-21 11:35:22 -05:00
parent 637b6a9a9d
commit 8f9358ad1c
3 changed files with 9 additions and 5 deletions

View File

@ -15,6 +15,7 @@ module CeleryScript
BAD_BODY = "Body of '%s' node contains '%s' node. " \
"Expected one of: %s"
T_MISMATCH = "Type mismatch. %s must be one of: %s. Got: %s"
MISSING_VAR = "You must select a Location for the Location Variable."
# Certain CeleryScript pairing errors are more than just a syntax error.
# For instance, A `nothing` node in a `parameter_declaration` is often an
@ -24,8 +25,11 @@ module CeleryScript
FRIENDLY_ERRORS = {
nothing: {
write_pin: "You must select a Peripheral in the Control Peripheral step.",
variable_declaration: "You must provide a value for all parameters",
parameter_declaration: "You must provide a value for all parameters",
variable_declaration: MISSING_VAR,
parameter_declaration: MISSING_VAR,
read_pin: "You must select a Sensor in the Read Sensor step.",
move_to: "You must select a Location in the Move To step.",
execute: "You must select a Sequence in the Execute step.",
},
}.with_indifferent_access

View File

@ -374,7 +374,7 @@ describe Api::SequencesController do
body: [] }
post :create, body: input.to_json, params: { format: :json }
expect(response.status).to eq(422)
expect(json[:body]).to include("must provide a value for all parameters")
expect(json[:body]).to include(CeleryScript::Checker::MISSING_VAR)
end
end
end

View File

@ -23,7 +23,7 @@ describe CeleryScript::Checker do
let (:checker) { CeleryScript::Checker.new(tree, corpus, device) }
it "disallows `change_ownership` on the server-side" do
hash[:body] = [ { kind: "change_ownership", args: { } } ]
hash[:body] = [{ kind: "change_ownership", args: {} }]
expect { checker.run! }.to raise_error("Never.")
end
@ -293,6 +293,6 @@ describe CeleryScript::Checker do
chk = CeleryScript::Checker.new(tree, corpus, device)
expect(chk.valid?).to be false
message = "must provide a value for all parameters"
expect(chk.error.message).to include(message)
expect(chk.error.message).to include(CeleryScript::Checker::MISSING_VAR)
end
end