Class: RSpec::Matchers::BuiltIn::AbleToMatcher
- Inherits:
-
Be
- Object
- Be
- RSpec::Matchers::BuiltIn::AbleToMatcher
- Defined in:
- lib/bali/rspec/able_to_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(operation, class_or_record = nil) ⇒ AbleToMatcher
constructor
A new instance of AbleToMatcher.
- #matches?(actor) ⇒ Boolean
Constructor Details
#initialize(operation, class_or_record = nil) ⇒ AbleToMatcher
Returns a new instance of AbleToMatcher.
5 6 7 8 |
# File 'lib/bali/rspec/able_to_matcher.rb', line 5 def initialize(operation, class_or_record = nil) @operation = operation @class_or_record = class_or_record end |
Instance Method Details
#description ⇒ Object
29 30 31 |
# File 'lib/bali/rspec/able_to_matcher.rb', line 29 def description "be able to #{@operation}" end |
#failure_message ⇒ Object
21 22 23 |
# File 'lib/bali/rspec/able_to_matcher.rb', line 21 def "expected to be able to #{@operation}, but actually cannot" end |
#failure_message_when_negated ⇒ Object
25 26 27 |
# File 'lib/bali/rspec/able_to_matcher.rb', line 25 def "expected not to be able to #{@operation}, but actually can" end |
#matches?(actor) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bali/rspec/able_to_matcher.rb', line 10 def matches?(actor) if @class_or_record rule_class = "#{@class_or_record.class.name}#{Bali.config.suffix}".constantize rule_class.can?(actor, @operation, @class_or_record) else @class_or_record = actor rule_class = "#{@class_or_record.name}#{Bali.config.suffix}".constantize rule_class.can?(nil, @operation, @class_or_record) end end |