Sha256: 8a8d10dc50da67e8f782364af19f1c1e948e1d8dcd6f3fbba7b36c022a21178a

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Guard::Reek::Runner do
  subject { Guard::Reek::Runner.new(options) }
  let(:options) { { ui: ui, notifier: notifier } }
  let(:ui) { class_double('Guard::UI', info: true) }
  let(:notifier) { class_double('Guard::Notifier', notify: true) }

  before do
    allow(subject).to receive(:system)
  end

  it 'executes reek' do
    expect(subject).to receive(:system).with('reek')
    subject.run
  end

  it 'executes reek with file' do
    expect(subject).to receive(:system).with('reek', 'test.rb')
    subject.run(['test.rb'])
  end

  it 'executes reek when .reek updated' do
    expect(subject).to receive(:system).with('reek')
    subject.run(['.reek'])
  end

  context 'when reek exited with 0 status' do
    before do
      allow(subject).to receive(:system).and_return(true)
    end

    it 'notifies about success' do
      expect(notifier).to receive(:notify).with('Reek Results', title: 'Passed', image: :success)
      subject.run
    end
  end

  context 'when reek exited with non 0 status' do
    before do
      allow(subject).to receive(:system).and_return(false)
    end

    it 'notifies about failure' do
      expect(notifier).to receive(:notify).with('Reek Results', title: 'Failed', image: :failed)
      subject.run
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
guard-reek-1.0.2 spec/guard/reek/runner_spec.rb
guard-reek-1.0.1 spec/guard/reek/runner_spec.rb