Class: Arrthorizer::RSpec::Matchers::Roles::AppliesToUser
- Inherits:
-
Object
- Object
- Arrthorizer::RSpec::Matchers::Roles::AppliesToUser
- Defined in:
- lib/arrthorizer/rspec/matchers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negates ⇒ Object
-
#initialize(user) ⇒ AppliesToUser
constructor
A new instance of AppliesToUser.
- #matches?(role) ⇒ Boolean
- #with_context(hash) ⇒ Object
Constructor Details
#initialize(user) ⇒ AppliesToUser
Returns a new instance of AppliesToUser.
8 9 10 |
# File 'lib/arrthorizer/rspec/matchers.rb', line 8 def initialize(user) @user = user end |
Instance Method Details
#failure_message ⇒ Object
18 19 20 |
# File 'lib/arrthorizer/rspec/matchers.rb', line 18 def "Expected role #{@role.name} to apply in context #{context.inspect}\nfor user #{user.inspect}, but it does not apply!" end |
#failure_message_when_negates ⇒ Object
22 23 24 |
# File 'lib/arrthorizer/rspec/matchers.rb', line 22 def "Expected role #{@role.name} not to apply in context #{context.inspect}\nfor user #{user.inspect}, but it applies!" end |
#matches?(role) ⇒ Boolean
12 13 14 15 16 |
# File 'lib/arrthorizer/rspec/matchers.rb', line 12 def matches?(role) @role = role role.applies_to_user?(user, context) end |
#with_context(hash) ⇒ Object
26 27 28 29 30 |
# File 'lib/arrthorizer/rspec/matchers.rb', line 26 def with_context(hash) @context = to_context(hash) self end |