|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | 3 | 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 | + |
4 | 10 | describe 'ssh_keyscan_repo' do |
5 | 11 | it 'scans ssh' do |
6 | 12 | Mina::Configuration.instance.set(:repository, 'git@github.com/exapmle') |
7 | 13 | expect { invoke_all }.to output(output_file('ssh_keyscan_repo')).to_stdout |
8 | 14 | end |
9 | 15 | end |
10 | 16 |
|
| 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 | + |
11 | 61 | describe 'run' do |
12 | 62 | it 'runs command' do |
13 | 63 | subject.invoke('ls -al') |
|
0 commit comments