Skip to content

Commit cd0eba1

Browse files
authored
Test remaining default tasks (mina-deploy#692)
1 parent 87490e6 commit cd0eba1

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
environment is DEPRECATED! Please use local_environment and remote_environment
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if ! ssh-keygen -H -F localhost &>/dev/null; then
2+
ssh-keyscan -p 22 localhost >> ~/.ssh/known_hosts
3+
fi

spec/tasks/default_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,63 @@
11
require 'spec_helper'
22

33
RSpec.describe 'default', type: :rake do
4+
describe 'environment' do
5+
it 'outputs a deprecation warning' do
6+
expect { invoke_all }.to output(output_file('environment')).to_stdout
7+
end
8+
end
9+
410
describe 'ssh_keyscan_repo' do
511
it 'scans ssh' do
612
Mina::Configuration.instance.set(:repository, 'git@github.com/exapmle')
713
expect { invoke_all }.to output(output_file('ssh_keyscan_repo')).to_stdout
814
end
915
end
1016

17+
describe 'ssh_keyscan_domain' do
18+
subject { rake['ssh_keyscan_domain'] }
19+
20+
context "when domain isn't set" do
21+
around do |example|
22+
original_domain = Mina::Configuration.instance.fetch(:domain)
23+
Mina::Configuration.instance.remove(:domain)
24+
example.run
25+
Mina::Configuration.instance.set(:domain, original_domain)
26+
end
27+
28+
it 'exits with an error message' do
29+
expect do
30+
invoke_all
31+
end.to raise_error(SystemExit)
32+
.and output(/domain must be defined!/).to_stdout
33+
end
34+
end
35+
36+
context "when port isn't set" do
37+
around do |example|
38+
original_port = Mina::Configuration.instance.fetch(:port)
39+
Mina::Configuration.instance.remove(:port)
40+
example.run
41+
Mina::Configuration.instance.set(:port, original_port)
42+
end
43+
44+
it 'exits with an error message' do
45+
expect do
46+
invoke_all
47+
end.to raise_error(SystemExit)
48+
.and output(/port must be defined!/).to_stdout
49+
end
50+
end
51+
52+
context 'when conditions are met' do
53+
it 'scans ssh' do
54+
expect do
55+
invoke_all
56+
end.to output(output_file('ssh_keyscan_domain')).to_stdout
57+
end
58+
end
59+
end
60+
1161
describe 'run' do
1262
it 'runs command' do
1363
subject.invoke('ls -al')

0 commit comments

Comments
 (0)