Class: Allowy::Matchers::AbleToMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/allowy/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(action, subject = nil, *params) ⇒ AbleToMatcher

Returns a new instance of AbleToMatcher.



5
6
7
# File 'lib/allowy/matchers.rb', line 5

def initialize(action, subject=nil, *params)
  @action, @subject, @params = action, subject, params
end

Instance Method Details

#descriptionObject



17
18
19
# File 'lib/allowy/matchers.rb', line 17

def description
  say "be able to"
end

#failure_messageObject



21
22
23
# File 'lib/allowy/matchers.rb', line 21

def failure_message
  say "expected to be able to"
end

#matches?(access_control) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/allowy/matchers.rb', line 13

def matches?(access_control)
  access_control.can?(@action, @subject, *@params)
end

#negative_failure_messageObject Also known as: failure_message_when_negated



25
26
27
# File 'lib/allowy/matchers.rb', line 25

def negative_failure_message
  say "expected NOT to be able to"
end

#say(msg) ⇒ Object



9
10
11
# File 'lib/allowy/matchers.rb', line 9

def say msg
  "#{msg} #{@action} #{@subject.inspect}"
end