Class: Aegis::Spec::Matchers::CheckPermissions
- Inherits:
-
Object
- Object
- Aegis::Spec::Matchers::CheckPermissions
- Defined in:
- lib/aegis/spec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected_resource, expected_options = {}) ⇒ CheckPermissions
constructor
A new instance of CheckPermissions.
- #matches?(controller) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected_resource, expected_options = {}) ⇒ CheckPermissions
Returns a new instance of CheckPermissions.
7 8 9 10 |
# File 'lib/aegis/spec/matchers.rb', line 7 def initialize(expected_resource, = {}) @expected_resource = expected_resource @expected_options = end |
Instance Method Details
#description ⇒ Object
35 36 37 38 39 |
# File 'lib/aegis/spec/matchers.rb', line 35 def description description = "check permissions against resource #{@expected_resource.inspect}" description << " with options #{@expected_options.inspect}" if @expected_options.any? description end |
#failure_message ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/aegis/spec/matchers.rb', line 19 def if @actual_resource != @expected_resource "expected #{@controller_class} to check permissions against resource #{@expected_resource.inspect}, but it checked against #{@actual_resource.inspect}" else "expected #{@controller_class} to check permissions with options #{@expected_options.inspect}, but options were #{@actual_options.inspect}" end end |
#matches?(controller) ⇒ Boolean
12 13 14 15 16 17 |
# File 'lib/aegis/spec/matchers.rb', line 12 def matches?(controller) @controller_class = controller.class @actual_resource = @controller_class.instance_variable_get('@aegis_permissions_resource') @actual_options = @controller_class.instance_variable_get('@aegis_permissions_options') @actual_resource == @expected_resource && @actual_options == @expected_options end |
#negative_failure_message ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/aegis/spec/matchers.rb', line 27 def if @actual_resource == @expected_resource "expected #{@controller_class} to not check permissions against resource #{@expected_resource.inspect}" else "expected #{@controller_class} to not check permissions with options #{@expected_options.inspect}" end end |