Sha256: c194f9bb22740569a0a1d378624782900b817fe78107351638b286bd73480b3b

Contents?: true

Size: 1.26 KB

Versions: 33

Compression:

Stored size: 1.26 KB

Contents

require 'gitx/executor'

RSpec.describe Gitx::Executor do
  let(:executor) { described_class.new }
  let(:exit_value) { double(:exit_value, success?: true) }
  let(:thread) { double(:thread, value: exit_value) }
  let(:stdoutput) { StringIO.new('Hello World') }
  before do
    expect(Open3).to receive(:popen2e).and_yield(nil, stdoutput, thread)
  end

  describe '#execute' do
    context 'when execution is successful and block given' do
      before do
        @output = []
        executor.execute('some', 'command', '--with', '--args') do |output|
          @output << output
        end
      end
      it 'yields the command and output' do
        expect(@output).to eq ['$ some command --with --args', 'Hello World']
      end
    end
    context 'when execution is successful' do
      before do
        @output = executor.execute('some', 'command', '--with', '--args')
      end
      it 'returns the output' do
        expect(@output).to eq 'Hello World'
      end
    end
    context 'when execution is not sucessful' do
      let(:exit_value) { double(:exit_value, success?: false) }
      it 'raises ExecutionError' do
        expect do
          executor.execute('some', 'bad', 'command')
        end.to raise_error Gitx::Executor::ExecutionError
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
gitx-4.5.0 spec/gitx/executor_spec.rb
gitx-4.4.0 spec/gitx/executor_spec.rb
gitx-4.3.0 spec/gitx/executor_spec.rb
gitx-4.1.1 spec/gitx/executor_spec.rb
gitx-4.1.0 spec/gitx/executor_spec.rb
gitx-4.0.0 spec/gitx/executor_spec.rb
gitx-4.0.0.ci.234.1 spec/gitx/executor_spec.rb
gitx-3.2.0 spec/gitx/executor_spec.rb
gitx-3.2.0.ci.231.1 spec/gitx/executor_spec.rb
gitx-3.1.2 spec/gitx/executor_spec.rb
gitx-3.1.1 spec/gitx/executor_spec.rb
gitx-3.1.0.ci.216.1 spec/gitx/executor_spec.rb
gitx-3.1.0 spec/gitx/executor_spec.rb
gitx-3.0.2.ci.213.1 spec/gitx/executor_spec.rb
gitx-3.0.2.ci.207.1 spec/gitx/executor_spec.rb
gitx-3.0.2 spec/gitx/executor_spec.rb
gitx-3.0.1.ci.200.1 spec/gitx/executor_spec.rb
gitx-3.0.1 spec/gitx/executor_spec.rb
gitx-3.0.0.ci.188.1 spec/gitx/executor_spec.rb
gitx-3.0.0 spec/gitx/executor_spec.rb