Fix farm event create specs
parent
86ce520cdd
commit
04ae21ac73
|
@ -14,13 +14,13 @@ module CeleryScript
|
|||
T_MISMATCH = "Type mismatch. %s must be one of: %s. Got: %s"
|
||||
|
||||
# Certain CeleryScript pairing errors are more than just a syntax error.
|
||||
# For instance, A `nothing` node in a `variable_declaration` is often an
|
||||
# For instance, A `nothing` node in a `parameter_declaration` is often an
|
||||
# indication that the user did not fill out a value for a variable. In these
|
||||
# rare cases, we muct provide information beyond what is found in the
|
||||
# BAD_LEAF template.
|
||||
FRIENDLY_ERRORS = {
|
||||
nothing: {
|
||||
variable_declaration: "You must provide a value for all parameters"
|
||||
parameter_declaration: "You must provide a value for all parameters"
|
||||
}
|
||||
}.with_indifferent_access
|
||||
attr_reader :tree, :corpus, :device
|
||||
|
|
|
@ -213,7 +213,7 @@ module CeleryScriptSettingsBag
|
|||
.node(:channel, [:channel_name])
|
||||
.node(:wait, [:milliseconds])
|
||||
.node(:send_message, [:message, :message_type], [:channel])
|
||||
.node(:execute, [:sequence_id], [:variable_declaration])
|
||||
.node(:execute, [:sequence_id], [:parameter_application])
|
||||
.node(:_if, [:lhs, :op, :rhs, :_then, :_else], [:pair])
|
||||
.node(:sequence, [:version, :locals], STEPS)
|
||||
.node(:home, [:speed, :axis], [])
|
||||
|
@ -246,14 +246,15 @@ module CeleryScriptSettingsBag
|
|||
.node(:remove_farmware, [:package])
|
||||
.node(:scope_declaration, [], SCOPE_DECLARATIONS)
|
||||
.node(:identifier, [:label])
|
||||
.node(:variable_declaration, [:label, :data_value], [])
|
||||
.node(:variable_declaration, [:label, :data_value], []) # <= duplicate nodes
|
||||
.node(:parameter_application, [:label, :data_value], []) # <= not a mistake - RC
|
||||
.node(:parameter_declaration, [:label, :default_value], [])
|
||||
.node(:set_servo_angle, [:pin_number, :pin_value], [])
|
||||
.node(:change_ownership, [], [:pair])
|
||||
.node(:dump_info, [], [])
|
||||
.node(:install_first_party_farmware, [])
|
||||
.node(:internal_farm_event, [], [:variable_declaration])
|
||||
.node(:internal_regimen, [], SCOPE_DECLARATIONS)
|
||||
.node(:internal_farm_event, [], [:parameter_application])
|
||||
.node(:internal_regimen, [], [:parameter_application])
|
||||
.node(:internal_entry_point, [], [])
|
||||
.node(:every_point, [:every_point_type], [])
|
||||
.node(:resource_update, RESOURCE_UPDATE_ARGS) do |x|
|
||||
|
|
|
@ -24,7 +24,7 @@ describe Api::FarmEventsController do
|
|||
sign_in user
|
||||
payload = generic_fe.merge(body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_application",
|
||||
args: {
|
||||
label: "wow",
|
||||
data_value: {
|
||||
|
@ -48,8 +48,11 @@ describe Api::FarmEventsController do
|
|||
wrong = { kind: "identifier", args: { label: "wrong" } }
|
||||
body = [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
args: { label: "also_wrong", data_value: wrong }
|
||||
kind: "parameter_application",
|
||||
args: {
|
||||
label: "also_wrong",
|
||||
data_value: wrong
|
||||
}
|
||||
}
|
||||
]
|
||||
body = generic_fe.merge(body: body)
|
||||
|
@ -64,11 +67,11 @@ describe Api::FarmEventsController do
|
|||
body = generic_fe.merge({
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_application",
|
||||
args: { kind: "tool", args: { tool_id: 0 } }
|
||||
},
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_application",
|
||||
args: { kind: "tool", args: { tool_id: 0 } }
|
||||
},
|
||||
]
|
||||
|
@ -77,7 +80,7 @@ describe Api::FarmEventsController do
|
|||
expect(response.status).to eq(422)
|
||||
expect(json.keys).to include(:farm_event)
|
||||
expect(json[:farm_event])
|
||||
.to include("'variable_declaration' to have a 'label'")
|
||||
.to include("'parameter_application' to have a 'label'")
|
||||
end
|
||||
|
||||
it 'makes a farm_event' do
|
||||
|
|
|
@ -55,7 +55,7 @@ describe Api::FarmEventsController do
|
|||
args: {},
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_application",
|
||||
args: {
|
||||
label: "foo",
|
||||
data_value: { kind: "coordinate", args: { x: 0, y: 0, z: 0 } }
|
||||
|
@ -105,7 +105,7 @@ describe Api::FarmEventsController do
|
|||
expect(fe.fragment).to be(nil)
|
||||
body = [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_application",
|
||||
args: {
|
||||
label: "bar",
|
||||
data_value: {
|
||||
|
|
|
@ -16,7 +16,7 @@ describe Api::RegimensController do
|
|||
color: "red",
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "parent",
|
||||
data_value: {
|
||||
|
@ -32,7 +32,7 @@ describe Api::RegimensController do
|
|||
expect(response.status).to eq(200)
|
||||
declr = json.fetch(:body).first
|
||||
expect(declr).to be
|
||||
expect(declr.fetch(:kind)).to eq("variable_declaration")
|
||||
expect(declr.fetch(:kind)).to eq("parameter_declaration")
|
||||
path = [:args, :data_value, :args, :every_point_type]
|
||||
expect(declr.dig(*path)).to eq("Plant")
|
||||
end
|
||||
|
@ -68,7 +68,7 @@ describe Api::RegimensController do
|
|||
color: "red",
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "parent",
|
||||
data_value: { kind: "nothing", args: { } }
|
||||
|
|
|
@ -45,7 +45,7 @@ describe Api::RegimensController do
|
|||
|
||||
var_declr = [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "parent",
|
||||
data_value: {
|
||||
|
@ -66,7 +66,7 @@ describe Api::RegimensController do
|
|||
color: "blue",
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "parent",
|
||||
data_value: {
|
||||
|
|
|
@ -133,7 +133,7 @@ describe Api::SequencesController do
|
|||
post :create, body: input.to_json, params: {format: :json}
|
||||
expect(response.status).to eq(422)
|
||||
expctd =
|
||||
"Expected one of: [:variable_declaration, :parameter_declaration]"
|
||||
"Expected one of: [:parameter_declaration, :parameter_declaration]"
|
||||
expect(json[:body]).to include(expctd)
|
||||
end
|
||||
|
||||
|
@ -291,7 +291,7 @@ describe Api::SequencesController do
|
|||
args: { },
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "x",
|
||||
data_value: {
|
||||
|
|
|
@ -17,7 +17,13 @@ class FakeSequence < Mutations::Command
|
|||
args: {},
|
||||
body: [{
|
||||
kind: "parameter_declaration",
|
||||
args: { label: "parent" }
|
||||
args: {
|
||||
label: "parent",
|
||||
default_value: {
|
||||
kind: "coordinate",
|
||||
args: { x: 4, y: 4, z: 4, }
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ describe CeleryScript::Checker do
|
|||
:args=>{},
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "parent",
|
||||
data_value: { kind: "coordinate", args: { x: 0, y: 0, z: 0 } }
|
||||
|
@ -263,7 +263,7 @@ describe CeleryScript::Checker do
|
|||
:args=>{},
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "parent",
|
||||
data_value: {
|
||||
|
|
|
@ -9,7 +9,7 @@ describe CeleryScript::Checker do
|
|||
it "disallows the use of `identifier` nodes" do
|
||||
params = { kind: "internal_farm_event",
|
||||
args: {},
|
||||
body: [ {kind: "variable_declaration",
|
||||
body: [ {kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "foo",
|
||||
data_value: {
|
||||
|
@ -28,7 +28,7 @@ describe CeleryScript::Checker do
|
|||
it "runs through a syntactically valid program" do
|
||||
body = [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "tool",
|
||||
data_value: {
|
||||
|
@ -40,7 +40,7 @@ describe CeleryScript::Checker do
|
|||
}
|
||||
},
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "coordinate",
|
||||
data_value: {
|
||||
|
@ -54,7 +54,7 @@ describe CeleryScript::Checker do
|
|||
}
|
||||
},
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "point",
|
||||
data_value: {
|
||||
|
|
|
@ -15,14 +15,14 @@ describe Fragments::Create do
|
|||
args: {},
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "myLabel123",
|
||||
data_value: { kind: "coordinate", args: { x: 0, y: 1, z: 2, } }
|
||||
}
|
||||
},
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "other thing",
|
||||
data_value: { kind: "tool", args: { tool_id: tool.id } }
|
||||
|
@ -38,8 +38,8 @@ describe Fragments::Create do
|
|||
pair = variable2.arg_set.standard_pairs.first
|
||||
expect(entry.kind.value).to eq("internal_farm_event")
|
||||
expect(entry.next.kind.value).to eq("internal_entry_point")
|
||||
expect(entry.body.kind.value).to eq("variable_declaration")
|
||||
expect(variable2.kind.value).to eq("variable_declaration")
|
||||
expect(entry.body.kind.value).to eq("parameter_declaration")
|
||||
expect(variable2.kind.value).to eq("parameter_declaration")
|
||||
expect(variable2.next.kind.value).to eq("internal_entry_point")
|
||||
expect(pair.arg_name.value).to eq("data_value")
|
||||
expect(pair.node.kind.value).to eq("tool")
|
||||
|
@ -57,7 +57,7 @@ describe Fragments::Create do
|
|||
:__parent => H[0],
|
||||
:__body => H[2],
|
||||
:__next => H[0] },
|
||||
{ :__KIND__ => "variable_declaration",
|
||||
{ :__KIND__ => "parameter_declaration",
|
||||
:__parent => H[1],
|
||||
:label => "foo",
|
||||
:__data_value => H[3],
|
||||
|
@ -83,7 +83,7 @@ describe Fragments::Create do
|
|||
nodes = fragment.nodes.sort_by(&:id);
|
||||
expect(nodes[0].kind.value).to eq("internal_entry_point")
|
||||
expect(nodes[1].kind.value).to eq("internal_farm_event")
|
||||
expect(nodes[2].kind.value).to eq("variable_declaration")
|
||||
expect(nodes[2].kind.value).to eq("parameter_declaration")
|
||||
expect(nodes[3].kind.value).to eq("identifier")
|
||||
expect(nodes[3].arg_set.primitive_pairs.count).to eq 2
|
||||
Node.destroy_all
|
||||
|
|
|
@ -32,14 +32,14 @@ describe Fragments::Create do
|
|||
args: {},
|
||||
body: [
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "myLabel123",
|
||||
data_value: { kind: "coordinate", args: { x: 0, y: 1, z: 2, } }
|
||||
}
|
||||
},
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: "other thing",
|
||||
data_value: { kind: "tool", args: { tool_id: tool.id } }
|
||||
|
@ -59,7 +59,7 @@ describe Fragments::Create do
|
|||
a2z = (('a'..'z').to_a + ('0'..'9').to_a)
|
||||
body = a2z.map do |label|
|
||||
{
|
||||
kind: "variable_declaration",
|
||||
kind: "parameter_declaration",
|
||||
args: {
|
||||
label: label,
|
||||
data_value: { kind: "coordinate", args: { x: 0, y: 1, z: 2, } }
|
||||
|
|
Loading…
Reference in New Issue