Class: HaveAPI::Spec::MockAction
- Inherits:
-
Object
- Object
- HaveAPI::Spec::MockAction
- Defined in:
- lib/haveapi/spec/mock_action.rb
Instance Method Summary collapse
- #call(input, user: nil) ⇒ Object
-
#initialize(test, server, action, path, v) ⇒ MockAction
constructor
A new instance of MockAction.
Constructor Details
#initialize(test, server, action, path, v) ⇒ MockAction
Returns a new instance of MockAction.
3 4 5 6 7 8 9 |
# File 'lib/haveapi/spec/mock_action.rb', line 3 def initialize(test, server, action, path, v) @test = test @server = server @action = action @path = path @v = v end |
Instance Method Details
#call(input, user: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/haveapi/spec/mock_action.rb', line 11 def call(input, user: nil, &) action = @action.new(nil, @v, input, nil, HaveAPI::Context.new( @server, version: @v, action: @action, path: @path, params: input, user:, endpoint: true )) unless action.(user) raise 'Access denied. Insufficient permissions.' end status, data, errors = action.safe_exec raise(data || 'action failed') unless status action.instance_exec(@test, &) data end |