|
4 | 4 | describe '.execute' do
|
5 | 5 | let(:args_prefix) { %w[cmd] }
|
6 | 6 | let(:max_command_length) { 10 }
|
| 7 | + let(:options) { { args: splittable_args } } |
7 | 8 |
|
8 |
| - subject { described_class.execute(args_prefix, splittable_args) } |
| 9 | + subject { described_class.execute(args_prefix, options) } |
9 | 10 |
|
10 | 11 | before do
|
11 | 12 | described_class.stub(:max_command_length).and_return(max_command_length)
|
|
35 | 36 | let(:splittable_args) { %w[1 2 3 4 5 6 7 8] }
|
36 | 37 |
|
37 | 38 | it 'executes two commands with the appropriately split arguments' do
|
38 |
| - Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 1 2 3 4 5 6 7]) |
39 |
| - Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 8]) |
| 39 | + Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 1 2 3 4 5 6 7], |
| 40 | + hash_excluding(:args)) |
| 41 | + Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 8], |
| 42 | + hash_excluding(:args)) |
40 | 43 | subject
|
41 | 44 | end
|
42 | 45 |
|
|
55 | 58 | context 'when one command fails' do
|
56 | 59 | before do
|
57 | 60 | Overcommit::Subprocess.stub(:spawn).
|
58 |
| - with(%w[cmd 8]). |
| 61 | + with(%w[cmd 8], anything). |
59 | 62 | and_return(Overcommit::Subprocess::Result.new(2, 'whoa', 'bad error'))
|
60 | 63 | end
|
61 | 64 |
|
|
75 | 78 | let(:splittable_args) { 15.times.map { |i| (i + 1).to_s } }
|
76 | 79 |
|
77 | 80 | it 'executes multiple commands with the appropriately split arguments' do
|
78 |
| - Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 1 2 3 4 5 6 7]) |
79 |
| - Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 8 9 10 11]) |
80 |
| - Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 12 13 14]) |
81 |
| - Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 15]) |
| 81 | + Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 1 2 3 4 5 6 7], |
| 82 | + hash_excluding(:args)) |
| 83 | + Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 8 9 10 11], |
| 84 | + hash_excluding(:args)) |
| 85 | + Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 12 13 14], |
| 86 | + hash_excluding(:args)) |
| 87 | + Overcommit::Subprocess.should_receive(:spawn).with(%w[cmd 15], |
| 88 | + hash_excluding(:args)) |
82 | 89 | subject
|
83 | 90 | end
|
84 | 91 | end
|
|
101 | 108 | expect { subject }.to raise_error Overcommit::Exceptions::InvalidCommandArgs
|
102 | 109 | end
|
103 | 110 | end
|
| 111 | + |
| 112 | + context 'with a standard input stream specified' do |
| 113 | + let(:max_command_length) { 5 } |
| 114 | + let(:args_prefix) { %w[cat] } |
| 115 | + let(:options) { { args: %w[- - -], input: 'Hello' } } |
| 116 | + |
| 117 | + it 'passes the same standard input to each command' do |
| 118 | + Overcommit::Subprocess.should_receive(:spawn).with(%w[cat - -], |
| 119 | + hash_including(input: 'Hello')) |
| 120 | + Overcommit::Subprocess.should_receive(:spawn).with(%w[cat -], |
| 121 | + hash_including(input: 'Hello')) |
| 122 | + subject |
| 123 | + end |
| 124 | + end |
104 | 125 | end
|
105 | 126 | end
|
0 commit comments