Class: Allowy::Matchers::AbleToMatcher
- Inherits:
-
Object
- Object
- Allowy::Matchers::AbleToMatcher
- Defined in:
- lib/allowy/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(action, subject = nil) ⇒ AbleToMatcher
constructor
A new instance of AbleToMatcher.
- #matches?(access_control) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #say(msg) ⇒ Object
Constructor Details
#initialize(action, subject = nil) ⇒ AbleToMatcher
Returns a new instance of AbleToMatcher.
5 6 7 |
# File 'lib/allowy/matchers.rb', line 5 def initialize(action, subject=nil) @action, @subject = action, subject end |
Instance Method Details
#description ⇒ Object
17 18 19 |
# File 'lib/allowy/matchers.rb', line 17 def description say "be able to" end |
#failure_message ⇒ Object
21 22 23 |
# File 'lib/allowy/matchers.rb', line 21 def say "expected to be able to" end |
#matches?(access_control) ⇒ Boolean
13 14 15 |
# File 'lib/allowy/matchers.rb', line 13 def matches?(access_control) access_control.can?(@action, @subject) end |
#negative_failure_message ⇒ Object
25 26 27 |
# File 'lib/allowy/matchers.rb', line 25 def 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 |