Class: Arrthorizer::RSpec::Matchers::Roles::AppliesToUser

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

Instance Method Summary collapse

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_messageObject



18
19
20
# File 'lib/arrthorizer/rspec/matchers.rb', line 18

def failure_message
  "Expected role #{@role.name} to apply in context #{context.inspect}\nfor user #{user.inspect}, but it does not apply!"
end

#failure_message_when_negatesObject



22
23
24
# File 'lib/arrthorizer/rspec/matchers.rb', line 22

def failure_message_when_negates
  "Expected role #{@role.name} not to apply in context #{context.inspect}\nfor user #{user.inspect}, but it applies!"
end

#matches?(role) ⇒ Boolean

Returns:

  • (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