mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
20 lines
528 B
Ruby
20 lines
528 B
Ruby
require 'spec_helper'
|
|
require 'mspec/guards'
|
|
|
|
RSpec.describe Object, "#as_user" do
|
|
before :each do
|
|
ScratchPad.clear
|
|
end
|
|
|
|
it "yields when the Process.euid is not 0" do
|
|
allow(Process).to receive(:euid).and_return(501)
|
|
as_user { ScratchPad.record :yield }
|
|
expect(ScratchPad.recorded).to eq(:yield)
|
|
end
|
|
|
|
it "does not yield when the Process.euid is 0" do
|
|
allow(Process).to receive(:euid).and_return(0)
|
|
as_user { ScratchPad.record :yield }
|
|
expect(ScratchPad.recorded).not_to eq(:yield)
|
|
end
|
|
end
|