Class: OsoCloud::ParityHandle

Inherits:
Object
  • Object
show all
Defined in:
lib/oso/parity_handle.rb

Overview

ParityHandle is a testing utility in Oso Migrate for comparing expected authorization decisions with actual Oso results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParityHandle

Returns a new instance of ParityHandle.



24
25
26
27
28
# File 'lib/oso/parity_handle.rb', line 24

def initialize
  @api = nil
  @request_id = nil
  @expected = nil
end

Instance Attribute Details

#expectedObject (readonly)

Returns the value of attribute expected.



22
23
24
# File 'lib/oso/parity_handle.rb', line 22

def expected
  @expected
end

#request_idObject (readonly)

Returns the value of attribute request_id.



22
23
24
# File 'lib/oso/parity_handle.rb', line 22

def request_id
  @request_id
end

Instance Method Details

#expect(expected) ⇒ nil

Expect is a public method for users to indicate the expected result of an authorization query.

Parameters:

  • expected (Boolean)

    Boolean indicating the expected authorization result.

Returns:

  • (nil)

Raises:

  • (StandardError)

    If expected result is set twice.



55
56
57
58
59
60
61
62
# File 'lib/oso/parity_handle.rb', line 55

def expect(expected)
  raise StandardError, 'attempted to set expected result twice' unless @expected.nil?

  @expected = expected

  send_expected_result unless @request_id.nil?
  nil
end