Merge pull request #31 from chef/exist-vs-exists

Exist vs exists
This commit is contained in:
Christoph Hartmann 2015-09-21 12:27:24 +02:00 committed by Dominik Richter
commit 69bdd619a3
22 changed files with 35 additions and 35 deletions

View file

@ -21,7 +21,7 @@ module Vulcano::Resources
@file.content,
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: true,
).params if @file.exists?
).params if @file.exist?
@loaded = true
@content
end
@ -37,8 +37,8 @@ module Vulcano::Resources
@content
end
def exists?
@file.exists?
def exist?
@file.exist?
end
def has_interface?(interface)

View file

@ -24,7 +24,7 @@ class Cmd < Vulcano.resource(1)
result.exit_status.to_i
end
def exists?
def exist?
res = vulcano.run_command("type \"#{@command}\" > /dev/null")
res.exit_status.to_i == 0
end

View file

@ -12,7 +12,7 @@ module Vulcano::Resources
end
%w{
type exists? file? block_device? character_device? socket? directory?
type exist? file? block_device? character_device? socket? directory?
symlink? pipe? mode mode? owner owned_by? group grouped_into? link_target
linked_to? content mtime size selinux_label mounted? immutable?
product_version file_version version? md5sum sha256sum

View file

@ -173,7 +173,7 @@ class SysV < ServiceManager
service = @vulcano.file(filename)
# check if service is installed
return nil if !service.exists?
return nil if !service.exist?
# check if service is enabled
configfile = "/etc/init/#{service_name}.conf"

View file

@ -117,7 +117,7 @@ class YumRepo
@cache
end
def exists?
def exist?
!info.nil?
end
@ -141,7 +141,7 @@ module Vulcano::Resources
def exists?
deprecated
@repository.exists?
@repository.exist?
end
def enabled?

View file

@ -96,7 +96,7 @@ module Vulcano::Backends
end
%w{
exists? file? socket? directory? symlink? pipe?
exist? file? socket? directory? symlink? pipe?
}.each do |m|
define_method m.to_sym do
::File.method(m.to_sym).call(@path)

View file

@ -63,11 +63,11 @@ module Vulcano::Backends
def initialize(_runtime, path)
@path = path
# mock dataset
@exists = (rand < 0.8) ? true : false
@is_file = (@exists && rand < 0.7) ? true : false
@exist = (rand < 0.8) ? true : false
@is_file = (@exist && rand < 0.7) ? true : false
@size = 0
@content = ''
if @exists && @is_file
if @exist && @is_file
@size = (rand**3 * 1000).to_i
@size = 0 if rand < 0.2
end
@ -77,7 +77,7 @@ module Vulcano::Backends
@content
end
%w{ size content file? exists? }.each do |m|
%w{ size content file? exist? }.each do |m|
define_method m.to_sym do
instance_variable_get(m.sub('?', '').to_sym)
end

View file

@ -218,7 +218,7 @@ module Vulcano::Backends
super(backend, path)
end
def exists?
def exist?
Specinfra::Runner.check_file_exists(@path)
end

View file

@ -5,7 +5,7 @@ class Vulcano::Plugins::Backend
# interface methods: these fields should be implemented by every
# backend File
%w{
exists? mode owner group link_target content mtime size
exist? mode owner group link_target content mtime size
selinux_label product_version file_version path
}.each do |m|
define_method m.to_sym do

View file

@ -17,8 +17,8 @@ class Vulcano::Plugins::Backend
"cat #{@spath} 2>/dev/null || echo -n").stdout
end
def exists?
@exists ||= (
def exist?
@exist ||= (
@backend.
run_command("test -e #{@spath}").
exit_status == 0

View file

@ -17,14 +17,14 @@ describe command('exit 123') do
its(:exit_status) { should eq 123 }
end
describe command('/bin/sh').exists? do
describe command('/bin/sh').exist? do
it { should eq true }
end
describe command('sh').exists? do
describe command('sh').exist? do
it { should eq true }
end
describe command('this is not existing').exists? do
describe command('this is not existing').exist? do
it { should eq false }
end

View file

@ -1,5 +1,5 @@
return unless command('ssh').exists?
return unless command('ssh').exist?
describe ssh_config do
its('SendEnv') { should include('GORDON_CLIENT')}

View file

@ -1,5 +1,5 @@
return unless command('sshd').exists?
return unless command('sshd').exist?
describe sshd_config do
its('AcceptEnv') { should include('GORDON_SERVER')}

View file

@ -7,7 +7,7 @@ describe 'file interface' do
let(:file) { backend.file('/tmp/block_device') }
it 'exists' do
file.exists?.must_equal(true)
file.exist?.must_equal(true)
end
it 'is a block device' do

View file

@ -7,7 +7,7 @@ describe 'file interface' do
let(:file) { backend.file('/dev/null') }
it 'exists' do
file.exists?.must_equal(true)
file.exist?.must_equal(true)
end
it 'is a character device' do

View file

@ -7,7 +7,7 @@ describe 'file interface' do
let(:file) { backend.file('/tmp/file') }
it 'exists' do
file.exists?.must_equal(true)
file.exist?.must_equal(true)
end
it 'is a file' do

View file

@ -7,7 +7,7 @@ describe 'file interface' do
let(:file) { backend.file('/tmp/folder') }
it 'exists' do
file.exists?.must_equal(true)
file.exist?.must_equal(true)
end
it 'is a directory' do

View file

@ -9,7 +9,7 @@ describe 'file interface' do
}
it 'does not exist' do
file.exists?.must_equal(false)
file.exist?.must_equal(false)
end
it 'is not a file' do

View file

@ -7,7 +7,7 @@ describe 'file interface' do
let(:file) { backend.file('/tmp/pipe') }
it 'exists' do
file.exists?.must_equal(true)
file.exist?.must_equal(true)
end
it 'is a pipe' do

View file

@ -7,7 +7,7 @@ describe 'file interface' do
let(:file) { backend.file('/tmp/symlink') }
it 'exists' do
file.exists?.must_equal(true)
file.exist?.must_equal(true)
end
it 'is a symlink' do

View file

@ -10,7 +10,7 @@ describe 'Vulcano::Resources::Bond' do
let(:resource) { loadResource('bond', 'bond0') }
it 'bond must be available' do
resource.exists?.must_equal true
resource.exist?.must_equal true
end
it 'eth0 is part of bond' do

View file

@ -50,31 +50,31 @@ describe 'Vulcano::Resources::YumRepo' do
# its('epel') { should exist }
# its('epel') { should be_enabled }
it 'test its syntax repo' do
_(resource.extras.exists?).must_equal true
_(resource.extras.exist?).must_equal true
_(resource.extras.enabled?).must_equal true
end
it 'test enabled extra repo' do
extras = resource.repo('extras/7/x86_64')
_(extras.exists?).must_equal true
_(extras.exist?).must_equal true
_(extras.enabled?).must_equal true
end
it 'test enabled extra repo with short name' do
extras = resource.repo('extras')
_(extras.exists?).must_equal true
_(extras.exist?).must_equal true
_(extras.enabled?).must_equal true
end
it 'test disabled extra-source repo' do
extras = resource.repo('base-debuginfo/x86_64')
_(extras.exists?).must_equal true
_(extras.exist?).must_equal true
_(extras.enabled?).must_equal false
end
# test serverspec syntax
let(:serverspec) { loadResource('yumrepo', 'extras') }
it 'test enabled extra repo' do
it 'test enabled extra repo (serverspec backwards comptability)' do
_(serverspec.exists?).must_equal true
_(serverspec.enabled?).must_equal true
end