3
0
This repository has been archived on 2022-01-17. You can view files and clone it, but cannot push or open issues or pull requests.
recipes-parser/debug.cr
2019-08-08 10:32:09 +02:00

57 lines
1.1 KiB
Crystal

require "option_parser"
require "./src/spec"
recipe_file_name = "some-non-existant-file"
OptionParser.parse! do |parser|
parser.on "-f file", "--file file", "File to parse." do |f|
recipe_file_name = f
end
parser.on "-h", "--help", "Show this help" do
puts parser
exit 0
end
end
options = Hash(String,String).new
options["someoptionexample"] = "option"
specs = Specs.parse recipe_file_name, options
pp! specs
# low level stuff
sectioncontainer = Specs::Section.new "val"
begin
puts sectioncontainer.as_s
puts "(NOT OK) Specs::Section should not accept .as_s"
rescue e
puts "(OK) #{e}"
end
begin
pp! sectioncontainer.as_a_or_s
puts "(NOT OK) Specs::Section should not accept .as_a_or_s"
rescue e
puts "(OK) #{e}"
end
arraycontainer = Specs::ArrayContainer.new Array(String).new.push "value"
begin
puts arraycontainer.as_s
puts "(NOT OK) Specs::ArrayContainer should not accept .as_s"
rescue e
puts "(OK) #{e}"
end
begin
pp! arraycontainer.as_a_or_s
puts "(OK) Specs::ArrayContainer should accept .as_a_or_s"
rescue e
puts "(NOT OK) #{e}"
end