Class: LogicalAuthz::Matcher::Authorized
- Inherits:
-
Object
- Object
- LogicalAuthz::Matcher::Authorized
- Defined in:
- lib/logical_authz/spec_helper.rb
Direct Known Subclasses
Instance Method Summary collapse
- #check_authorization_flag ⇒ Object
- #failure_message(match_text) ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize ⇒ Authorized
constructor
A new instance of Authorized.
- #match_state ⇒ Object
- #matches?(controller) ⇒ Boolean
Constructor Details
#initialize ⇒ Authorized
Returns a new instance of Authorized.
4 5 6 |
# File 'lib/logical_authz/spec_helper.rb', line 4 def initialize @controller = nil end |
Instance Method Details
#check_authorization_flag ⇒ Object
12 13 14 15 16 |
# File 'lib/logical_authz/spec_helper.rb', line 12 def return false unless @flash.has_key? :logical_authz_record return true if @flash[:logical_authz_record][:result] == true return false end |
#failure_message(match_text) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/logical_authz/spec_helper.rb', line 25 def (match_text) if @flash.has_key? :logical_authz_record laz_rec = @flash[:logical_authz_record] "Expected #{@controller.class.name}(#{@controller.params.inspect})" + " #{match_text} #{match_state}, but flash[:logical_authz_record][:result] " + "is <#{laz_rec[:result].inspect}> (reason: #{laz_rec[:reason].inspect}, " + "rule: #{laz_rec[:determining_rule].try(:name)})" else "Expected #{@controller.class.name}(#{@controller.params.inspect}) #{match_text} #{match_state}, but flash did not have key :logical_authz_record" end end |
#failure_message_for_should ⇒ Object
37 38 39 |
# File 'lib/logical_authz/spec_helper.rb', line 37 def ("to be") end |
#failure_message_for_should_not ⇒ Object
41 42 43 |
# File 'lib/logical_authz/spec_helper.rb', line 41 def ("not to be") end |
#match_state ⇒ Object
8 9 10 |
# File 'lib/logical_authz/spec_helper.rb', line 8 def match_state "authorized" end |
#matches?(controller) ⇒ Boolean
18 19 20 21 22 23 |
# File 'lib/logical_authz/spec_helper.rb', line 18 def matches?(controller) @controller = controller @flash = controller.__send__(:flash) #controller should be a controller return end |