Module: Unveiler
- Defined in:
- lib/unveiler.rb
Overview
Unveiler allows for testing programs using pledge and unveil.
Class Method Summary collapse
-
.pledge_and_unveil(pledge, unveil) ⇒ Object
Use Pledge.unveil to limit access to the file system based on the
unveil
argument.
Class Method Details
.pledge_and_unveil(pledge, unveil) ⇒ Object
Use Pledge.unveil to limit access to the file system based on the unveil
argument. Then pledge the process with the given pledge
permissions. This will automatically unveil the rack and mail gems if they are loaded.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/unveiler.rb', line 18 def self.pledge_and_unveil(pledge, unveil) unveil = Hash[unveil] if defined?(Gem) && Gem.respond_to?(:loaded_specs) if defined?(Rack) && Gem.loaded_specs['rack'] unveil['rack'] = :gem end if defined?(Mail) && Gem.loaded_specs['mail'] unveil['mail'] = :gem end end Pledge.unveil(unveil) unless defined?(SimpleCov) # If running coverage tests, don't run pledged as coverage # testing can require many additional permissions. Pledge.pledge(pledge) end end |