Skip to content

Commit 3b749f5

Browse files
authored
Merge pull request #40 from DannyBen/fix/test-on-error
Show warning when running the test command on an invalid file
2 parents 9f1f4f5 + 928d231 commit 3b749f5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/completely/commands/test.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ class Test < Base
2222

2323
def run
2424
puts tester.test(compline).join "\n"
25-
return unless args['--keep']
2625

27-
File.write 'completely-tester.sh', tester_script
28-
puts 'saved completely-tester.sh'
26+
if args['--keep']
27+
File.write 'completely-tester.sh', tester_script
28+
puts 'saved completely-tester.sh'
29+
end
30+
31+
syntax_warning unless completions.valid?
2932
end
3033

3134
private

spec/completely/commands/test_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,16 @@
6565
.to raise_approval('cli/test/error')
6666
end
6767
end
68+
69+
context 'with an invalid configuration' do
70+
before do
71+
reset_tmp_dir
72+
File.write 'spec/tmp/in.yaml', { 'one' => %w[anything], 'two' => %w[something] }.to_yaml
73+
ENV['COMPLETELY_CONFIG_PATH'] = 'spec/tmp/in.yaml'
74+
end
75+
76+
it 'outputs a warning to STDERR' do
77+
expect { subject.execute %w[test on] }.to output_approval('cli/warning').to_stderr
78+
end
79+
end
6880
end

0 commit comments

Comments
 (0)