Sha256: 6c7ce6dc0acf10f489785e94b68acd086884a9b146be8ff594bfb3f9734c96da

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

require "spec_helper"

RSpec.describe <%= configuration.project_namespaced_class %>::CLI::Shell do
  using Refinements::Pathnames
  using AutoInjector::Stub

  subject(:shell) { described_class.new }

  include_context "with application dependencies"

  before { <%= configuration.project_namespaced_class %>::CLI::Actions::Import.stub configuration:, kernel:, logger: }

  after { <%= configuration.project_namespaced_class %>::CLI::Actions::Import.unstub :configuration, :kernel, :logger }

  describe "#call" do
    it "edits configuration" do
      shell.call %w[--config edit]
      expect(kernel).to have_received(:system).with("$EDITOR ")
    end

    it "views configuration" do
      shell.call %w[--config view]
      expect(kernel).to have_received(:system).with("cat ")
    end

    it "prints version" do
      shell.call %w[--version]
      expect(logger.reread).to match(/<%= configuration.project_label %>\s\d+\.\d+\.\d+/)
    end

    it "prints help (usage)" do
      shell.call %w[--help]
      expect(logger.reread).to match(/<%= configuration.project_label %>.+USAGE.+/m)
    end

    it "prints usage when no options are given" do
      shell.call
      expect(logger.reread).to match(/<%= configuration.project_label %>.+USAGE.+/m)
    end

    it "prints error with invalid option" do
      shell.call %w[--bogus]
      expect(logger.reread).to match(/invalid option.+bogus/)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gemsmith-18.6.0 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.5.0 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.4.0 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.3.0 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.2.0 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.1.1 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.1.0 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.0.2 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.0.1 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb
gemsmith-18.0.0 lib/gemsmith/templates/%project_name%/spec/lib/%project_path%/cli/shell_spec.rb.erb