Skip to content

Commit

Permalink
Merge pull request #558 from uroesch/selinux_module-string
Browse files Browse the repository at this point in the history
Override the selinux_module string to be 'SELinux module'
  • Loading branch information
mizzy committed Mar 7, 2016
2 parents 5e3aee9 + 12b917b commit fcfc48a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/serverspec/matcher/be_installed.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
RSpec::Matchers.define :be_installed do
match do |name|
name.installed?(@provider, @version)
if subject.class.name == 'Serverspec::Type::SelinuxModule'
name.installed?(@version)
else
name.installed?(@provider, @version)
end
end

description do
message = 'be installed'
message << %( by "#{@provider}") if @provider
message << %( with version "#{@version}") if @version
message
end

chain :by do |provider|
Expand Down
6 changes: 5 additions & 1 deletion lib/serverspec/type/selinux_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ def enabled?
@runner.check_selinux_module_is_enabled(@name)
end

def installed?(name, version=nil)
def installed?(version = nil)
@runner.check_selinux_module_is_installed(@name, version)
end

def to_s
%(SELinux module "#{@name}")
end
end
end
4 changes: 4 additions & 0 deletions spec/type/linux/selinux_module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

describe selinux_module('bootloader') do
it { should be_installed }
end

describe selinux_module('bootloader') do
it { should be_installed.with_version('1.10') }
end

describe selinux_module('bootloader') do
Expand Down

0 comments on commit fcfc48a

Please sign in to comment.