Sha256: f51cf8186896758f12f4a1960160726acb68c00b041da6610afe27cbe3dab89e

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe <%= config.dig(:gem, :class) %>::CLI do
  let(:options) { [] }
  let(:command_line) { Array(command).concat options }
  let(:cli) { described_class.start command_line }

  shared_examples_for "a config command", :temp_dir do
    context "with no options" do
      it "prints help text" do
        result = -> { cli }
        expect(&result).to output(/Manage gem configuration./).to_stdout
      end
    end
  end

  shared_examples_for "a version command" do
    it "prints version" do
      result = -> { cli }
      expect(&result).to output(/#{<%= config.dig(:gem, :class) %>::Identity.version_label}\n/).to_stdout
    end
  end

  shared_examples_for "a help command" do
    it "prints usage" do
      result = -> { cli }
      expect(&result).to output(/#{<%= config.dig(:gem, :class) %>::Identity.version_label}\scommands:\n/).to_stdout
    end
  end

  describe "--config" do
    let(:command) { "--config" }
    it_behaves_like "a config command"
  end

  describe "-c" do
    let(:command) { "-c" }
    it_behaves_like "a config command"
  end

  describe "--version" do
    let(:command) { "--version" }
    it_behaves_like "a version command"
  end

  describe "-v" do
    let(:command) { "-v" }
    it_behaves_like "a version command"
  end

  describe "--help" do
    let(:command) { "--help" }
    it_behaves_like "a help command"
  end

  describe "-h" do
    let(:command) { "-h" }
    it_behaves_like "a help command"
  end

  context "with no command" do
    let(:command) { nil }
    it_behaves_like "a help command"
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
gemsmith-12.3.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-12.2.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-12.1.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-12.0.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-11.3.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-11.2.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-11.1.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-11.0.1 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-11.0.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-10.4.2 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-10.4.1 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-10.4.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-10.3.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-10.2.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-10.1.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt
gemsmith-10.0.0 lib/gemsmith/templates/%gem_name%/spec/lib/%gem_path%/cli_spec.rb.tt