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

Test remaining default tasks #692

Merged
merged 1 commit into from
Aug 17, 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
1 change: 1 addition & 0 deletions spec/support/outputs/environment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
environment is DEPRECATED! Please use local_environment and remote_environment
3 changes: 3 additions & 0 deletions spec/support/outputs/ssh_keyscan_domain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if ! ssh-keygen -H -F localhost &>/dev/null; then
ssh-keyscan -p 22 localhost >> ~/.ssh/known_hosts
fi
50 changes: 50 additions & 0 deletions spec/tasks/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,63 @@
require 'spec_helper'

RSpec.describe 'default', type: :rake do
describe 'environment' do
it 'outputs a deprecation warning' do
expect { invoke_all }.to output(output_file('environment')).to_stdout
end
end

describe 'ssh_keyscan_repo' do
it 'scans ssh' do
Mina::Configuration.instance.set(:repository, 'git@github.com/exapmle')
expect { invoke_all }.to output(output_file('ssh_keyscan_repo')).to_stdout
end
end

describe 'ssh_keyscan_domain' do
subject { rake['ssh_keyscan_domain'] }

context "when domain isn't set" do
around do |example|
original_domain = Mina::Configuration.instance.fetch(:domain)
Mina::Configuration.instance.remove(:domain)
example.run
Mina::Configuration.instance.set(:domain, original_domain)
end

it 'exits with an error message' do
expect do
invoke_all
end.to raise_error(SystemExit)
.and output(/domain must be defined!/).to_stdout
end
end

context "when port isn't set" do
around do |example|
original_port = Mina::Configuration.instance.fetch(:port)
Mina::Configuration.instance.remove(:port)
example.run
Mina::Configuration.instance.set(:port, original_port)
end

it 'exits with an error message' do
expect do
invoke_all
end.to raise_error(SystemExit)
.and output(/port must be defined!/).to_stdout
end
end

context 'when conditions are met' do
it 'scans ssh' do
expect do
invoke_all
end.to output(output_file('ssh_keyscan_domain')).to_stdout
end
end
end

describe 'run' do
it 'runs command' do
subject.invoke('ls -al')
Expand Down