Class: KittyPolicy::RSpec::ToBeAbleTo

Inherits:
Object
  • Object
show all
Defined in:
lib/kitty_policy/rspec.rb

Instance Method Summary collapse

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_messageObject



16
17
18
# File 'lib/kitty_policy/rspec.rb', line 16

def failure_message
  "Expected user to be able to #{@action.inspect} #{@subject.inspect unless @subject == :empty}, but isn't"
end

#failure_message_when_negatedObject



20
21
22
# File 'lib/kitty_policy/rspec.rb', line 20

def failure_message_when_negated
  "Expected user not to be able to #{@action.inspect} #{@subject.inspect unless @subject == :empty}, but is"
end

#matches?(user) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/kitty_policy/rspec.rb', line 12

def matches?(user)
  @policy.can?(user, @action, @subject)
end