gem: fix tests to work on newer Fedora hosts (#47158)

(cherry picked from commit f720499337)
pull/47174/merge
Jordan Borean 6 years ago committed by Toshio Kuratomi
parent 20c1cf41a4
commit 940eb3ae47

@ -37,33 +37,80 @@
name: gist name: gist
state: present state: present
register: install_gem_result register: install_gem_result
ignore_errors: yes
- name: List gems # when running as root on Fedora, '--install-dir' is set in the os defaults which is
command: gem list # incompatible with '--user-install', we ignore this error for this case only
register: current_gems - name: fail if failed to install gem
fail:
- name: Ensure gem was installed msg: "failed to install gem: {{ install_gem_result.msg }}"
assert: when:
that: - install_gem_result is failed
- install_gem_result is changed - not (ansible_user_uid == 0 and "User --install-dir or --user-install but not both" not in install_gem_result.msg)
- current_gems.stdout is search('gist\s+\([0-9.]+\)')
- block:
- name: Remove a gem - name: List gems
gem: command: gem list
name: gist register: current_gems
state: absent
register: remove_gem_results - name: Ensure gem was installed
assert:
- name: List gems that:
command: gem list - install_gem_result is changed
register: current_gems - current_gems.stdout is search('gist\s+\([0-9.]+\)')
- name: Verify gem is not installed - name: Remove a gem
assert: gem:
that: name: gist
- remove_gem_results is changed state: absent
- current_gems.stdout is not search('gist\s+\([0-9.]+\)') register: remove_gem_results
- name: List gems
command: gem list
register: current_gems
- name: Verify gem is not installed
assert:
that:
- remove_gem_results is changed
- current_gems.stdout is not search('gist\s+\([0-9.]+\)')
when: not install_gem_result is failed
# install gem in --no-user-install
- block:
- name: Install a gem with --no-user-install
gem:
name: gist
state: present
user_install: no
register: install_gem_result
- name: List gems
command: gem list
register: current_gems
- name: Ensure gem was installed
assert:
that:
- install_gem_result is changed
- current_gems.stdout is search('gist\s+\([0-9.]+\)')
- name: Remove a gem
gem:
name: gist
state: absent
register: remove_gem_results
- name: List gems
command: gem list
register: current_gems
- name: Verify gem is not installed
assert:
that:
- remove_gem_results is changed
- current_gems.stdout is not search('gist\s+\([0-9.]+\)')
when: ansible_user_uid == 0
# Check cutom gem directory # Check cutom gem directory
- name: Install gem in a custom directory with incorrect options - name: Install gem in a custom directory with incorrect options

Loading…
Cancel
Save