Module: Aegis::Spec::Matchers

Defined in:
lib/aegis/spec/matchers.rb

Defined Under Namespace

Classes: CheckPermissions

Instance Method Summary collapse

Instance Method Details

#be_allowed_to(*args) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/aegis/spec/matchers.rb', line 47

def be_allowed_to(*args)
  simple_matcher do |user, matcher|
    action, *action_args = args
    target = action.to_s + (action_args.present? ? " given #{action_args.inspect}" : "")
    matcher.description = "be allowed to " + target
    matcher.failure_message = "expected #{user.inspect} to be allowed to #{target}"
    matcher.negative_failure_message = "expected #{user.inspect} to be denied to #{target}"
    user.send("may_#{action}?", *action_args)
  end
end

#check_permissions(*args) ⇒ Object



43
44
45
# File 'lib/aegis/spec/matchers.rb', line 43

def check_permissions(*args)
  CheckPermissions.new(*args)
end