Sha256: 5bae687a62528ee4d14b95f70b1f126e1b661749e1395a03cc265841ae36c8ba

Contents?: true

Size: 1.71 KB

Versions: 4

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

describe Phare::CLI do
  let(:described_class) { Phare::CLI }

  let(:cli) { described_class.new(env, argv) }
  let(:argv) { [] }
  let(:run!) { cli.run }
  let(:env) { {} }

  describe :run do
    context 'with version flag' do
      let(:cli) { described_class.new(env, ['--version']) }

      before do
        expect(Phare).to receive(:puts).with Phare::VERSION
      end

      it { expect { run! }.to exit_with_code(0) }
    end

    context 'with legacy code check skipping' do
      let(:env) { { 'SKIP_CODE_CHECK' => '1' } }
      it { expect { run! }.to exit_with_code(0) }
    end

    context 'with code check skipping' do
      let(:env) { { 'SKIP_PHARE' => '1' } }
      it { expect { run! }.to exit_with_code(0) }
    end

    context 'without code check skipping' do
      let(:env) { {} }

      context 'with suite errors' do
        before do
          expect(cli.suite).to receive(:run)
          expect(cli.suite).to receive(:status).and_return(1337)
        end

        it { expect { run! }.to exit_with_code(1) }
      end

      context 'without suite errors' do
        before do
          expect(cli.suite).to receive(:run)
          expect(cli.suite).to receive(:status).and_return(0)
        end

        it { expect { run! }.to exit_with_code(0) }
      end
    end
  end

  describe :parsed_options do
    let(:parsed_options) { cli.send(:parsed_options, argv) }

    before do
      expect(cli).to receive(:parsed_options_from_yaml).and_return(skip: ['scsslint'])
      expect(cli).to receive(:parsed_options_from_arguments).and_return(skip: ['rubocop'])
    end

    it { expect(parsed_options[:directory]).to eql Dir.pwd }
    it { expect(parsed_options[:skip]).to eql [:rubocop] }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
phare-1.0.1 spec/phare/cli_spec.rb
phare-1.0.0 spec/phare/cli_spec.rb
phare-0.7.1 spec/phare/cli_spec.rb
phare-0.7 spec/phare/cli_spec.rb