Sha256: db6ec3353d82ffbb7c5ba09ec7b688132bd381b9414f43b5ab43383944119f99
Contents?: true
Size: 928 Bytes
Versions: 3
Compression:
Stored size: 928 Bytes
Contents
require 'spec_helper' require 'mspec/guards' describe Object, "#as_user" do before :each do @guard = UserGuard.new UserGuard.stub(:new).and_return(@guard) 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 it "sets the name of the guard to :as_user" do as_user { } @guard.name.should == :as_user end it "calls #unregister even when an exception is raised in the guard block" do @guard.should_receive(:match?).and_return(true) @guard.should_receive(:unregister) lambda do as_user { raise Exception } end.should raise_error(Exception) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mspec-1.9.1 | spec/guards/user_spec.rb |
mspec-1.9.0 | spec/guards/user_spec.rb |
mspec-1.8.0 | spec/guards/user_spec.rb |