aegis 2.5.2 → 2.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,6 +2,6 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'rails', '=2.3.8'
4
4
  gem "aegis", :path => '.'
5
- gem 'rspec', '=1.2.9'
6
- gem 'rspec-rails', '=1.2.9'
5
+ gem 'rspec', '=1.3.1'
6
+ gem 'rspec-rails', '=1.3.3'
7
7
  gem 'ruby-debug'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.5.2
1
+ 2.5.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aegis}
8
- s.version = "2.5.2"
8
+ s.version = "2.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Henning Koch", "Tobias Kraze"]
12
- s.date = %q{2010-11-06}
12
+ s.date = %q{2010-11-10}
13
13
  s.description = %q{Aegis is an authorization solution for Ruby on Rails that supports roles and a RESTish, resource-style declaration of permission rules.}
14
14
  s.email = %q{henning.koch@makandra.de}
15
15
  s.extra_rdoc_files = [
@@ -44,15 +44,40 @@ module Aegis
44
44
  CheckPermissions.new(*args)
45
45
  end
46
46
 
47
- def be_allowed_to(*args)
48
- simple_matcher do |user, matcher|
49
- action, *action_args = args
50
- target = action.to_s + (action_args.present? ? " given #{action_args.inspect}" : "")
51
- matcher.description = "be allowed to " + target
52
- matcher.failure_message = "expected #{user.inspect} to be allowed to #{target}"
53
- matcher.negative_failure_message = "expected #{user.inspect} to be denied to #{target}"
54
- user.send("may_#{action}?", *action_args)
47
+ class BeAllowedTo
48
+
49
+ def initialize(expected_action, *expected_args)
50
+ @expected_action = expected_action
51
+ @expected_args = expected_args
52
+ end
53
+
54
+ def matches?(user)
55
+ @actual_user = user
56
+ @actual_user.send("may_#{@expected_action}?", *@expected_args)
57
+ end
58
+
59
+ def description
60
+ "be allowed to #{action_as_prose}"
61
+ end
62
+
63
+ def failure_message
64
+ "expected #{@actual_user.inspect} to be allowed to #{action_as_prose}"
55
65
  end
66
+
67
+ def negative_failure_message
68
+ "expected #{@actual_user.inspect} to be denied to #{action_as_prose}"
69
+ end
70
+
71
+ private
72
+
73
+ def action_as_prose
74
+ @expected_action.to_s + (@expected_args.present? ? " given #{@expected_args.inspect}" : "")
75
+ end
76
+
77
+ end
78
+
79
+ def be_allowed_to(*args)
80
+ BeAllowedTo.new(*args)
56
81
  end
57
82
 
58
83
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aegis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 5
9
- - 2
10
- version: 2.5.2
9
+ - 3
10
+ version: 2.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henning Koch
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-06 00:00:00 +01:00
19
+ date: 2010-11-10 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies: []
22
22