Sha256: 8cf8238547b9d7313d814237a3e79e1e958b49ebaca4c49db5e8c23239a3d8fe

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

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

  describe '#execute' do
    let(:logger) { double }
    let(:output_storer) { double }
    let(:config) { PolishGeeks::DevTools::Config.new }

    before do
      expect(::PolishGeeks::DevTools::OutputStorer)
        .to receive(:new)
        .and_return(output_storer)

      expect(::PolishGeeks::DevTools)
        .to receive(:config)
        .and_return(config)
        .at_least(:once)

      PolishGeeks::DevTools::Config::COMMANDS.each do |command|
        config.public_send(:"#{command}=", true)

        klass_name = command.to_s.gsub(/(?<=_|^)(\w)/, &:upcase).gsub(/(?:_)(\w)/, '\1')
        klass = Object.const_get("PolishGeeks::DevTools::Command::#{klass_name}")

        instance = double
        output = double

        expect(klass)
          .to receive(:new)
          .and_return(instance)

        expect(instance)
          .to receive(:stored_output=)
          .with(output_storer)

        expect(instance)
          .to receive(:execute)

        expect(instance)
          .to receive(:output)
          .and_return(output)

        expect(output_storer)
          .to receive(:"#{command}=")
          .with(output)

        expect(logger)
          .to receive(:log)
          .with(instance)
      end
    end

    it { subject.execute(logger) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polishgeeks-dev-tools-1.2.0 spec/lib/polishgeeks/dev-tools/runner_spec.rb
polishgeeks-dev-tools-1.1.3 spec/lib/polishgeeks/dev-tools/runner_spec.rb