Class: Aegis::Spec::Matchers::BeAllowedTo

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

Instance Method Summary collapse

Constructor Details

#initialize(expected_action, *expected_args) ⇒ BeAllowedTo

Returns a new instance of BeAllowedTo.



49
50
51
52
# File 'lib/aegis/spec/matchers.rb', line 49

def initialize(expected_action, *expected_args)
  @expected_action = expected_action
  @expected_args = expected_args
end

Instance Method Details

#descriptionObject



59
60
61
# File 'lib/aegis/spec/matchers.rb', line 59

def description
  "be allowed to #{action_as_prose}"
end

#failure_messageObject



63
64
65
# File 'lib/aegis/spec/matchers.rb', line 63

def failure_message
  "expected #{@actual_user.inspect} to be allowed to #{action_as_prose}"
end

#matches?(user) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'lib/aegis/spec/matchers.rb', line 54

def matches?(user)
  @actual_user = user
  @actual_user.send("may_#{@expected_action}?", *@expected_args)
end

#negative_failure_messageObject



67
68
69
# File 'lib/aegis/spec/matchers.rb', line 67

def negative_failure_message
  "expected #{@actual_user.inspect} to be denied to #{action_as_prose}"
end