aboutsummaryrefslogtreecommitdiffstats
path: root/spec/mspec/lib/mspec/guards/superuser.rb
blob: 6e447198a7b94d7cb9218f9123c9000ba0217a96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'mspec/guards/guard'

class SuperUserGuard < SpecGuard
  def match?
    Process.euid == 0
  end
end

class Object
  def as_superuser(&block)
    SuperUserGuard.new.run_if(:as_superuser, &block)
  end

  def as_user(&block)
    SuperUserGuard.new.run_unless(:as_user, &block)
  end
end