How to use expected method of MyModule Package

Best Minitest_ruby code snippet using MyModule.expected

selinux_module_spec.rb

Source:selinux_module_spec.rb Github

copy

Full Screen

...17 {18 source_te: 'puppet:///modules/mymodule/selinux/mymodule.te'19 }20 end21 it { is_expected.to contain_selinux__module('mymodule').that_requires('Anchor[selinux::module pre]') }22 it { is_expected.to contain_selinux__module('mymodule').that_comes_before('Anchor[selinux::module post]') }23 end24 context 'present case with refpolicy builder and with te file only' do25 let(:params) do26 {27 source_te: 'puppet:///modules/mymodule/selinux/mymodule.te',28 builder: 'refpolicy'29 }30 end31 it { is_expected.to contain_file(workdir) }32 it { is_expected.to contain_file("#{workdir}/mymodule.te").that_notifies('Exec[clean-module-mymodule]') }33 it { is_expected.to contain_file("#{workdir}/mymodule.fc").with(source: nil, content: '') }34 it { is_expected.to contain_file("#{workdir}/mymodule.if").with(source: nil, content: '') }35 it { is_expected.to contain_exec('clean-module-mymodule').with(command: "rm -f '#{module_basepath}.pp' '#{module_basepath}.loaded'", cwd: workdir) }36 it { is_expected.to contain_exec('build-module-mymodule').with(command: "make -f /usr/share/selinux/devel/Makefile mymodule.pp || (rm -f #{module_basepath}.pp #{module_basepath}.loaded && exit 1)", creates: "#{module_basepath}.pp") }37 it { is_expected.to contain_exec('install-module-mymodule').with(command: "semodule -i #{module_basepath}.pp && touch #{module_basepath}.loaded", cwd: workdir, creates: "#{module_basepath}.loaded") }38 it { is_expected.to contain_selmodule('mymodule').with_ensure('present', selmodulepath: workdir) }39 end40 context 'present case with refpolicy builder and with te and fc file' do41 let(:params) do42 {43 source_te: 'puppet:///modules/mymodule/selinux/mymodule.te',44 source_fc: 'puppet:///modules/mymodule/selinux/mymodule.fc',45 builder: 'refpolicy'46 }47 end48 it { is_expected.to contain_file(workdir) }49 it { is_expected.to contain_file("#{workdir}/mymodule.te").that_notifies('Exec[clean-module-mymodule]') }50 it { is_expected.to contain_file("#{workdir}/mymodule.fc").that_notifies('Exec[clean-module-mymodule]') }51 it { is_expected.to contain_file("#{workdir}/mymodule.if").with(source: nil, content: '') }52 it { is_expected.to contain_exec('clean-module-mymodule').with(command: "rm -f '#{module_basepath}.pp' '#{module_basepath}.loaded'", cwd: workdir) }53 it { is_expected.to contain_exec('build-module-mymodule').with(command: "make -f /usr/share/selinux/devel/Makefile mymodule.pp || (rm -f #{module_basepath}.pp #{module_basepath}.loaded && exit 1)", creates: "#{module_basepath}.pp") }54 it { is_expected.to contain_exec('install-module-mymodule').with(command: "semodule -i #{module_basepath}.pp && touch #{module_basepath}.loaded", cwd: workdir, creates: "#{module_basepath}.loaded") }55 it { is_expected.to contain_selmodule('mymodule').with_ensure('present', selmodulepath: workdir) }56 end57 context 'present case with refpolicy builder and with te, fc and if file' do58 let(:params) do59 {60 source_te: 'puppet:///modules/mymodule/selinux/mymodule.te',61 source_if: 'puppet:///modules/mymodule/selinux/mymodule.if',62 source_fc: 'puppet:///modules/mymodule/selinux/mymodule.fc',63 builder: 'refpolicy'64 }65 end66 it { is_expected.to contain_file(workdir) }67 it { is_expected.to contain_file("#{workdir}/mymodule.te").that_notifies('Exec[clean-module-mymodule]') }68 it { is_expected.to contain_file("#{workdir}/mymodule.if").that_notifies('Exec[clean-module-mymodule]') }69 it { is_expected.to contain_file("#{workdir}/mymodule.fc").that_notifies('Exec[clean-module-mymodule]') }70 it { is_expected.to contain_exec('clean-module-mymodule').with(command: "rm -f '#{module_basepath}.pp' '#{module_basepath}.loaded'", cwd: workdir) }71 it { is_expected.to contain_exec('build-module-mymodule').with(command: "make -f /usr/share/selinux/devel/Makefile mymodule.pp || (rm -f #{module_basepath}.pp #{module_basepath}.loaded && exit 1)", creates: "#{module_basepath}.pp") }72 it { is_expected.to contain_exec('install-module-mymodule').with(command: "semodule -i #{module_basepath}.pp && touch #{module_basepath}.loaded", cwd: workdir, creates: "#{module_basepath}.loaded") }73 it { is_expected.to contain_selmodule('mymodule').with_ensure('present', selmodulepath: workdir) }74 end75 context 'present case with refpolicy builder and with inline te, fc and if file' do76 let(:params) do77 {78 content_te: 'policy_module(puppet_test, 1.0.0)',79 content_if: 'interface(puppet_test)',80 content_fc: '/bin/sh system_u:object_r:bin_t',81 builder: 'refpolicy'82 }83 end84 it { is_expected.to contain_file(workdir) }85 it { is_expected.to contain_file("#{workdir}/mymodule.te").with(source: nil, content: 'policy_module(puppet_test, 1.0.0)').that_notifies('Exec[clean-module-mymodule]') }86 it { is_expected.to contain_file("#{workdir}/mymodule.if").with(source: nil, content: 'interface(puppet_test)').that_notifies('Exec[clean-module-mymodule]') }87 it { is_expected.to contain_file("#{workdir}/mymodule.fc").with(source: nil, content: '/bin/sh system_u:object_r:bin_t').that_notifies('Exec[clean-module-mymodule]') }88 it { is_expected.to contain_exec('clean-module-mymodule').with(command: "rm -f '#{module_basepath}.pp' '#{module_basepath}.loaded'", cwd: workdir) }89 it { is_expected.to contain_exec('build-module-mymodule').with(command: "make -f /usr/share/selinux/devel/Makefile mymodule.pp || (rm -f #{module_basepath}.pp #{module_basepath}.loaded && exit 1)", creates: "#{module_basepath}.pp") }90 it { is_expected.to contain_exec('install-module-mymodule').with(command: "semodule -i #{module_basepath}.pp && touch #{module_basepath}.loaded", cwd: workdir, creates: "#{module_basepath}.loaded") }91 it { is_expected.to contain_selmodule('mymodule').with_ensure('present', selmodulepath: workdir) }92 end93 context 'present case with simple builder with te' do94 let(:params) do95 {96 source_te: 'puppet:///modules/mymodule/selinux/mymodule.te',97 builder: 'simple'98 }99 end100 it { is_expected.to contain_file(workdir) }101 it { is_expected.to contain_file("#{workdir}/mymodule.te").that_notifies('Exec[clean-module-mymodule]') }102 it { is_expected.to contain_file("#{workdir}/mymodule.fc").with(source: nil, content: '') }103 it { is_expected.to contain_file("#{workdir}/mymodule.if").with(source: nil, content: '') }104 it { is_expected.to contain_exec('clean-module-mymodule').with(command: "rm -f '#{module_basepath}.pp' '#{module_basepath}.loaded'", cwd: workdir) }105 it { is_expected.to contain_exec('build-module-mymodule').with(command: "/var/lib/puppet/puppet-selinux/bin/selinux_build_module_simple.sh mymodule #{workdir} || (rm -f #{module_basepath}.pp #{module_basepath}.loaded && exit 1)", creates: "#{module_basepath}.pp") }106 it { is_expected.to contain_exec('install-module-mymodule').with(command: "semodule -i #{module_basepath}.pp && touch #{module_basepath}.loaded", cwd: workdir, creates: "#{module_basepath}.loaded") }107 it { is_expected.to contain_selmodule('mymodule').with_ensure('present', selmodulepath: workdir) }108 end109 context 'present case with simple builder with inline te' do110 let(:params) do111 {112 content_te: 'policy_module(puppet_test, 1.0.0)',113 builder: 'simple'114 }115 end116 it { is_expected.to contain_file(workdir) }117 it { is_expected.to contain_file("#{workdir}/mymodule.te").with(content: 'policy_module(puppet_test, 1.0.0)').that_notifies('Exec[clean-module-mymodule]') }118 it { is_expected.to contain_file("#{workdir}/mymodule.fc").with(source: nil, content: '') }119 it { is_expected.to contain_file("#{workdir}/mymodule.if").with(source: nil, content: '') }120 it { is_expected.to contain_exec('clean-module-mymodule').with(command: "rm -f '#{module_basepath}.pp' '#{module_basepath}.loaded'", cwd: workdir) }121 it { is_expected.to contain_exec('build-module-mymodule').with(command: "/var/lib/puppet/puppet-selinux/bin/selinux_build_module_simple.sh mymodule #{workdir} || (rm -f #{module_basepath}.pp #{module_basepath}.loaded && exit 1)", creates: "#{module_basepath}.pp") }122 it { is_expected.to contain_exec('install-module-mymodule').with(command: "semodule -i #{module_basepath}.pp && touch #{module_basepath}.loaded", cwd: workdir, creates: "#{module_basepath}.loaded") }123 it { is_expected.to contain_selmodule('mymodule').with_ensure('present', selmodulepath: workdir) }124 end125 context 'unsupported source with simple builder' do126 let(:params) do127 {128 source_if: 'puppet:///modules/mymodule/selinux/mymodule.te',129 builder: 'simple'130 }131 end132 it do133 is_expected.to raise_error(Puppet::Error, %r{simple builder does not support})134 end135 end136 context 'present case with pre-compiled policy package' do137 let(:params) do138 {139 source_pp: 'puppet:///modules/mymodule/selinux/mymodule.pp'140 }141 end142 it { is_expected.to contain_file(workdir) }143 it { is_expected.to contain_file("#{workdir}/mymodule.pp").that_notifies('Exec[clean-module-mymodule]') }144 it { is_expected.to contain_exec('clean-module-mymodule').with(command: "rm -f '#{module_basepath}.loaded'", cwd: workdir) }145 it { is_expected.to contain_exec('install-module-mymodule').with(command: "semodule -i #{module_basepath}.pp && touch #{module_basepath}.loaded", cwd: workdir, creates: "#{module_basepath}.loaded") }146 it { is_expected.to contain_selmodule('mymodule').with_ensure('present', selmodulepath: workdir) }147 end148 context 'conflicting parameters' do149 let(:params) do150 {151 source_pp: 'puppet:///modules/mymodule/selinux/mymodule.pp',152 source_te: 'puppet:///modules/mymodule/selinux/mymodule.te',153 builder: 'simple'154 }155 end156 it do157 is_expected.to raise_error(Puppet::Error, %r{mutually exclusive})158 end159 end160 context 'absent case' do161 let(:params) do162 {163 ensure: 'absent'164 }165 end166 it { is_expected.to contain_selmodule('mymodule').with_ensure('absent') }167 end168 end169 end170end...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Minitest_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful