Method: ChefSpec::API::User#remove_user

Defined in:
lib/chefspec/api/user.rb

#remove_user(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a user resource exists in the Chef run with the action :remove. Given a Chef Recipe that removes “apache2” as a user:

user 'apache2' do
  action :remove
end

The Examples section demonstrates the different ways to test a user resource with ChefSpec.

Examples:

Assert that a user was remove

expect(chef_run).to remove_user('apache2')

Assert that a user was remove with predicate matchers

expect(chef_run).to remove_user('apache2').with_uid(1234)

Assert that a user was remove with attributes

expect(chef_run).to remove_user('apache2').with(uid: 1234)

Assert that a user was remove using a regex

expect(chef_run).to remove_user('apache2').with(uid: /\d+/)

Assert that a user was not remove

expect(chef_run).to_not remove_user('apache2')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:



76
77
78
# File 'lib/chefspec/api/user.rb', line 76

def remove_user(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:user, :remove, resource_name)
end