roles_generic 0.2.7 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/README.markdown +25 -13
  2. data/Rakefile +7 -5
  3. data/VERSION +1 -1
  4. data/lib/generators/{roles_model → roles_generic}/roles/roles_generator.rb +8 -15
  5. data/lib/roles_generic/base.rb +40 -2
  6. data/lib/roles_generic/generic/role.rb +2 -16
  7. data/lib/roles_generic/generic/role_util.rb +30 -0
  8. data/lib/roles_generic/generic/user/implementation.rb +108 -6
  9. data/lib/roles_generic/generic/user/multi_impl.rb +27 -0
  10. data/lib/roles_generic/generic/user/single_impl.rb +24 -0
  11. data/lib/roles_generic/generic.rb +1 -1
  12. data/lib/roles_generic/role.rb +1 -0
  13. data/lib/roles_generic/rspec/api/completeness.rb +22 -0
  14. data/lib/roles_generic/rspec/api/full.rb +5 -0
  15. data/lib/roles_generic/rspec/api/read_api.rb +119 -0
  16. data/lib/roles_generic/rspec/api/simple_check.rb +11 -0
  17. data/lib/roles_generic/rspec/api/user_class_api.rb +31 -0
  18. data/lib/roles_generic/rspec/api/write_api.rb +50 -0
  19. data/lib/roles_generic/rspec/test_it.rb +2 -0
  20. data/lib/roles_generic/rspec/user_setup.rb +6 -0
  21. data/lib/roles_generic/strategy/multi/many_roles.rb +12 -19
  22. data/lib/roles_generic/strategy/multi/role_strings.rb +15 -12
  23. data/lib/roles_generic/strategy/multi/roles_mask.rb +20 -16
  24. data/lib/roles_generic/strategy/multi/roles_string.rb +14 -11
  25. data/lib/roles_generic/strategy/single/admin_flag.rb +24 -13
  26. data/lib/roles_generic/strategy/single/one_role.rb +19 -18
  27. data/lib/roles_generic/strategy/single/role_string.rb +16 -11
  28. data/lib/roles_generic.rb +1 -0
  29. data/roles_generic.gemspec +60 -46
  30. data/spec/generator_spec_helper.rb +1 -1
  31. data/spec/{generators → roles_generic/generators}/admin_flag_generator_spec.rb +2 -3
  32. data/spec/{generators → roles_generic/generators}/many_roles_generator_spec.rb +3 -2
  33. data/spec/{generators → roles_generic/generators}/one_role_generator_spec.rb +3 -2
  34. data/spec/{generators → roles_generic/generators}/role_string_generator_spec.rb +2 -2
  35. data/spec/{generators → roles_generic/generators}/role_strings_generator_spec.rb +2 -2
  36. data/spec/{generators → roles_generic/generators}/roles_mask_generator_spec.rb +2 -2
  37. data/spec/{generators → roles_generic/generators}/roles_string_generator_spec.rb +2 -2
  38. data/spec/roles_generic/strategy/multi/many_roles_spec.rb +26 -0
  39. data/spec/roles_generic/strategy/multi/role_strings_spec.rb +21 -0
  40. data/spec/roles_generic/strategy/multi/roles_mask_spec.rb +20 -0
  41. data/spec/roles_generic/strategy/multi/roles_string_spec.rb +21 -0
  42. data/spec/roles_generic/strategy/single/admin_flag_spec.rb +20 -0
  43. data/spec/roles_generic/strategy/single/one_role_spec.rb +27 -0
  44. data/spec/roles_generic/strategy/single/role_string_spec.rb +21 -0
  45. metadata +72 -50
  46. data/spec/roles_generic/admin_flag_spec.rb +0 -66
  47. data/spec/roles_generic/many_roles_spec.rb +0 -64
  48. data/spec/roles_generic/one_role_spec.rb +0 -71
  49. data/spec/roles_generic/role_string_spec.rb +0 -65
  50. data/spec/roles_generic/role_strings_spec.rb +0 -58
  51. data/spec/roles_generic/roles_mask_spec.rb +0 -57
  52. data/spec/roles_generic/roles_string_spec.rb +0 -58
@@ -0,0 +1,50 @@
1
+ class Role
2
+ end
3
+
4
+ describe 'Roles Generic API : WRITE' do
5
+ before :each do
6
+ default_user_setup
7
+ end
8
+
9
+ describe '#roles=' do
10
+ it "should set user role to :admin" do
11
+ @guest_user.roles = :admin
12
+ @guest_user.has_role?(:admin).should be_true
13
+ @guest_user.roles = :guest
14
+ end
15
+ end
16
+
17
+ describe '#exchange_roles' do
18
+ it "should exchange user role :user with role :admin" do
19
+ @guest_user.exchange_role :guest, :with => :admin
20
+ @guest_user.has?(:guest).should be_false
21
+ @guest_user.has?(:admin).should be_true
22
+ end
23
+
24
+ it "should exchange user role :admin with roles :user and :guest" do
25
+ case @admin_user.class.role_strategy.multiplicity
26
+ when :single
27
+ lambda { @admin_user.exchange_role :admin, :with => [:user, :guest] }.should raise_error
28
+ when :multi
29
+ @admin_user.exchange_role :admin, :with => [:user, :guest]
30
+ @admin_user.has_role?(:user).should be_true
31
+ @admin_user.has_role?(:guest).should be_true
32
+ @admin_user.has?(:admin).should be_false
33
+ end
34
+ end
35
+ end
36
+
37
+ describe '#remove_roles' do
38
+ it "should remove user role :admin using #remove_roles" do
39
+ @admin_user.remove_roles :admin
40
+ @admin_user.has_role?(:admin).should_not be_true
41
+ end
42
+
43
+ it "should remove user role :admin using #remove_role" do
44
+ @guest_user.add_role :admin
45
+ @guest_user.has_role?(:admin).should be_true
46
+ @guest_user.remove_role :admin
47
+ @guest_user.has_role?(:admin).should_not be_true
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,2 @@
1
+ require "roles_generic/rspec/user_setup"
2
+ require "roles_generic/rspec/api/full"
@@ -0,0 +1,6 @@
1
+ def default_user_setup
2
+ @admin_user = User.new 'Admin user', :admin
3
+ @normal_user = User.new 'Normal user', :user, :guest
4
+ @guest_user = User.new 'Guest user', :guest
5
+ end
6
+
@@ -4,26 +4,19 @@ module RoleStrategy::Generic
4
4
  :many_roles
5
5
  end
6
6
 
7
- module Implementation
8
- # assign roles
9
- def roles=(*_roles)
10
- _roles = get_roles(_roles)
11
- return nil if !_roles || _roles.empty?
12
- role_relations = role_class.find_roles(_roles)
13
- role_relations.each do |role_relation|
14
- self.send("#{role_attribute}=", role_relation) if role_relation.kind_of?(role_class)
15
- end
16
- end
17
-
18
- # query assigned roles
19
- def roles
20
- self.send(role_attribute)
21
- end
7
+ module Implementation
8
+ include Roles::Generic::User::Implementation::Multi
9
+
10
+ def new_roles *role_names
11
+ role_class.find_roles(extract_roles role_names)
12
+ end
22
13
 
23
- def roles_list
24
- _roles = [roles].flatten.compact
25
- return [] if _roles.empty?
26
- _roles.map{|r| r.name }.compact
14
+ def present_roles roles_names
15
+ roles_names.to_a.map{|role| role.name.to_s.to_sym}
16
+ end
17
+
18
+ def set_empty_roles
19
+ self.send("#{role_attribute}=", [])
27
20
  end
28
21
  end
29
22
 
@@ -5,20 +5,23 @@ module RoleStrategy::Generic
5
5
  end
6
6
 
7
7
  module Implementation
8
- # assign roles
9
- def roles=(*roles)
10
- new_roles = roles.flatten.map{|r| r.to_s if valid_role?(r)}.compact
11
- self.send("#{role_attribute}=", ::Set.new(new_roles)) if new_roles && new_roles.not.empty?
12
- end
13
-
14
- # query assigned roles
15
- def roles
16
- self.send(role_attribute).map{|r| r.to_sym}
17
- end
8
+ include Roles::Generic::User::Implementation::Multi
18
9
 
19
- def roles_list
20
- [roles].flatten
10
+ def new_roles *roles
11
+ ::Set.new select_valid_roles(roles)
21
12
  end
13
+
14
+ def select_valid_roles *roles
15
+ roles.flat_uniq.select{|role| valid_role? role }.map(&:to_sym)
16
+ end
17
+
18
+ def set_empty_roles
19
+ self.send("#{role_attribute}=", [])
20
+ end
21
+
22
+ def present_roles roles_names
23
+ roles_names.to_a
24
+ end
22
25
  end
23
26
 
24
27
  extend Roles::Generic::User::Configuration
@@ -5,6 +5,8 @@ module RoleStrategy::Generic
5
5
  end
6
6
 
7
7
  module Implementation
8
+ include Roles::Generic::User::Implementation::Multi
9
+
8
10
  class Roles < ::Set # :nodoc:
9
11
  attr_reader :model_instance
10
12
 
@@ -16,29 +18,31 @@ module RoleStrategy::Generic
16
18
  def <<(role)
17
19
  model_instance.roles = super.to_a
18
20
  self
19
- end
20
- end
21
-
22
- # assign roles
23
- def roles=(*roles)
24
- self.send("#{role_attribute}=", (roles.flatten.map { |r| r.to_sym } & strategy_class.valid_roles).map { |r| calc_index(r) }.inject { |sum, bitvalue| sum + bitvalue })
21
+ end
25
22
  end
26
- alias_method :role=, :roles=
27
-
28
- # query assigned roles
29
- def roles
30
- strategy_class::Roles.new(self, strategy_class.valid_roles.reject { |r| ((self.send(role_attribute) || 0) & calc_index(r)).zero? })
31
- end
32
-
33
- def roles_list
34
- roles.to_a
35
- end
36
23
 
37
24
  protected
38
25
 
39
26
  def calc_index(r)
40
27
  2**strategy_class.valid_roles.index(r)
41
28
  end
29
+
30
+ def get_roles
31
+ strategy_class::Roles.new(self, strategy_class.valid_roles.reject { |r| ((get_role || 0) & calc_index(r)).zero? })
32
+ end
33
+
34
+ def new_roles *role_names
35
+ role_names = role_names.flatten.map{ |r| r.to_sym } & strategy_class.valid_roles
36
+ role_names.map { |r| calc_index(r) }.inject { |sum, bitvalue| sum + bitvalue }
37
+ end
38
+
39
+ def set_empty_roles
40
+ self.send("#{role_attribute}=", 0)
41
+ end
42
+
43
+ def present_roles *role_names
44
+ role_names.to_a.to_symbols
45
+ end
42
46
  end
43
47
 
44
48
  extend Roles::Generic::User::Configuration
@@ -4,19 +4,22 @@ module RoleStrategy::Generic
4
4
  :roles_string
5
5
  end
6
6
 
7
- module Implementation
8
- # assign roles
9
- def roles=(*roles)
10
- roles_str = roles.flatten.map{|r| r.to_s if valid_role?(r)}.compact.uniq.join(',')
11
- self.send("#{role_attribute}=", roles_str) if roles_str && roles_str.not.empty?
12
- end
13
- alias_method :role=, :roles=
7
+ module Implementation
8
+ include Roles::Generic::User::Implementation::Multi
9
+
10
+ protected
14
11
 
15
- # query assigned roles
16
- def roles
17
- self.send(role_attribute).split(',').uniq.map{|r| r.to_sym}
12
+ def new_roles *roles
13
+ roles.flatten.map{|r| r.to_s}.join(',')
14
+ end
15
+
16
+ def present_roles role_names
17
+ role_names.split(',').uniq.map{|r| r.to_sym}
18
+ end
19
+
20
+ def set_empty_roles
21
+ self.send("#{role_attribute}=", "")
18
22
  end
19
- alias_method :roles_list, :roles
20
23
  end
21
24
 
22
25
  extend Roles::Generic::User::Configuration
@@ -3,25 +3,36 @@ module RoleStrategy::Generic
3
3
  def self.default_role_attribute
4
4
  :admin_flag
5
5
  end
6
+
7
+ module Implementation
8
+ protected
6
9
 
7
- module Implementation
8
- # assign roles
9
- def roles=(*new_roles)
10
- first_role = new_roles.flatten.first
11
- self.send("#{role_attribute}=", new_roles.flatten.first.admin?) if valid_role? first_role
10
+ def new_role role
11
+ role.admin?
12
12
  end
13
-
14
- # query assigned roles
15
- def roles
16
- role = self.send(role_attribute) ? strategy_class.admin_role_key : strategy_class.default_role_key
17
- [role]
13
+
14
+ def new_roles *roles
15
+ new_role roles.flatten.first
16
+ end
17
+
18
+ def get_role
19
+ self.send(role_attribute) ? strategy_class.admin_role_key : strategy_class.default_role_key
20
+ end
21
+
22
+ def present_roles *roles
23
+ roles.map{|role| role ? :admin : :guest}
18
24
  end
19
- alias_method :roles_list, :roles
20
-
25
+ alias_method :present_role, :present_roles
26
+
27
+ def set_empty_role
28
+ self.send("#{role_attribute}=", false)
29
+ end
21
30
  end # Implementation
22
-
31
+
23
32
  extend Roles::Generic::User::Configuration
24
33
  configure :num => :single
34
+
35
+ include Roles::Generic::User::Implementation::Single
25
36
  end
26
37
  end
27
38
 
@@ -4,27 +4,26 @@ module RoleStrategy::Generic
4
4
  :one_role
5
5
  end
6
6
 
7
- module Implementation
8
- # assign roles
9
- def roles=(*_roles)
10
- _roles = get_roles(_roles)
11
- return nil if !_roles || _roles.empty?
7
+ module Implementation
8
+ include Roles::Generic::User::Implementation::Single
9
+
10
+ protected
12
11
 
13
- first_role = _roles.flatten.first
14
- role_relation = role_class.find_role(first_role)
15
- if role_relation && role_relation.kind_of?(role_class)
16
- self.send("#{role_attribute}=", role_relation)
17
- end
18
- end
12
+ def new_role role
13
+ role_class.find_role(role)
14
+ end
19
15
 
20
- # query assigned roles
21
- def roles
22
- [self.send(role_attribute).name.to_sym]
23
- end
16
+ def new_roles *roles
17
+ new_role roles.flatten.first
18
+ end
24
19
 
25
- def roles_list
26
- self.roles.to_a
27
- end
20
+ def present_roles *roles
21
+ roles.map{|role| extract_role role}
22
+ end
23
+
24
+ def set_empty_role
25
+ self.send("#{role_attribute}=", nil)
26
+ end
28
27
  end
29
28
 
30
29
  extend Roles::Generic::User::Configuration
@@ -33,5 +32,7 @@ module RoleStrategy::Generic
33
32
  def self.included(base)
34
33
  base.extend Roles::Generic::Role::ClassMethods
35
34
  end
35
+
36
+ include Roles::Generic::User::Implementation::Single
36
37
  end
37
38
  end
@@ -5,20 +5,25 @@ module RoleStrategy::Generic
5
5
  end
6
6
 
7
7
  module Implementation
8
- # assign roles
9
- def roles=(*roles)
10
- first_role = roles.flatten.first.to_s
11
- if valid_role? first_role
12
- self.send("#{role_attribute}=", first_role)
13
- end
8
+ include Roles::Generic::User::Implementation::Single
9
+
10
+ def new_role role
11
+ role.to_s
14
12
  end
15
- alias_method :role=, :roles=
16
13
 
17
- # query assigned roles
18
- def roles
19
- [self.send(role_attribute).to_sym]
14
+ def new_roles *roles
15
+ new_role roles.flatten.first
20
16
  end
21
- alias_method :roles_list, :roles
17
+
18
+ def present_role role
19
+ role.split(',').map(&:to_sym)
20
+ end
21
+
22
+ def set_empty_role
23
+ self.send("#{role_attribute}=", "")
24
+ end
25
+
26
+ alias_method :present_roles, :present_role
22
27
  end
23
28
 
24
29
  extend Roles::Generic::User::Configuration
data/lib/roles_generic.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'require_all'
2
2
  require 'active_support/inflector'
3
3
  require 'sugar-high/not'
4
+ require 'sugar-high/array'
4
5
  require 'set'
5
6
  require 'roles_generic/namespaces'
6
7
  require 'roles_generic/base'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{roles_generic}
8
- s.version = "0.2.7"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-09-23}
12
+ s.date = %q{2010-11-20}
13
13
  s.description = %q{Generic role strategies sharing the same API. Easy to insert in any model}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -24,18 +24,29 @@ Gem::Specification.new do |s|
24
24
  "README.markdown",
25
25
  "Rakefile",
26
26
  "VERSION",
27
- "lib/generators/roles_model/roles/roles_generator.rb",
27
+ "lib/generators/roles_generic/roles/roles_generator.rb",
28
28
  "lib/roles_generic.rb",
29
29
  "lib/roles_generic/admin.rb",
30
30
  "lib/roles_generic/base.rb",
31
31
  "lib/roles_generic/generic.rb",
32
32
  "lib/roles_generic/generic/role.rb",
33
+ "lib/roles_generic/generic/role_util.rb",
33
34
  "lib/roles_generic/generic/user.rb",
34
35
  "lib/roles_generic/generic/user/class_methods.rb",
35
36
  "lib/roles_generic/generic/user/configuration.rb",
36
37
  "lib/roles_generic/generic/user/implementation.rb",
38
+ "lib/roles_generic/generic/user/multi_impl.rb",
39
+ "lib/roles_generic/generic/user/single_impl.rb",
37
40
  "lib/roles_generic/namespaces.rb",
38
41
  "lib/roles_generic/role.rb",
42
+ "lib/roles_generic/rspec/api/completeness.rb",
43
+ "lib/roles_generic/rspec/api/full.rb",
44
+ "lib/roles_generic/rspec/api/read_api.rb",
45
+ "lib/roles_generic/rspec/api/simple_check.rb",
46
+ "lib/roles_generic/rspec/api/user_class_api.rb",
47
+ "lib/roles_generic/rspec/api/write_api.rb",
48
+ "lib/roles_generic/rspec/test_it.rb",
49
+ "lib/roles_generic/rspec/user_setup.rb",
39
50
  "lib/roles_generic/strategy.rb",
40
51
  "lib/roles_generic/strategy/multi/many_roles.rb",
41
52
  "lib/roles_generic/strategy/multi/role_strings.rb",
@@ -46,20 +57,20 @@ Gem::Specification.new do |s|
46
57
  "lib/roles_generic/strategy/single/role_string.rb",
47
58
  "roles_generic.gemspec",
48
59
  "spec/generator_spec_helper.rb",
49
- "spec/generators/admin_flag_generator_spec.rb",
50
- "spec/generators/many_roles_generator_spec.rb",
51
- "spec/generators/one_role_generator_spec.rb",
52
- "spec/generators/role_string_generator_spec.rb",
53
- "spec/generators/role_strings_generator_spec.rb",
54
- "spec/generators/roles_mask_generator_spec.rb",
55
- "spec/generators/roles_string_generator_spec.rb",
56
- "spec/roles_generic/admin_flag_spec.rb",
57
- "spec/roles_generic/many_roles_spec.rb",
58
- "spec/roles_generic/one_role_spec.rb",
59
- "spec/roles_generic/role_string_spec.rb",
60
- "spec/roles_generic/role_strings_spec.rb",
61
- "spec/roles_generic/roles_mask_spec.rb",
62
- "spec/roles_generic/roles_string_spec.rb",
60
+ "spec/roles_generic/generators/admin_flag_generator_spec.rb",
61
+ "spec/roles_generic/generators/many_roles_generator_spec.rb",
62
+ "spec/roles_generic/generators/one_role_generator_spec.rb",
63
+ "spec/roles_generic/generators/role_string_generator_spec.rb",
64
+ "spec/roles_generic/generators/role_strings_generator_spec.rb",
65
+ "spec/roles_generic/generators/roles_mask_generator_spec.rb",
66
+ "spec/roles_generic/generators/roles_string_generator_spec.rb",
67
+ "spec/roles_generic/strategy/multi/many_roles_spec.rb",
68
+ "spec/roles_generic/strategy/multi/role_strings_spec.rb",
69
+ "spec/roles_generic/strategy/multi/roles_mask_spec.rb",
70
+ "spec/roles_generic/strategy/multi/roles_string_spec.rb",
71
+ "spec/roles_generic/strategy/single/admin_flag_spec.rb",
72
+ "spec/roles_generic/strategy/single/one_role_spec.rb",
73
+ "spec/roles_generic/strategy/single/role_string_spec.rb",
63
74
  "spec/spec_helper.rb",
64
75
  "wiki/strategies/admin_flag.textile",
65
76
  "wiki/strategies/many_roles.textile",
@@ -76,20 +87,20 @@ Gem::Specification.new do |s|
76
87
  s.summary = %q{Generic role strategies sharing the same API}
77
88
  s.test_files = [
78
89
  "spec/generator_spec_helper.rb",
79
- "spec/generators/admin_flag_generator_spec.rb",
80
- "spec/generators/many_roles_generator_spec.rb",
81
- "spec/generators/one_role_generator_spec.rb",
82
- "spec/generators/role_string_generator_spec.rb",
83
- "spec/generators/role_strings_generator_spec.rb",
84
- "spec/generators/roles_mask_generator_spec.rb",
85
- "spec/generators/roles_string_generator_spec.rb",
86
- "spec/roles_generic/admin_flag_spec.rb",
87
- "spec/roles_generic/many_roles_spec.rb",
88
- "spec/roles_generic/one_role_spec.rb",
89
- "spec/roles_generic/role_string_spec.rb",
90
- "spec/roles_generic/role_strings_spec.rb",
91
- "spec/roles_generic/roles_mask_spec.rb",
92
- "spec/roles_generic/roles_string_spec.rb",
90
+ "spec/roles_generic/generators/admin_flag_generator_spec.rb",
91
+ "spec/roles_generic/generators/many_roles_generator_spec.rb",
92
+ "spec/roles_generic/generators/one_role_generator_spec.rb",
93
+ "spec/roles_generic/generators/role_string_generator_spec.rb",
94
+ "spec/roles_generic/generators/role_strings_generator_spec.rb",
95
+ "spec/roles_generic/generators/roles_mask_generator_spec.rb",
96
+ "spec/roles_generic/generators/roles_string_generator_spec.rb",
97
+ "spec/roles_generic/strategy/multi/many_roles_spec.rb",
98
+ "spec/roles_generic/strategy/multi/role_strings_spec.rb",
99
+ "spec/roles_generic/strategy/multi/roles_mask_spec.rb",
100
+ "spec/roles_generic/strategy/multi/roles_string_spec.rb",
101
+ "spec/roles_generic/strategy/single/admin_flag_spec.rb",
102
+ "spec/roles_generic/strategy/single/one_role_spec.rb",
103
+ "spec/roles_generic/strategy/single/role_string_spec.rb",
93
104
  "spec/spec_helper.rb"
94
105
  ]
95
106
 
@@ -98,27 +109,30 @@ Gem::Specification.new do |s|
98
109
  s.specification_version = 3
99
110
 
100
111
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
101
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
102
- s.add_development_dependency(%q<generator-spec>, ["~> 0.6.5"])
112
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
113
+ s.add_development_dependency(%q<generator-spec>, [">= 0.7"])
103
114
  s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
104
- s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0"])
105
- s.add_runtime_dependency(%q<sugar-high>, ["~> 0.2.10"])
106
- s.add_runtime_dependency(%q<rails3_artifactor>, ["~> 0.2.5"])
115
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0"])
116
+ s.add_runtime_dependency(%q<sugar-high>, ["~> 0.3.0"])
117
+ s.add_runtime_dependency(%q<rails3_artifactor>, ["~> 0.3.1"])
118
+ s.add_runtime_dependency(%q<logging_assist>, [">= 0.1.6"])
107
119
  else
108
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
109
- s.add_dependency(%q<generator-spec>, ["~> 0.6.5"])
120
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
121
+ s.add_dependency(%q<generator-spec>, [">= 0.7"])
110
122
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
111
- s.add_dependency(%q<activesupport>, ["~> 3.0.0"])
112
- s.add_dependency(%q<sugar-high>, ["~> 0.2.10"])
113
- s.add_dependency(%q<rails3_artifactor>, ["~> 0.2.5"])
123
+ s.add_dependency(%q<activesupport>, [">= 3.0"])
124
+ s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
125
+ s.add_dependency(%q<rails3_artifactor>, ["~> 0.3.1"])
126
+ s.add_dependency(%q<logging_assist>, [">= 0.1.6"])
114
127
  end
115
128
  else
116
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
117
- s.add_dependency(%q<generator-spec>, ["~> 0.6.5"])
129
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
130
+ s.add_dependency(%q<generator-spec>, [">= 0.7"])
118
131
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
119
- s.add_dependency(%q<activesupport>, ["~> 3.0.0"])
120
- s.add_dependency(%q<sugar-high>, ["~> 0.2.10"])
121
- s.add_dependency(%q<rails3_artifactor>, ["~> 0.2.5"])
132
+ s.add_dependency(%q<activesupport>, [">= 3.0"])
133
+ s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
134
+ s.add_dependency(%q<rails3_artifactor>, ["~> 0.3.1"])
135
+ s.add_dependency(%q<logging_assist>, [">= 0.1.6"])
122
136
  end
123
137
  end
124
138
 
@@ -1,5 +1,5 @@
1
1
  require 'rspec/core'
2
- require 'generator_spec'
2
+ require 'generator-spec'
3
3
  require 'roles_generic'
4
4
 
5
5
  RSpec::Generator.configure do |config|
@@ -31,9 +31,8 @@ describe 'role strategy generator: admin_flag' do
31
31
  g.run_generator arguments.args
32
32
  g.should generate_model :user do |clazz|
33
33
  clazz.should include_module 'Roles::Generic'
34
- puts "clazz: #{clazz}"
35
- clazz.should have_call :roles, :args => ':admin, :user'
36
- clazz.should have_call :role_strategy, :args => ":#{strategy}"
34
+ clazz.should have_call :valid_roles_are, :args => ':admin, :user'
35
+ clazz.should have_call :strategy, :args => ":#{strategy}"
37
36
  end
38
37
  end
39
38
  end
@@ -28,8 +28,9 @@ describe 'helper_generator' do
28
28
  g.run_generator arguments.args
29
29
  g.should generate_model :user do |clazz|
30
30
  clazz.should include_module 'RoleModels::Generic'
31
- clazz.should have_call :roles, :args => ':admin, :user'
32
- clazz.should have_call :role_strategy, :args => ":#{strategy}"
31
+ clazz.should have_call :valid_roles_are, :args => ':admin, :user'
32
+ clazz.should have_call :role_class, :args => ':role'
33
+ clazz.should have_call :strategy, :args => ":#{strategy}"
33
34
  end
34
35
  end
35
36
  end
@@ -28,8 +28,9 @@ describe 'helper_generator' do
28
28
  g.run_generator arguments.args
29
29
  g.should generate_model :user do |clazz|
30
30
  clazz.should include_module 'RoleModels::Generic'
31
- clazz.should have_call :roles, :args => ':admin, :user'
32
- clazz.should have_call :role_strategy, :args => ":#{strategy}"
31
+ clazz.should have_call :role_class, :args => ':role'
32
+ clazz.should have_call :valid_roles_are, :args => ':admin, :user'
33
+ clazz.should have_call :strategy, :args => ":#{strategy}"
33
34
  end
34
35
  end
35
36
  end
@@ -28,8 +28,8 @@ describe 'helper_generator' do
28
28
  g.run_generator arguments.args
29
29
  g.should generate_model :user do |clazz|
30
30
  clazz.should include_module 'RoleModels::Generic'
31
- clazz.should have_call :roles, :args => ':admin, :user'
32
- clazz.should have_call :role_strategy, :args => ":#{strategy}"
31
+ clazz.should have_call :valid_roles_are, :args => ':admin, :user'
32
+ clazz.should have_call :strategy, :args => ":#{strategy}"
33
33
  end
34
34
  end
35
35
  end
@@ -28,8 +28,8 @@ describe 'helper_generator' do
28
28
  g.run_generator arguments.args
29
29
  g.should generate_model :user do |clazz|
30
30
  clazz.should include_module 'RoleModels::Generic'
31
- clazz.should have_call :roles, :args => ':admin, :user'
32
- clazz.should have_call :role_strategy, :args => ":#{strategy}"
31
+ clazz.should have_call :valid_roles_are, :args => ':admin, :user'
32
+ clazz.should have_call :strategy, :args => ":#{strategy}"
33
33
  end
34
34
  end
35
35
  end
@@ -28,8 +28,8 @@ describe 'helper_generator' do
28
28
  g.run_generator arguments.args
29
29
  g.should generate_model :user do |clazz|
30
30
  clazz.should include_module 'RoleModels::Generic'
31
- clazz.should have_call :roles, :args => ':admin, :user'
32
- clazz.should have_call :role_strategy, :args => ":#{strategy}"
31
+ clazz.should have_call :valid_roles_are, :args => ':admin, :user'
32
+ clazz.should have_call :strategy, :args => ":#{strategy}"
33
33
  end
34
34
  end
35
35
  end
@@ -28,8 +28,8 @@ describe 'helper_generator' do
28
28
  g.run_generator arguments.args
29
29
  g.should generate_model :user do |clazz|
30
30
  clazz.should include_module 'RoleModels::Generic'
31
- clazz.should have_call :roles, :args => ':admin, :user'
32
- clazz.should have_call :role_strategy, :args => ":#{strategy}"
31
+ clazz.should have_call :valid_roles_are, :args => ':admin, :user'
32
+ clazz.should have_call :strategy, :args => ":#{strategy}"
33
33
  end
34
34
  end
35
35
  end