Class: ApiMaker::SpecHelper::ExecuteMemberCommand
- Inherits:
-
ApplicationService
- Object
- ServicePattern::Service
- ApplicationService
- ApiMaker::SpecHelper::ExecuteMemberCommand
- Includes:
- RSpec::Mocks::ExampleMethods
- Defined in:
- lib/api_maker/spec_helper/execute_member_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 ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #ability ⇒ Object
- #collection ⇒ Object
- #fake_controller ⇒ Object
- #helper ⇒ Object
- #helper_command ⇒ Object
-
#initialize(ability: nil, api_maker_args: nil, collection: nil, command:, fake_controller: nil, model:, args: {}) ⇒ ExecuteMemberCommand
constructor
A new instance of ExecuteMemberCommand.
- #perform ⇒ Object
Methods inherited from ApplicationService
Constructor Details
#initialize(ability: nil, api_maker_args: nil, collection: nil, command:, fake_controller: nil, model:, args: {}) ⇒ ExecuteMemberCommand
Returns a new instance of ExecuteMemberCommand.
6 7 8 9 10 11 12 13 14 |
# File 'lib/api_maker/spec_helper/execute_member_command.rb', line 6 def initialize(ability: nil, api_maker_args: nil, collection: nil, command:, fake_controller: nil, model:, args: {}) @ability = ability @api_maker_args = api_maker_args @args = args @collection = collection @command = command @fake_controller = fake_controller @model = model 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_member_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_member_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_member_command.rb', line 4 def command @command end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/api_maker/spec_helper/execute_member_command.rb', line 4 def model @model end |
Instance Method Details
#ability ⇒ Object
22 23 24 |
# File 'lib/api_maker/spec_helper/execute_member_command.rb', line 22 def ability @ability ||= ApiMaker::Ability.new(api_maker_args: api_maker_args) end |
#collection ⇒ Object
26 27 28 |
# File 'lib/api_maker/spec_helper/execute_member_command.rb', line 26 def collection @collection ||= model.class.where(id: model.id) end |
#fake_controller ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/api_maker/spec_helper/execute_member_command.rb', line 30 def fake_controller @fake_controller ||= instance_double( ApiMaker::BaseController, api_maker_args: api_maker_args, current_ability: ability ) end |
#helper ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/api_maker/spec_helper/execute_member_command.rb', line 38 def helper @helper ||= ApiMaker::CommandSpecHelper.new( collection: collection, command: command, controller: fake_controller ) end |
#helper_command ⇒ Object
46 47 48 49 50 51 |
# File 'lib/api_maker/spec_helper/execute_member_command.rb', line 46 def helper_command @helper_command ||= helper.add_command( primary_key: model.id, args: args ) end |
#perform ⇒ Object
16 17 18 19 20 |
# File 'lib/api_maker/spec_helper/execute_member_command.rb', line 16 def perform helper_command helper.execute! succeed! helper_command.result end |