Fix sequence / fragment related specs I

pull/1125/head
Rick Carlino 2019-02-14 08:53:32 -06:00
parent 04ae21ac73
commit 16a4d3f730
2 changed files with 35 additions and 11 deletions

View File

@ -86,7 +86,7 @@ describe Api::SequencesController do
expect(generated_result.dig(:args, :foo)).to eq(nil)
end
it 'disallows typos in `locals` declaration' do
it 'disallows bad default_values' do
input = {
name: "Scare Birds",
body: [],
@ -99,7 +99,11 @@ describe Api::SequencesController do
{
kind: "parameter_declaration",
args: {
label: "parent"
label: "parent",
default_value: {
kind: "wait",
args: { milliseconds: 12 }
}
}
}
]
@ -110,7 +114,8 @@ describe Api::SequencesController do
sign_in user
post :create, body: input.to_json, params: {format: :json}
expect(response.status).to eq(422)
expect(json[:body]).to include("not a valid default value")
expect(json[:body]).to include("Expected leaf 'wait' within "\
"'parameter_declaration' to be one of: [")
end
it 'disallows erroneous `locals` declaration' do
@ -133,7 +138,7 @@ describe Api::SequencesController do
post :create, body: input.to_json, params: {format: :json}
expect(response.status).to eq(422)
expctd =
"Expected one of: [:parameter_declaration, :parameter_declaration]"
"Expected one of: [:variable_declaration, :parameter_declaration]"
expect(json[:body]).to include(expctd)
end
@ -149,6 +154,14 @@ describe Api::SequencesController do
kind: "parameter_declaration",
args: {
label: "parent",
default_value: {
kind: "coordinate",
args: {
x: 0,
y: 0,
z: 0
}
}
}
}
]
@ -168,6 +181,7 @@ describe Api::SequencesController do
sign_in user
post :create, body: input.to_json, params: {format: :json}
binding.pry
expect(response.status).to eq(200)
dig_path = [:args, :locals, :body, 0, :args, :label]
generated_result = CeleryScript::FetchCelery
@ -258,7 +272,10 @@ describe Api::SequencesController do
body: [
{
kind: "parameter_declaration",
args: { label: "parent" }
args: {
label: "parent",
default_value: { kind: "sync", args: {} }
}
}
]
}
@ -278,7 +295,7 @@ describe Api::SequencesController do
}
post :create, body: input.to_json, params: {format: :json}
expect(response.status).to eq(422)
expect(json[:body]).to include("not a valid default value")
expect(json[:body]).to include("but got sync")
end
@ -306,6 +323,7 @@ describe Api::SequencesController do
body: [ ]
}
post :create, body: input.to_json, params: {format: :json}
pending("We will need to talk about this one")
expect(response.status).to eq(422)
expect(json[:body]).to include("must provide a value for all parameters")
end

View File

@ -32,14 +32,14 @@ describe Fragments::Create do
args: {},
body: [
{
kind: "parameter_declaration",
kind: "parameter_application",
args: {
label: "myLabel123",
data_value: { kind: "coordinate", args: { x: 0, y: 1, z: 2, } }
}
},
{
kind: "parameter_declaration",
kind: "parameter_application",
args: {
label: "other thing",
data_value: { kind: "tool", args: { tool_id: tool.id } }
@ -59,10 +59,17 @@ describe Fragments::Create do
a2z = (('a'..'z').to_a + ('0'..'9').to_a)
body = a2z.map do |label|
{
kind: "parameter_declaration",
kind: "parameter_application",
args: {
label: label,
data_value: { kind: "coordinate", args: { x: 0, y: 1, z: 2, } }
data_value: {
kind: "coordinate",
args: {
x: 0,
y: 1,
z: 2,
}
}
}
}
end
@ -77,7 +84,6 @@ describe Fragments::Create do
fragment = Fragments::Create.run!(device: device,
owner: farm_event,
flat_ast: Fragments::Preprocessor.run!(origin))
# Warm the cache up with two dry-runs:
Fragments::Show.run!(owner: farm_event)
Fragments::Show.run!(owner: farm_event)