Skip to content

Commit

Permalink
Test remaining default tasks (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
lovro-bikic authored Aug 17, 2021
1 parent 87490e6 commit cd0eba1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
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

0 comments on commit cd0eba1

Please sign in to comment.