Class: KittyPolicy::RSpec::ToBeAbleTo
- Inherits:
-
Object
- Object
- KittyPolicy::RSpec::ToBeAbleTo
- Defined in:
- lib/kitty_policy/rspec.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(policy, action, subject) ⇒ ToBeAbleTo
constructor
A new instance of ToBeAbleTo.
- #matches?(user) ⇒ Boolean
Constructor Details
#initialize(policy, action, subject) ⇒ ToBeAbleTo
Returns a new instance of ToBeAbleTo.
6 7 8 9 10 |
# File 'lib/kitty_policy/rspec.rb', line 6 def initialize(policy, action, subject) @policy = policy @action = action @subject = subject end |
Instance Method Details
#failure_message ⇒ Object
16 17 18 |
# File 'lib/kitty_policy/rspec.rb', line 16 def "Expected user to be able to #{@action.inspect} #{@subject.inspect unless @subject == :empty}, but isn't" end |
#failure_message_when_negated ⇒ Object
20 21 22 |
# File 'lib/kitty_policy/rspec.rb', line 20 def "Expected user not to be able to #{@action.inspect} #{@subject.inspect unless @subject == :empty}, but is" end |
#matches?(user) ⇒ Boolean
12 13 14 |
# File 'lib/kitty_policy/rspec.rb', line 12 def matches?(user) @policy.can?(user, @action, @subject) end |