Sha256: 11beb408c40a7844e3b56b855297424c5a1e5a37092fa276d7bc0809ddfebea5
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'helper' class TestSentientUser < Test::Unit::TestCase should "allow making the 'person' class sentient" do p = Person.new p.make_current assert_equal Person.current, p end should "allow making the 'user' class sentient" do u = User.new u.make_current assert_equal User.current, u end should "not allow making Person.current a user" do assert_raise ArgumentError do Person.current = User.new end end should "allow making person.current a person" do Person.current = Person.new end should "allow subclasses of user to be assigned to user.current" do User.current = AnonymousUser.new end should "allow execution of a block as a specified user" do p, p2 = Person.new, Person.new p.make_current Person.do_as(p2) { assert_equal Person.current, p2 } end should "should reset the original user after executing a block as a specified user" do p, p2 = Person.new, Person.new p.make_current Person.do_as(p2) { } assert_equal Person.current, p begin Person.do_as(p2) { raise "error" } rescue assert_equal Person.current, p end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sentient_user-0.3.2 | test/test_sentient_user.rb |