class ApiMaker::CommandSpecHelper
Attributes
collection[R]
command_class[R]
commands[R]
Public Class Methods
new(command:, collection: nil, controller: nil)
click to toggle source
# File lib/api_maker/command_spec_helper.rb, line 4 def initialize(command:, collection: nil, controller: nil) @collection = collection @command_class = command @commands = {} @controller = controller || double end
Public Instance Methods
add_command(args: {}, primary_key: nil)
click to toggle source
# File lib/api_maker/command_spec_helper.rb, line 11 def add_command(args: {}, primary_key: nil) id = commands.length + 1 commands[id] = { args: ActionController::Parameters.new(args), id: id, primary_key: primary_key } AddedCommand.new(id, response) end
command()
click to toggle source
# File lib/api_maker/command_spec_helper.rb, line 23 def command @command ||= command_class.new( ability: controller.__send__(:current_ability), args: controller.__send__(:api_maker_args), collection: collection, commands: commands, command_response: response, controller: controller ) end
controller()
click to toggle source
# File lib/api_maker/command_spec_helper.rb, line 34 def controller @controller ||= double(current_user: user) end
execute!()
click to toggle source
# File lib/api_maker/command_spec_helper.rb, line 38 def execute! command.execute! ServicePattern::Response.new(success: true) end
response()
click to toggle source
# File lib/api_maker/command_spec_helper.rb, line 43 def response @response ||= ApiMaker::CommandResponse.new(controller: @controller) end