sentient_user 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/sentient_user.rb CHANGED
@@ -8,7 +8,7 @@ module SentientUser
8
8
 
9
9
  def self.current=(o)
10
10
  raise(ArgumentError,
11
- "Expected an object of class 'User', got #{o.inspect}") unless (o.is_a?(User) || o.nil?)
11
+ "Expected an object of class '#{self}', got #{o.inspect}") unless (o.is_a?(self) || o.nil?)
12
12
  Thread.current[:user] = o
13
13
  end
14
14
 
data/test/helper.rb CHANGED
@@ -8,3 +8,13 @@ require 'sentient_user'
8
8
 
9
9
  class Test::Unit::TestCase
10
10
  end
11
+
12
+ class Person
13
+ include SentientUser
14
+ end
15
+
16
+ class User
17
+ include SentientUser
18
+ end
19
+
20
+ class AnonymousUser < User ; end
@@ -1,7 +1,29 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestSentientUser < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
4
+ should "allow making the 'person' class sentient" do
5
+ p = Person.new
6
+ p.make_current
7
+ assert_equal Person.current, p
8
+ end
9
+
10
+ should "allow making the 'user' class sentient" do
11
+ u = User.new
12
+ u.make_current
13
+ assert_equal User.current, u
14
+ end
15
+
16
+ should "not allow making Person.current a user" do
17
+ assert_raise ArgumentError do
18
+ Person.current = User.new
19
+ end
20
+ end
21
+
22
+ should "allow making person.current a person" do
23
+ Person.current = Person.new
24
+ end
25
+
26
+ should "allow subclasses of user to be assigned to user.current" do
27
+ User.current = AnonymousUser.new
6
28
  end
7
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentient_user
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bokmann
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-08 00:00:00 -05:00
12
+ date: 2010-03-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency