Sha256: 0d5e098801c49ae66fbff4d71dccb4e4cb066722e761136289cfa295487350d4

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

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

  let(:config) { double }

  describe '#execute' do
    it 'executes the command' do
      subject.execute
    end
  end

  describe '#label' do
    it { expect(subject.label).to eq 'Expires in' }
  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 use expire_in instead of expires_in:\n\n#{file_name}\n" }

      before { subject.instance_variable_set('@output', output) }

      it { expect(subject.error_message).to eq expected }
    end
  end

  describe '#valid?' do
    context 'when output is empty' do
      before do
        subject.instance_variable_set('@output', '')
      end
      it { expect(subject.valid?).to eq true }
    end
  end

  describe '#excludes' do
    context 'when expire_files_ignored is not set' do
      let(:config) do
        instance_double(
          PolishGeeks::DevTools::Config,
          expires_in_files_ignored: nil
        )
      end

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

      it { expect(subject.send(:excludes)).to eq [] }
    end

    context 'when expire_files_ignored is set' do
      let(:expires_in_files_ignored) { rand }
      let(:config) do
        instance_double(
          PolishGeeks::DevTools::Config,
          expires_in_files_ignored: expires_in_files_ignored
        )
      end

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

      it { expect(subject.send(:excludes)).to eq expires_in_files_ignored }
    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/expires_in_spec.rb