Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runner tests #685

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions spec/lib/mina/runner/exec_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper'

describe Mina::Runner::Exec do
subject(:runner) { described_class.new('echo hello') }

describe '#run' do
before do
allow(Kernel).to receive(:exec)
expect_any_instance_of(Kernel).to receive(:exec).with('echo hello')
end

it 'executes the script' do
runner.run
end
end
end
17 changes: 17 additions & 0 deletions spec/lib/mina/runner/printer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe Mina::Runner::Printer do
subject(:runner) { described_class.new('echo hello') }

describe '#run' do
it 'prints the script to stdout' do
expect do
runner.run
end.to output("echo hello\n").to_stdout
end

it 'returns true', :suppressed_output do
expect(runner.run).to eq(true)
end
end
end
16 changes: 16 additions & 0 deletions spec/lib/mina/runner/system_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper'

describe Mina::Runner::System do
subject(:runner) { described_class.new('echo hello') }

describe '#run' do
before do
allow(Kernel).to receive(:system)
expect_any_instance_of(Kernel).to receive(:system).with('echo hello')
end

it 'executes the script' do
runner.run
end
end
end
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@
config.after(:all, type: :rake) do
Mina::Configuration.instance.remove :simulate
end

config.around(:each, :suppressed_output) do |example|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :D

original_stdout, $stdout = $stdout, File.open(File::NULL, 'w')
original_stderr, $stderr = $stderr, File.open(File::NULL, 'w')

example.run

$stdout, $stderr = original_stdout, original_stderr
end
end