diff options
| author | Benjamin Sanders <ben@Benjamins-MacBook-Pro.local> | 2025-10-11 10:34:24 -0400 |
|---|---|---|
| committer | Benjamin Sanders <ben@Benjamins-MacBook-Pro.local> | 2025-10-11 10:34:24 -0400 |
| commit | 5571dc766e2143e39762ff0b47c41d1c2e154f4c (patch) | |
| tree | f4f124d314a7e76c04484515aa0fd1f2e271a601 /vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/presenter_spec.rb | |
| parent | 359f3309c97fc894b63e0a295c76ab298504d635 (diff) | |
Vendor bundled gems for deployment
Diffstat (limited to 'vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/presenter_spec.rb')
| -rw-r--r-- | vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/presenter_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/presenter_spec.rb b/vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/presenter_spec.rb new file mode 100644 index 0000000..b72dbae --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/presenter_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require "spec_helper" + +describe(Mercenary::Presenter) do + let(:supercommand) { Mercenary::Command.new(:script_name) } + let(:command) { Mercenary::Command.new(:subcommand, supercommand) } + let(:presenter) { described_class.new(command) } + + before(:each) do + supercommand.option "version", "-v", "--version", "Show version" + supercommand.option "help", "-h", "--help", "Help!" + + command.version "1.4.2" + command.description "Do all the things." + command.option "help", "-h", "--help", "Help!" + command.option "one", "-1", "--one", "The first option" + command.option "two", "-2", "--two", "The second option" + command.alias :cmd + supercommand.commands[command.name] = command + end + + it "knows how to present the command" do + expect(presenter.command_presentation).to eql("script_name subcommand 1.4.2 -- Do all the things.\n\nUsage:\n\n script_name subcommand\n\nOptions:\n -1, --one The first option\n -2, --two The second option\n -v, --version Show version\n -h, --help Help!") + end + + it "knows how to present the subcommands, without duplicates for aliases" do + expect(described_class.new(supercommand).subcommands_presentation).to eql(" subcommand, cmd Do all the things.") + end + + it "knows how to present the usage" do + expect(presenter.usage_presentation).to eql(" script_name subcommand") + end + + it "knows how to present the options" do + expect(presenter.options_presentation).to eql(" -1, --one The first option\n -2, --two The second option\n -v, --version Show version\n -h, --help Help!") + end + + it "allows you to say print_* instead of *_presentation" do + expect(presenter.print_usage).to eql(presenter.usage_presentation) + expect(presenter.print_subcommands).to eql(presenter.subcommands_presentation) + expect(presenter.print_options).to eql(presenter.options_presentation) + expect(presenter.print_command).to eql(presenter.command_presentation) + end +end |
