Sha256: 795c2f2d9e8a4c2eb4b692c8d0c133ad670ffd5dd22ea835b441d64c96c0e663

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

RSpec.describe PolishGeeks::DevTools::Commands::RequiredFiles do
  subject { described_class.new }

  let(:config) { double }

  describe '#execute' do
    context 'when required_files_include is set' do
      let(:required_files_include) { 'REVIEW.md' }
      let(:config) do
        instance_double(
          PolishGeeks::DevTools::Config,
          required_files_include: [required_files_include]
        )
      end

      before do
        expect(PolishGeeks::DevTools::Config).to receive(:config) { config }
        subject.execute
      end

      it { expect(subject.error_message.match(/REVIEW.md not exist/)).not_to be_nil }
    end

    context 'when required_files_include is empty' do
      it { expect(subject.error_message).to be_nil }
    end
  end

  describe '#valid?' do
    context 'when file exist' do
      before { subject.instance_variable_set('@output', []) }

      it { expect(subject.valid?).to be true }
    end
  end

  describe '#error_message' do
    context 'when output is not empty' do
      let(:file_name) { rand.to_s }
      let(:output) { [file_name] }
      let(:expected) { "Following files does not exist or are empty:\n#{file_name}\n" }
      before do
        subject.instance_variable_set('@output', output)
      end
      it { expect(subject.error_message).to eq expected }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polishgeeks-dev-tools-1.3.2 spec/lib/polish_geeks/dev_tools/commands/required_files_spec.rb