Class: ApiMaker::SpecHelper::ExecuteCollectionCommand
- Inherits:
-
ApplicationService
- Object
- ServicePattern::Service
- ApplicationService
- ApiMaker::SpecHelper::ExecuteCollectionCommand
- Includes:
- RSpec::Mocks::ExampleMethods
- Defined in:
- lib/api_maker/spec_helper/execute_collection_command.rb
Instance Attribute Summary collapse
-
#api_maker_args ⇒ Object
readonly
Returns the value of attribute api_maker_args.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
Instance Method Summary collapse
- #ability ⇒ Object
- #fake_controller ⇒ Object
- #helper ⇒ Object
- #helper_command ⇒ Object
-
#initialize(ability: nil, api_maker_args: {}, args: {}, command:, fake_controller: nil, model_class:) ⇒ ExecuteCollectionCommand
constructor
A new instance of ExecuteCollectionCommand.
- #perform ⇒ Object
Methods inherited from ApplicationService
Constructor Details
#initialize(ability: nil, api_maker_args: {}, args: {}, command:, fake_controller: nil, model_class:) ⇒ ExecuteCollectionCommand
Returns a new instance of ExecuteCollectionCommand.
6 7 8 9 10 11 12 13 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 6 def initialize(ability: nil, api_maker_args: {}, args: {}, command:, fake_controller: nil, model_class:) @ability = ability @api_maker_args = api_maker_args @args = args @command = command @fake_controller = fake_controller @model_class = model_class end |
Instance Attribute Details
#api_maker_args ⇒ Object (readonly)
Returns the value of attribute api_maker_args.
4 5 6 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 4 def api_maker_args @api_maker_args end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 4 def args @args end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 4 def command @command end |
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
4 5 6 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 4 def model_class @model_class end |
Instance Method Details
#ability ⇒ Object
21 22 23 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 21 def ability @ability ||= ApiMaker::Ability.new(api_maker_args: api_maker_args) end |
#fake_controller ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 25 def fake_controller @fake_controller ||= instance_double( ApiMaker::BaseController, api_maker_args: api_maker_args, current_ability: ability ) end |
#helper ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 33 def helper @helper ||= ApiMaker::CommandSpecHelper.new( collection: model_class, command: command, controller: fake_controller ) end |
#helper_command ⇒ Object
41 42 43 44 45 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 41 def helper_command @helper_command ||= helper.add_command( args: args ) end |
#perform ⇒ Object
15 16 17 18 19 |
# File 'lib/api_maker/spec_helper/execute_collection_command.rb', line 15 def perform helper_command helper.execute! succeed! helper_command.result end |