Corpus tracks values

pull/1125/head
Rick Carlino 2019-02-19 10:21:45 -06:00
parent 3b7f9da9ae
commit 3f2c02bd7d
4 changed files with 27 additions and 5 deletions

View File

@ -28,7 +28,8 @@ module CeleryScript
self
end
def value(*x)
def value(name, values)
@value_def_list[name] = ValueSpecification.new(name, values)
self
end

View File

@ -1,6 +1,3 @@
# Define how a particular argument should behave in a corpus.
# Remember: In CeleryScript, and arg is a `key` (string) and a `value` (either
# a primitive data type or a fully-formed CS node)
module CeleryScript
class EnumSpecification
attr_reader :name, :allowed_values

View File

@ -0,0 +1,14 @@
module CeleryScript
class ValueSpecification
attr_reader :name, :values
def initialize(name, values)
@name = name
@values = values
end
def as_json(optns)
{ "name" => name }
end
end
end

View File

@ -238,5 +238,15 @@ describe CeleryScript::Corpus do
expect(enums.first.fetch("allowed_values")).to eq(list)
end
# it 'has values'
it 'has values' do
args = [name = :whatever, list = [Symbol, Hash]]
c = CeleryScript::Corpus.new.value(*args)
json = c.as_json
values = json.fetch(:values)
expect(values.length).to eq(1)
expect(values.first.fetch("name")).to eq(name)
expect(values.first.keys.length).to eq(1)
end
it 'assigns tags to nodes'
end