From 07f2275a41e92ccc5cc4b3663395a5174e1e45d6 Mon Sep 17 00:00:00 2001 From: Glenn Date: Sun, 13 Oct 2024 15:03:33 +0200 Subject: [PATCH] feat: add new spec files --- spec/parsers/completion_parser_spec.cr | 0 spec/parsers/config_parser_spec.cr | 68 ++++++++++++++++++++++++++ spec/parsers/mapping_parser_spec.cr | 0 spec/parsers/root_parser_spec.cr | 0 4 files changed, 68 insertions(+) create mode 100644 spec/parsers/completion_parser_spec.cr create mode 100644 spec/parsers/config_parser_spec.cr create mode 100644 spec/parsers/mapping_parser_spec.cr create mode 100644 spec/parsers/root_parser_spec.cr diff --git a/spec/parsers/completion_parser_spec.cr b/spec/parsers/completion_parser_spec.cr new file mode 100644 index 0000000..e69de29 diff --git a/spec/parsers/config_parser_spec.cr b/spec/parsers/config_parser_spec.cr new file mode 100644 index 0000000..ac9deee --- /dev/null +++ b/spec/parsers/config_parser_spec.cr @@ -0,0 +1,68 @@ +require "../spec_helper" +require "../../src/parsers/config_parser" + +describe GX::Parsers::ConfigParser do + context "Initialization" do + it "can initialize" do + GX::Parsers::ConfigParser.new.should be_a(GX::Parsers::ConfigParser) + end + end + + context "Functioning" do + it "can parse 'init' subcommand" do + config = GX::Config.new + parser = OptionParser.new + breadcrumbs = GX::Utils::BreadCrumbs.new(["mfm"]) + + GX::Parsers::ConfigParser.new.build(parser, breadcrumbs, config) + + # Test 'init' subcommand recognition + config.mode.should eq(GX::Types::Mode::GlobalTui) # default + parser.parse(["init"]) + config.mode.should eq(GX::Types::Mode::ConfigInit) + + # Test ConfigInitOptions instantiation + config.config_init_options.should be_a(GX::Parsers::Options::ConfigInitOptions) + + # Test banner update + # FIXME: parser.banner.should include("Create initial mfm configuration") + + # Test separator presence + # FIXME: parser.banner.should include("Init options") + end + + it "can parse '-p' / '--path' option for 'init' subcommand" do + config = GX::Config.new + parser = OptionParser.new + breadcrumbs = GX::Utils::BreadCrumbs.new(["mfm"]) + + GX::Parsers::ConfigParser.new.build(parser, breadcrumbs, config) + parser.parse(["init", "-p", "/test/path"]) + pp config + config.config_init_options.try do |opts| + opts.path.should eq("/test/path") + end + + config = GX::Config.new + parser = OptionParser.new + breadcrumbs = GX::Utils::BreadCrumbs.new(["mfm"]) + + GX::Parsers::ConfigParser.new.build(parser, breadcrumbs, config) + parser.parse(["init", "--path", "/test/path/2"]) + config.config_init_options.try do |opts| + opts.path.should eq("/test/path/2") + end + end + + it "should include help line for 'init' subcommand" do + config = GX::Config.new + parser = OptionParser.new + breadcrumbs = GX::Utils::BreadCrumbs.new(["mfm"]) + + GX::Parsers::ConfigParser.new.build(parser, breadcrumbs, config) + + # Test help line presence + # FIXME: parser.banner.should include("Run 'mfm config init --help' for more information on a command.") + end + end +end diff --git a/spec/parsers/mapping_parser_spec.cr b/spec/parsers/mapping_parser_spec.cr new file mode 100644 index 0000000..e69de29 diff --git a/spec/parsers/root_parser_spec.cr b/spec/parsers/root_parser_spec.cr new file mode 100644 index 0000000..e69de29