Skip to content

Commit

Permalink
Improve specs
Browse files Browse the repository at this point in the history
  • Loading branch information
pgeraghty committed Sep 26, 2019
1 parent 320a371 commit 98bc9ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/ansible/playbook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ module Ansible
expect { Playbook.stream('-i localhost, file_not_found.yml --list-hosts') { |l| next } }.to raise_exception(Playbook::Exception, /could not be found/)
end

it 'raises an error upon a fatal outcome (unreachable node)' do
expect { Playbook.stream('-i localhost.does_not_exist, spec/fixtures/fail_playbook.yml') { |l| next } }.to raise_exception(Playbook::Exception, (/FAILED/ && /fatal/ && /UNREACHABLE/))
end

pending 'test ignore_failures is skipped' do
fail
end

it 'defaults to standard output when streaming an Ansible Playbook if no block is given' do
expect { Playbook.stream '-i localhost, spec/fixtures/mock_playbook.yml' }.to output(/Test task/).to_stdout
end
Expand Down
11 changes: 11 additions & 0 deletions spec/fixtures/fail_playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

- name: Testing Playbook
hosts: all
gather_facts: no

tasks:
- name: Test task
register: test_msg
changed_when: "'Test' in test_msg.stderr"
shell: echo 'Test'

0 comments on commit 98bc9ba

Please sign in to comment.