require 'spec_helper' describe Chef::Sugar::PlatformFamily do it_behaves_like 'a chef sugar' describe '#arch_linux?' do it 'returns true when the platform_family is arch linux' do node = { 'platform_family' => 'arch' } expect(described_class.arch_linux?(node)).to be true end it 'returns false when the platform_family is not arch linux' do node = { 'platform_family' => 'windows' } expect(described_class.arch_linux?(node)).to be false end end describe '#debian?' do it 'returns true when the platform_family is debian' do node = { 'platform_family' => 'debian' } expect(described_class.debian?(node)).to be true end it 'returns false when the platform_family is not debian' do node = { 'platform_family' => 'windows' } expect(described_class.debian?(node)).to be false end end describe '#fedora?' do it 'returns true when the platform_family is fedora' do node = { 'platform_family' => 'fedora' } expect(described_class.fedora?(node)).to be true end it 'returns false when the platform_family is not fedora' do node = { 'platform_family' => 'windows' } expect(described_class.fedora?(node)).to be false end end describe '#freebsd?' do it 'returns true when the platform_family is freebsd' do node = { 'platform_family' => 'freebsd' } expect(described_class.freebsd?(node)).to be true end it 'returns false when the platform_family is not freebsd' do node = { 'platform_family' => 'windows' } expect(described_class.freebsd?(node)).to be false end end describe '#gentoo?' do it 'returns true when the platform_family is gentoo' do node = { 'platform_family' => 'gentoo' } expect(described_class.gentoo?(node)).to be true end it 'returns false when the platform_family is not gentoo' do node = { 'platform_family' => 'windows' } expect(described_class.gentoo?(node)).to be false end end describe '#mac_os_x?' do it 'returns true when the platform_family is mac_os_x' do node = { 'platform_family' => 'mac_os_x' } expect(described_class.mac_os_x?(node)).to be true end it 'returns false when the platform_family is not mac_os_x' do node = { 'platform_family' => 'windows' } expect(described_class.mac_os_x?(node)).to be false end end describe '#openbsd?' do it 'returns true when the platform_family is openbsd' do node = { 'platform_family' => 'openbsd' } expect(described_class.openbsd?(node)).to be true end it 'returns false when the platform_family is not openbsd' do node = { 'platform_family' => 'windows' } expect(described_class.openbsd?(node)).to be false end end describe '#rhel?' do it 'returns true when the platform_family is rhel' do node = { 'platform_family' => 'rhel' } expect(described_class.rhel?(node)).to be true end it 'returns false when the platform_family is not rhel' do node = { 'platform_family' => 'windows' } expect(described_class.rhel?(node)).to be false end end describe '#slackware?' do it 'returns true when the platform_family is slackware' do node = { 'platform_family' => 'slackware' } expect(described_class.slackware?(node)).to be true end it 'returns false when the platform_family is not slackware' do node = { 'platform_family' => 'windows' } expect(described_class.slackware?(node)).to be false end end describe '#suse?' do it 'returns true when the platform_family is suse' do node = { 'platform_family' => 'suse' } expect(described_class.suse?(node)).to be true end it 'returns false when the platform_family is not suse' do node = { 'platform_family' => 'windows' } expect(described_class.suse?(node)).to be false end end describe '#windows?' do it 'returns true when the platform_family is windows' do node = { 'platform_family' => 'windows' } expect(described_class.windows?(node)).to be true end it 'returns false when the platform_family is not windows' do node = { 'platform_family' => 'debian' } expect(described_class.windows?(node)).to be false end end describe '#wrlinux?' do it 'returns true when the platform_family is wrlinux' do node = { 'platform_family' => 'wrlinux' } expect(described_class.wrlinux?(node)).to be true end it 'returns false when the platform_family is not wrlinux' do node = { 'platform_family' => 'debian' } expect(described_class.wrlinux?(node)).to be false end end describe '#linux?' do it 'returns true when the os is Linux' do node = { 'os' => 'linux' } expect(described_class.linux?(node)).to be true end it 'returns false when the os is Windows' do node = { 'os' => 'windows' } expect(described_class.linux?(node)).to be false end it 'returns false when the os is Windows' do node = { 'os' => 'darwin' } expect(described_class.linux?(node)).to be false end end end