Skip to content

Commit 213c39c

Browse files
authored
Add runner specs (mina-deploy#685)
1 parent 5cff173 commit 213c39c

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

spec/lib/mina/runner/exec_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'spec_helper'
2+
3+
describe Mina::Runner::Exec do
4+
subject(:runner) { described_class.new('echo hello') }
5+
6+
describe '#run' do
7+
before do
8+
allow(Kernel).to receive(:exec)
9+
expect_any_instance_of(Kernel).to receive(:exec).with('echo hello')
10+
end
11+
12+
it 'executes the script' do
13+
runner.run
14+
end
15+
end
16+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'spec_helper'
2+
3+
describe Mina::Runner::Printer do
4+
subject(:runner) { described_class.new('echo hello') }
5+
6+
describe '#run' do
7+
it 'prints the script to stdout' do
8+
expect do
9+
runner.run
10+
end.to output("echo hello\n").to_stdout
11+
end
12+
13+
it 'returns true', :suppressed_output do
14+
expect(runner.run).to eq(true)
15+
end
16+
end
17+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'spec_helper'
2+
3+
describe Mina::Runner::System do
4+
subject(:runner) { described_class.new('echo hello') }
5+
6+
describe '#run' do
7+
before do
8+
allow(Kernel).to receive(:system)
9+
expect_any_instance_of(Kernel).to receive(:system).with('echo hello')
10+
end
11+
12+
it 'executes the script' do
13+
runner.run
14+
end
15+
end
16+
end

spec/spec_helper.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,13 @@
3131
config.after(:all, type: :rake) do
3232
Mina::Configuration.instance.remove :simulate
3333
end
34+
35+
config.around(:each, :suppressed_output) do |example|
36+
original_stdout, $stdout = $stdout, File.open(File::NULL, 'w')
37+
original_stderr, $stderr = $stderr, File.open(File::NULL, 'w')
38+
39+
example.run
40+
41+
$stdout, $stderr = original_stdout, original_stderr
42+
end
3443
end

0 commit comments

Comments
 (0)