Sha256: a5acbe8bce2b7d497a1fb6f32abd502ea6f07d7203a1e305cf0928f2802ee185

Contents?: true

Size: 1.41 KB

Versions: 7

Compression:

Stored size: 1.41 KB

Contents

require 'appsignal/cli'

describe Appsignal::CLI do
  let(:out_stream) { std_stream }
  let(:output) { out_stream.read }
  let(:cli) { Appsignal::CLI }
  before { Dir.stub(:pwd => project_fixture_path) }

  it "should print the help with no arguments, -h and --help" do
    [nil, '-h', '--help'].each do |arg|
      expect do
        capture_stdout(out_stream) do
          cli.run([arg].compact)
        end
      end.to raise_error(SystemExit)

      expect(output).to include 'appsignal <command> [options]'
      expect(output).to include \
        'Available commands: demo, diagnose, install, notify_of_deploy'
    end
  end

  it "should print the version with -v and --version" do
    ['-v', '--version'].each do |arg|
      expect do
        capture_stdout(out_stream) do
          cli.run([arg])
        end
      end.to raise_error(SystemExit)

      expect(output).to include 'AppSignal'
      expect(output).to include '.'
    end
  end

  it "should print a notice if a command does not exist" do
    expect do
      capture_stdout(out_stream) do
        cli.run(['nonsense'])
      end
    end.to raise_error(SystemExit)

    expect(output).to include "Command 'nonsense' does not exist, run "\
      "appsignal -h to see the help"
  end

  describe "diagnose" do
    it "should call Appsignal::Diagnose.install" do
      Appsignal::CLI::Diagnose.should_receive(:run)

      cli.run([
        'diagnose'
      ])
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
appsignal-2.0.6 spec/lib/appsignal/cli_spec.rb
appsignal-2.0.5 spec/lib/appsignal/cli_spec.rb
appsignal-2.0.5.beta.1 spec/lib/appsignal/cli_spec.rb
appsignal-2.1.0.alpha.3 spec/lib/appsignal/cli_spec.rb
appsignal-2.1.0.alpha.2 spec/lib/appsignal/cli_spec.rb
appsignal-2.1.0.alpha.1 spec/lib/appsignal/cli_spec.rb
appsignal-2.0.4 spec/lib/appsignal/cli_spec.rb