Sha256: 9338115a4bf86ae6aa63743a94535afdcee499088babb4cca80a4966164a4a80

Contents?: true

Size: 1.16 KB

Versions: 1

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(:configuration) { instance_double 'Reek::Configuration::AppConfiguration' }
    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

1 entries across 1 versions & 1 rubygems

Version Path
reek-4.4.2 spec/reek/cli/command/report_command_spec.rb