summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/guards/user_spec.rb
blob: 2de4db739059986c2beb0a7da2bde6fa886ea134 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'spec_helper'
require 'mspec/guards'

describe Object, "#as_user" do
  before :each do
    ScratchPad.clear
  end

  it "yields when the Process.euid is not 0" do
    Process.stub(:euid).and_return(501)
    as_user { ScratchPad.record :yield }
    ScratchPad.recorded.should == :yield
  end

  it "does not yield when the Process.euid is 0" do
    Process.stub(:euid).and_return(0)
    as_user { ScratchPad.record :yield }
    ScratchPad.recorded.should_not == :yield
  end
end