Sha256: b1ed4c5c700f1e1018e71096d72ab436969f4caf31adc0817936c358d95bea90

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

require_relative '../../../spec_helper'
require_lib 'reek/cli/command/report_command'
require_lib 'reek/cli/options'

RSpec.describe Reek::CLI::Command::ReportCommand do
  describe '#execute' do
    let(:options) { Reek::CLI::Options.new [] }

    let(:reporter) { double 'reporter' }
    let(:configuration) { double 'configuration' }
    let(:sources) { [source_file] }

    let(:command) do
      described_class.new(options: options,
                          sources: sources,
                          configuration: configuration)
    end

    before do
      allow(configuration).to receive(:directive_for).and_return({})
    end

    context 'when no smells are found' do
      let(:source_file) { CLEAN_FILE }

      it 'returns a success code' do
        result = command.execute
        expect(result).to eq Reek::CLI::Options::DEFAULT_SUCCESS_EXIT_CODE
      end
    end

    context 'when smells are found' do
      let(:source_file) { SMELLY_FILE }

      it 'returns a failure code' do
        result = Reek::CLI::Silencer.silently do
          command.execute
        end
        expect(result).to eq Reek::CLI::Options::DEFAULT_FAILURE_EXIT_CODE
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reek-4.4.1 spec/reek/cli/command/report_command_spec.rb
reek-4.4.0 spec/reek/cli/command/report_command_spec.rb
reek-4.3.0 spec/reek/cli/command/report_command_spec.rb
reek-4.2.5 spec/reek/cli/command/report_command_spec.rb
reek-4.2.4 spec/reek/cli/command/report_command_spec.rb