convenient_service 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/convenient_service/common/plugins/ensures_negated_j_send_result/middleware.rb +22 -0
- data/lib/convenient_service/common/plugins/ensures_negated_j_send_result.rb +3 -0
- data/lib/convenient_service/common/plugins/has_around_callbacks/concern.rb +8 -1
- data/lib/convenient_service/common/plugins/has_around_callbacks/middleware.rb +28 -7
- data/lib/convenient_service/common/plugins/has_callbacks/concern.rb +19 -9
- data/lib/convenient_service/common/plugins/has_callbacks/entities/callback_collection.rb +49 -1
- data/lib/convenient_service/common/plugins/has_callbacks/middleware.rb +21 -3
- data/lib/convenient_service/common/plugins/has_callbacks.rb +0 -1
- data/lib/convenient_service/common/plugins/has_instance_proxy/entities/instance_proxy.rb +1 -1
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb +12 -0
- data/lib/convenient_service/common/plugins.rb +1 -0
- data/lib/convenient_service/core/entities/config/exceptions.rb +2 -0
- data/lib/convenient_service/core/entities/config.rb +3 -0
- data/lib/convenient_service/dependencies.rb +11 -3
- data/lib/convenient_service/logger.rb +9 -1
- data/lib/convenient_service/rspec/matchers/classes/call_chain_next.rb +41 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb +46 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/delegation.rb +89 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb +223 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/outputs.rb +38 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matcher_collection.rb +157 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/apply_stub_to_track_delegations.rb +77 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb +94 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments.rb +89 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/base.rb +99 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_custom_value.rb +91 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/return_delegation_value.rb +129 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/with_any_arguments.rb +31 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/with_concrete_arguments.rb +31 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/without_arguments.rb +31 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers.rb +11 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities.rb +5 -1
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/exceptions.rb +65 -0
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to.rb +163 -41
- data/lib/convenient_service/service/configs/minimal.rb +85 -33
- data/lib/convenient_service/service/configs/standard/v1.rb +42 -24
- data/lib/convenient_service/service/configs/standard.rb +60 -46
- data/lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb +503 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/and.rb +133 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/base.rb +126 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/empty.rb +104 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/group.rb +118 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/not.rb +118 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/or.rb +145 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions/scalar.rb +133 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/expressions.rb +10 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb +217 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/entities.rb +4 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/exceptions.rb +95 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps/middleware.rb +30 -0
- data/lib/convenient_service/service/plugins/can_have_connected_steps.rb +6 -0
- data/lib/convenient_service/service/plugins/can_have_sequential_steps/concern.rb +76 -0
- data/lib/convenient_service/service/plugins/{can_have_steps → can_have_sequential_steps}/entities/step_collection.rb +54 -10
- data/lib/convenient_service/service/plugins/can_have_sequential_steps/entities.rb +3 -0
- data/lib/convenient_service/service/plugins/{can_have_steps → can_have_sequential_steps}/middleware.rb +7 -3
- data/lib/convenient_service/service/plugins/can_have_sequential_steps.rb +5 -0
- data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +4 -57
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/define_method_in_container.rb +45 -26
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment.rb +0 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/exceptions.rb +4 -24
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/concern/instance_methods.rb +155 -80
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/exceptions.rb +19 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/{can_be_result_step → can_be_method_step}/can_be_executed/exceptions.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/can_be_executed/middleware.rb +64 -4
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/can_be_executed.rb +1 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/concern.rb +7 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_alternative_steps.rb +3 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/concern.rb +0 -46
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/middleware.rb +26 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_parent_result/middleware.rb +13 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/{can_be_result_step → has_result}/concern.rb +8 -4
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result/middleware.rb +33 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result.rb +4 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +2 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities.rb +0 -1
- data/lib/convenient_service/service/plugins/can_have_steps.rb +0 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/concern.rb +2 -2
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status.rb +0 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb +135 -2
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern/instance_methods.rb +45 -17
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/can_be_checked/concern.rb +38 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/can_be_checked/middleware.rb +51 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/can_be_checked.rb +4 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins.rb +1 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/exceptions.rb +15 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result/concern.rb +72 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result.rb +3 -0
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/raises_on_not_checked_result_status/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +1 -0
- data/lib/convenient_service/service/plugins/has_j_send_result.rb +0 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation/middleware.rb +4 -0
- data/lib/convenient_service/service/plugins/has_negated_j_send_result/concern.rb +23 -0
- data/lib/convenient_service/service/plugins/has_negated_j_send_result.rb +3 -0
- data/lib/convenient_service/service/plugins/has_negated_result/concern.rb +33 -0
- data/lib/convenient_service/service/plugins/{has_j_send_result → has_negated_result}/exceptions.rb +3 -3
- data/lib/convenient_service/service/plugins/has_negated_result.rb +4 -0
- data/lib/convenient_service/service/plugins/{wraps_result_in_db_transaction → wraps_result_in_d_b_transaction}/middleware.rb +1 -1
- data/lib/convenient_service/service/plugins.rb +7 -2
- data/lib/convenient_service/specification.rb +28 -0
- data/lib/convenient_service/support/backtrace_cleaner.rb +6 -1
- data/lib/convenient_service/support/cache/entities/caches/base.rb +3 -0
- data/lib/convenient_service/support/method_parameters.rb +121 -0
- data/lib/convenient_service/support/never_reach_here.rb +21 -0
- data/lib/convenient_service/support/unique_value.rb +3 -0
- data/lib/convenient_service/support/value.rb +78 -0
- data/lib/convenient_service/support.rb +3 -0
- data/lib/convenient_service/utils/array/find_last.rb +8 -3
- data/lib/convenient_service/utils/object/instance_variable_delete.rb +1 -1
- data/lib/convenient_service/version.rb +1 -1
- data/lib/convenient_service.rb +23 -0
- metadata +109 -308
- data/.dev/.tmuxinator.yml +0 -22
- data/.dockerignore +0 -1
- data/.gem_release.yml +0 -11
- data/.github/contributing.md +0 -15
- data/.github/issue_template.md +0 -35
- data/.github/pull_request_template.md +0 -31
- data/.github/workflows/cd.yml +0 -68
- data/.github/workflows/ci.yml +0 -212
- data/.gitignore +0 -66
- data/.inch.yml +0 -7
- data/.rspec +0 -3
- data/.rubocop.yml +0 -45
- data/.rubocop_rspec.yml +0 -58
- data/.ruby-version +0 -1
- data/.tool-versions +0 -1
- data/.vscode/CacheItsValue.code-snippets +0 -15
- data/.vscode/DelegateTo.code-snippets +0 -15
- data/.vscode/cache_its_value.code-snippets +0 -17
- data/.vscode/comparison.code-snippets +0 -41
- data/.vscode/delegate_to.code-snippets +0 -20
- data/.yardopts +0 -16
- data/Appraisals +0 -146
- data/CHANGELOG.md +0 -504
- data/Gemfile +0 -17
- data/ROADMAP.md +0 -92
- data/Rakefile +0 -54
- data/Taskfile.yml +0 -679
- data/benchmark/commit_config/ips.rb +0 -18
- data/benchmark/commit_config/profile.rb +0 -30
- data/benchmark/empty_service/ips.rb +0 -123
- data/benchmark/has_committed_config/ips.rb +0 -78
- data/benchmark/has_committed_config/profile.rb +0 -30
- data/convenient_service.gemspec +0 -233
- data/coverage/.gitkeep +0 -0
- data/docker/2.7/Dockerfile +0 -73
- data/docker/3.0/Dockerfile +0 -73
- data/docker/3.1/Dockerfile +0 -73
- data/docker/3.2/Dockerfile +0 -73
- data/docker/jruby-9.4/Dockerfile +0 -88
- data/docker/truffleruby-22.3/Dockerfile +0 -91
- data/docs/.gitkeep +0 -0
- data/docs/api/.gitkeep +0 -0
- data/env.rb +0 -23
- data/gemfiles/.gitkeep +0 -0
- data/lib/convenient_service/common/plugins/has_callbacks/container.rb +0 -17
- data/lib/convenient_service/examples/dry/gemfile/dry_service/config.rb +0 -45
- data/lib/convenient_service/examples/dry/gemfile/dry_service.rb +0 -3
- data/lib/convenient_service/examples/dry/gemfile/services/assert_file_exists.rb +0 -29
- data/lib/convenient_service/examples/dry/gemfile/services/assert_file_not_empty.rb +0 -29
- data/lib/convenient_service/examples/dry/gemfile/services/assert_node_available.rb +0 -26
- data/lib/convenient_service/examples/dry/gemfile/services/assert_npm_package_available.rb +0 -39
- data/lib/convenient_service/examples/dry/gemfile/services/assert_valid_ruby_syntax.rb +0 -41
- data/lib/convenient_service/examples/dry/gemfile/services/format.rb +0 -37
- data/lib/convenient_service/examples/dry/gemfile/services/format_body.rb +0 -93
- data/lib/convenient_service/examples/dry/gemfile/services/format_gems_with_envs.rb +0 -96
- data/lib/convenient_service/examples/dry/gemfile/services/format_gems_without_envs.rb +0 -84
- data/lib/convenient_service/examples/dry/gemfile/services/format_header.rb +0 -74
- data/lib/convenient_service/examples/dry/gemfile/services/parse_content.rb +0 -93
- data/lib/convenient_service/examples/dry/gemfile/services/print_shell_command.rb +0 -44
- data/lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb +0 -31
- data/lib/convenient_service/examples/dry/gemfile/services/run_shell_command.rb +0 -45
- data/lib/convenient_service/examples/dry/gemfile/services/strip_comments.rb +0 -109
- data/lib/convenient_service/examples/dry/gemfile/services.rb +0 -18
- data/lib/convenient_service/examples/dry/gemfile.rb +0 -27
- data/lib/convenient_service/examples/dry/v1/gemfile/dry_service/config.rb +0 -47
- data/lib/convenient_service/examples/dry/v1/gemfile/dry_service.rb +0 -3
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_file_exists.rb +0 -31
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_file_not_empty.rb +0 -31
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_node_available.rb +0 -28
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_npm_package_available.rb +0 -41
- data/lib/convenient_service/examples/dry/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -43
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format.rb +0 -39
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_body.rb +0 -95
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_gems_with_envs.rb +0 -98
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_gems_without_envs.rb +0 -86
- data/lib/convenient_service/examples/dry/v1/gemfile/services/format_header.rb +0 -76
- data/lib/convenient_service/examples/dry/v1/gemfile/services/parse_content.rb +0 -95
- data/lib/convenient_service/examples/dry/v1/gemfile/services/read_file_content.rb +0 -33
- data/lib/convenient_service/examples/dry/v1/gemfile/services/run_shell_command.rb +0 -43
- data/lib/convenient_service/examples/dry/v1/gemfile/services/strip_comments.rb +0 -111
- data/lib/convenient_service/examples/dry/v1/gemfile/services.rb +0 -17
- data/lib/convenient_service/examples/dry/v1/gemfile.rb +0 -29
- data/lib/convenient_service/examples/rails/gemfile/rails_service/config.rb +0 -56
- data/lib/convenient_service/examples/rails/gemfile/rails_service.rb +0 -3
- data/lib/convenient_service/examples/rails/gemfile/services/assert_file_exists.rb +0 -25
- data/lib/convenient_service/examples/rails/gemfile/services/assert_file_not_empty.rb +0 -25
- data/lib/convenient_service/examples/rails/gemfile/services/assert_node_available.rb +0 -26
- data/lib/convenient_service/examples/rails/gemfile/services/assert_npm_package_available.rb +0 -35
- data/lib/convenient_service/examples/rails/gemfile/services/assert_valid_ruby_syntax.rb +0 -35
- data/lib/convenient_service/examples/rails/gemfile/services/format.rb +0 -66
- data/lib/convenient_service/examples/rails/gemfile/services/format_body.rb +0 -79
- data/lib/convenient_service/examples/rails/gemfile/services/format_gems_with_envs.rb +0 -82
- data/lib/convenient_service/examples/rails/gemfile/services/format_gems_without_envs.rb +0 -70
- data/lib/convenient_service/examples/rails/gemfile/services/format_header.rb +0 -68
- data/lib/convenient_service/examples/rails/gemfile/services/merge_sections.rb +0 -25
- data/lib/convenient_service/examples/rails/gemfile/services/parse_content.rb +0 -89
- data/lib/convenient_service/examples/rails/gemfile/services/print_shell_command.rb +0 -40
- data/lib/convenient_service/examples/rails/gemfile/services/read_file_content.rb +0 -27
- data/lib/convenient_service/examples/rails/gemfile/services/replace_file_content.rb +0 -37
- data/lib/convenient_service/examples/rails/gemfile/services/run_shell_command.rb +0 -40
- data/lib/convenient_service/examples/rails/gemfile/services/strip_comments.rb +0 -107
- data/lib/convenient_service/examples/rails/gemfile/services.rb +0 -21
- data/lib/convenient_service/examples/rails/gemfile.rb +0 -27
- data/lib/convenient_service/examples/rails/v1/gemfile/rails_service/config.rb +0 -58
- data/lib/convenient_service/examples/rails/v1/gemfile/rails_service.rb +0 -3
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_file_exists.rb +0 -27
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_file_not_empty.rb +0 -27
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_node_available.rb +0 -28
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_npm_package_available.rb +0 -37
- data/lib/convenient_service/examples/rails/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -37
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format.rb +0 -68
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_body.rb +0 -81
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_gems_with_envs.rb +0 -84
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_gems_without_envs.rb +0 -72
- data/lib/convenient_service/examples/rails/v1/gemfile/services/format_header.rb +0 -70
- data/lib/convenient_service/examples/rails/v1/gemfile/services/merge_sections.rb +0 -27
- data/lib/convenient_service/examples/rails/v1/gemfile/services/parse_content.rb +0 -91
- data/lib/convenient_service/examples/rails/v1/gemfile/services/read_file_content.rb +0 -29
- data/lib/convenient_service/examples/rails/v1/gemfile/services/replace_file_content.rb +0 -39
- data/lib/convenient_service/examples/rails/v1/gemfile/services/run_shell_command.rb +0 -38
- data/lib/convenient_service/examples/rails/v1/gemfile/services/strip_comments.rb +0 -109
- data/lib/convenient_service/examples/rails/v1/gemfile/services.rb +0 -20
- data/lib/convenient_service/examples/rails/v1/gemfile.rb +0 -29
- data/lib/convenient_service/examples/standard/cowsay/services/build_cloud.rb +0 -42
- data/lib/convenient_service/examples/standard/cowsay/services/build_cow.rb +0 -38
- data/lib/convenient_service/examples/standard/cowsay/services/print.rb +0 -32
- data/lib/convenient_service/examples/standard/cowsay/services.rb +0 -5
- data/lib/convenient_service/examples/standard/cowsay.rb +0 -26
- data/lib/convenient_service/examples/standard/date_time/services/safe_parse.rb +0 -31
- data/lib/convenient_service/examples/standard/date_time/services.rb +0 -3
- data/lib/convenient_service/examples/standard/date_time.rb +0 -25
- data/lib/convenient_service/examples/standard/factorial/services/calculate.rb +0 -55
- data/lib/convenient_service/examples/standard/factorial/services.rb +0 -3
- data/lib/convenient_service/examples/standard/factorial/utils/timeout/with_timeout.rb +0 -50
- data/lib/convenient_service/examples/standard/factorial/utils/timeout.rb +0 -21
- data/lib/convenient_service/examples/standard/factorial/utils.rb +0 -3
- data/lib/convenient_service/examples/standard/factorial.rb +0 -26
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb +0 -30
- data/lib/convenient_service/examples/standard/gemfile/services/assert_file_not_empty.rb +0 -30
- data/lib/convenient_service/examples/standard/gemfile/services/assert_node_available.rb +0 -26
- data/lib/convenient_service/examples/standard/gemfile/services/assert_npm_package_available.rb +0 -48
- data/lib/convenient_service/examples/standard/gemfile/services/assert_valid_ruby_syntax.rb +0 -39
- data/lib/convenient_service/examples/standard/gemfile/services/format.rb +0 -80
- data/lib/convenient_service/examples/standard/gemfile/services/format_body.rb +0 -83
- data/lib/convenient_service/examples/standard/gemfile/services/format_gems_with_envs.rb +0 -86
- data/lib/convenient_service/examples/standard/gemfile/services/format_gems_without_envs.rb +0 -74
- data/lib/convenient_service/examples/standard/gemfile/services/format_header.rb +0 -66
- data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +0 -52
- data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +0 -101
- data/lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb +0 -45
- data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +0 -39
- data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +0 -48
- data/lib/convenient_service/examples/standard/gemfile/services/run_shell_command.rb +0 -54
- data/lib/convenient_service/examples/standard/gemfile/services/strip_comments.rb +0 -111
- data/lib/convenient_service/examples/standard/gemfile/services.rb +0 -21
- data/lib/convenient_service/examples/standard/gemfile.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/constants.rb +0 -15
- data/lib/convenient_service/examples/standard/request_params/entities/description.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities/format.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities/id.rb +0 -47
- data/lib/convenient_service/examples/standard/request_params/entities/logger.rb +0 -21
- data/lib/convenient_service/examples/standard/request_params/entities/request.rb +0 -23
- data/lib/convenient_service/examples/standard/request_params/entities/source.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities/tag.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities/title.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/entities.rb +0 -11
- data/lib/convenient_service/examples/standard/request_params/services/apply_default_param_values.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/services/cast_params.rb +0 -38
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_body.rb +0 -70
- data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb +0 -62
- data/lib/convenient_service/examples/standard/request_params/services/filter_out_unpermitted_params.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/services/log_request_params.rb +0 -54
- data/lib/convenient_service/examples/standard/request_params/services/merge_params.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/services/prepare.rb +0 -65
- data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb +0 -94
- data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb +0 -72
- data/lib/convenient_service/examples/standard/request_params/services.rb +0 -13
- data/lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb +0 -46
- data/lib/convenient_service/examples/standard/request_params/utils/array.rb +0 -21
- data/lib/convenient_service/examples/standard/request_params/utils/http/request/parse_body.rb +0 -42
- data/lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/utils/http/request.rb +0 -28
- data/lib/convenient_service/examples/standard/request_params/utils/http.rb +0 -3
- data/lib/convenient_service/examples/standard/request_params/utils/integer/safe_parse.rb +0 -31
- data/lib/convenient_service/examples/standard/request_params/utils/integer.rb +0 -25
- data/lib/convenient_service/examples/standard/request_params/utils/json/safe_parse.rb +0 -40
- data/lib/convenient_service/examples/standard/request_params/utils/json.rb +0 -21
- data/lib/convenient_service/examples/standard/request_params/utils/object/blank.rb +0 -34
- data/lib/convenient_service/examples/standard/request_params/utils/object/present.rb +0 -31
- data/lib/convenient_service/examples/standard/request_params/utils/object.rb +0 -26
- data/lib/convenient_service/examples/standard/request_params/utils/url/valid.rb +0 -47
- data/lib/convenient_service/examples/standard/request_params/utils/url.rb +0 -21
- data/lib/convenient_service/examples/standard/request_params/utils.rb +0 -8
- data/lib/convenient_service/examples/standard/request_params.rb +0 -49
- data/lib/convenient_service/examples/standard/v1/cowsay/services/build_cloud.rb +0 -44
- data/lib/convenient_service/examples/standard/v1/cowsay/services/build_cow.rb +0 -40
- data/lib/convenient_service/examples/standard/v1/cowsay/services/print.rb +0 -34
- data/lib/convenient_service/examples/standard/v1/cowsay/services.rb +0 -5
- data/lib/convenient_service/examples/standard/v1/cowsay.rb +0 -26
- data/lib/convenient_service/examples/standard/v1/date_time/services/safe_parse.rb +0 -33
- data/lib/convenient_service/examples/standard/v1/date_time/services.rb +0 -3
- data/lib/convenient_service/examples/standard/v1/date_time.rb +0 -25
- data/lib/convenient_service/examples/standard/v1/factorial/services/calculate.rb +0 -51
- data/lib/convenient_service/examples/standard/v1/factorial/services.rb +0 -3
- data/lib/convenient_service/examples/standard/v1/factorial/utils/timeout/with_timeout.rb +0 -52
- data/lib/convenient_service/examples/standard/v1/factorial/utils/timeout.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/factorial/utils.rb +0 -3
- data/lib/convenient_service/examples/standard/v1/factorial.rb +0 -26
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_exists.rb +0 -32
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_not_empty.rb +0 -32
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_node_available.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_npm_package_available.rb +0 -50
- data/lib/convenient_service/examples/standard/v1/gemfile/services/assert_valid_ruby_syntax.rb +0 -41
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format.rb +0 -82
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_body.rb +0 -85
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_gems_with_envs.rb +0 -88
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_gems_without_envs.rb +0 -76
- data/lib/convenient_service/examples/standard/v1/gemfile/services/format_header.rb +0 -68
- data/lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb +0 -54
- data/lib/convenient_service/examples/standard/v1/gemfile/services/parse_content.rb +0 -103
- data/lib/convenient_service/examples/standard/v1/gemfile/services/read_file_content.rb +0 -41
- data/lib/convenient_service/examples/standard/v1/gemfile/services/replace_file_content.rb +0 -50
- data/lib/convenient_service/examples/standard/v1/gemfile/services/run_shell_command.rb +0 -52
- data/lib/convenient_service/examples/standard/v1/gemfile/services/strip_comments.rb +0 -113
- data/lib/convenient_service/examples/standard/v1/gemfile/services.rb +0 -20
- data/lib/convenient_service/examples/standard/v1/gemfile.rb +0 -26
- data/lib/convenient_service/examples/standard/v1/request_params/constants.rb +0 -17
- data/lib/convenient_service/examples/standard/v1/request_params/entities/description.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities/format.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities/id.rb +0 -49
- data/lib/convenient_service/examples/standard/v1/request_params/entities/logger.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/request_params/entities/request.rb +0 -25
- data/lib/convenient_service/examples/standard/v1/request_params/entities/source.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities/tag.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities/title.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/entities.rb +0 -11
- data/lib/convenient_service/examples/standard/v1/request_params/services/apply_default_param_values.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/request_params/services/cast_params.rb +0 -40
- data/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_body.rb +0 -72
- data/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_path.rb +0 -64
- data/lib/convenient_service/examples/standard/v1/request_params/services/filter_out_unpermitted_params.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/request_params/services/log_request_params.rb +0 -56
- data/lib/convenient_service/examples/standard/v1/request_params/services/merge_params.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/request_params/services/prepare.rb +0 -67
- data/lib/convenient_service/examples/standard/v1/request_params/services/validate_casted_params.rb +0 -96
- data/lib/convenient_service/examples/standard/v1/request_params/services/validate_uncasted_params.rb +0 -74
- data/lib/convenient_service/examples/standard/v1/request_params/services.rb +0 -13
- data/lib/convenient_service/examples/standard/v1/request_params/utils/array/wrap.rb +0 -48
- data/lib/convenient_service/examples/standard/v1/request_params/utils/array.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request/parse_body.rb +0 -44
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request/parse_path.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http/request.rb +0 -30
- data/lib/convenient_service/examples/standard/v1/request_params/utils/http.rb +0 -3
- data/lib/convenient_service/examples/standard/v1/request_params/utils/integer/safe_parse.rb +0 -33
- data/lib/convenient_service/examples/standard/v1/request_params/utils/integer.rb +0 -27
- data/lib/convenient_service/examples/standard/v1/request_params/utils/json/safe_parse.rb +0 -42
- data/lib/convenient_service/examples/standard/v1/request_params/utils/json.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object/blank.rb +0 -36
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object/present.rb +0 -33
- data/lib/convenient_service/examples/standard/v1/request_params/utils/object.rb +0 -28
- data/lib/convenient_service/examples/standard/v1/request_params/utils/url/valid.rb +0 -49
- data/lib/convenient_service/examples/standard/v1/request_params/utils/url.rb +0 -23
- data/lib/convenient_service/examples/standard/v1/request_params/utils.rb +0 -8
- data/lib/convenient_service/examples/standard/v1/request_params.rb +0 -49
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/commands/generate_printable_method.rb +0 -50
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/apply_stub_to_track_delegations.rb +0 -82
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments/commands/generate_printable_arguments.rb +0 -100
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/arguments.rb +0 -95
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/base.rb +0 -87
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/return_its_value.rb +0 -132
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_any_arguments.rb +0 -37
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/with_concrete_arguments.rb +0 -37
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/sub_matchers/without_arguments.rb +0 -37
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/base.rb +0 -41
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/with_calling_original.rb +0 -30
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings/values/without_calling_original.rb +0 -30
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings.rb +0 -12
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings_collection/exceptions.rb +0 -57
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/chainings_collection.rb +0 -171
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities/delegation.rb +0 -79
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher/entities.rb +0 -5
- data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/matcher.rb +0 -276
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment/commands/define_method_in_container.rb +0 -74
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/entities/callers/reassignment/commands.rb +0 -3
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step/can_be_executed/middleware.rb +0 -72
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step/can_be_executed.rb +0 -4
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_result_step.rb +0 -5
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/middleware.rb +0 -43
- data/logo.png +0 -0
- data/minitest.rb +0 -30
- data/yard/yard-convenient_service_concern.rb +0 -45
- /data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/{entities/matcher/commands.rb → commands.rb} +0 -0
- /data/lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/{matcher/entities/chainings/sub_matchers → sub_matchers}/arguments/commands.rb +0 -0
@@ -0,0 +1,223 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module PrimitiveMatchers
|
6
|
+
module Classes
|
7
|
+
class DelegateTo
|
8
|
+
module Entities
|
9
|
+
class Inputs
|
10
|
+
##
|
11
|
+
# @api private
|
12
|
+
#
|
13
|
+
# @!attribute [r] values
|
14
|
+
# @return [Hash{Symbol => Object}]
|
15
|
+
#
|
16
|
+
attr_reader :values
|
17
|
+
|
18
|
+
##
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
# @param object [Object]
|
22
|
+
# @param method [String, Symbol]
|
23
|
+
# @param block_expectation [Proc]
|
24
|
+
# @return [void]
|
25
|
+
#
|
26
|
+
def initialize(object:, method:, block_expectation:)
|
27
|
+
@values = {object: object, method: method, block_expectation: block_expectation}
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# @api private
|
32
|
+
#
|
33
|
+
# @return [Proc, nil]
|
34
|
+
#
|
35
|
+
def block_expectation
|
36
|
+
values[:block_expectation]
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# @api private
|
41
|
+
#
|
42
|
+
# @return [Object] Can be any type.
|
43
|
+
#
|
44
|
+
# @internal
|
45
|
+
# IMPORTANT: Must be refreshed when `expected_arguments` are reset.
|
46
|
+
#
|
47
|
+
def custom_return_value
|
48
|
+
return values[:custom_return_value] if values.has_key?(:custom_return_value)
|
49
|
+
|
50
|
+
values[:custom_return_value] = expected_return_value_block.call(delegation_value)
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# @api private
|
55
|
+
#
|
56
|
+
# @return [Object] Can be any type.
|
57
|
+
#
|
58
|
+
# @internal
|
59
|
+
# IMPORTANT: Must be refreshed when `expected_arguments` are reset.
|
60
|
+
#
|
61
|
+
def delegation_value
|
62
|
+
return values[:delegation_value] if values.has_key?(:delegation_value)
|
63
|
+
|
64
|
+
values[:delegation_value] =
|
65
|
+
object.__send__(
|
66
|
+
method,
|
67
|
+
*expected_arguments.args,
|
68
|
+
**expected_arguments.kwargs,
|
69
|
+
&expected_arguments.block
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# @api private
|
75
|
+
#
|
76
|
+
# @return [ConvenientService::Support::Arguments]
|
77
|
+
#
|
78
|
+
def expected_arguments
|
79
|
+
values[:expected_arguments] ||= Support::Arguments.null_arguments
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# @api private
|
84
|
+
#
|
85
|
+
# @return [Proc]
|
86
|
+
#
|
87
|
+
def expected_return_value_block
|
88
|
+
values[:expected_return_value_block] ||= proc { Support::UNDEFINED }
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# @api private
|
93
|
+
#
|
94
|
+
# @return [String, Symbol]
|
95
|
+
#
|
96
|
+
def method
|
97
|
+
values[:method]
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# @api private
|
102
|
+
#
|
103
|
+
# @return [Object] Can be any type.
|
104
|
+
#
|
105
|
+
def object
|
106
|
+
values[:object]
|
107
|
+
end
|
108
|
+
|
109
|
+
##
|
110
|
+
# @api private
|
111
|
+
#
|
112
|
+
# @return [String]
|
113
|
+
#
|
114
|
+
def printable_block_expectation
|
115
|
+
@printable_block_expectation ||= Utils::Proc.display(block_expectation)
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# @api private
|
120
|
+
#
|
121
|
+
# @return [String]
|
122
|
+
#
|
123
|
+
def printable_method
|
124
|
+
@printable_method ||= Commands::GeneratePrintableMethod.call(object: object, method: method)
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# @api private
|
129
|
+
#
|
130
|
+
# @return [Boolean]
|
131
|
+
#
|
132
|
+
def has_call_original?
|
133
|
+
values.has_key?(:should_call_original)
|
134
|
+
end
|
135
|
+
|
136
|
+
##
|
137
|
+
# @api private
|
138
|
+
#
|
139
|
+
# @return [Boolean]
|
140
|
+
#
|
141
|
+
def should_call_original?
|
142
|
+
return values[:should_call_original] if values.has_key?(:should_call_original)
|
143
|
+
|
144
|
+
values[:should_call_original] = true
|
145
|
+
end
|
146
|
+
|
147
|
+
##
|
148
|
+
# @api private
|
149
|
+
#
|
150
|
+
# @return [Proc]
|
151
|
+
#
|
152
|
+
def block_expectation=(block)
|
153
|
+
values[:block_expectation] = block
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# @api private
|
158
|
+
#
|
159
|
+
# @param arguments [ConvenientService::Support::Arguments]
|
160
|
+
# @return [ConvenientService::Support::Arguments]
|
161
|
+
#
|
162
|
+
def expected_arguments=(arguments)
|
163
|
+
values.delete(:delegation_value)
|
164
|
+
values.delete(:custom_return_value)
|
165
|
+
|
166
|
+
values[:expected_arguments] = arguments
|
167
|
+
end
|
168
|
+
|
169
|
+
##
|
170
|
+
# @api private
|
171
|
+
#
|
172
|
+
# @param flag [Boolean]
|
173
|
+
# @return [Boolean]
|
174
|
+
#
|
175
|
+
def should_call_original=(flag)
|
176
|
+
values[:should_call_original] = flag
|
177
|
+
end
|
178
|
+
|
179
|
+
##
|
180
|
+
# @api private
|
181
|
+
#
|
182
|
+
# @param block [Proc]
|
183
|
+
# @return [Proc]
|
184
|
+
# @raise [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Exceptions::ReturnCustomValueChainingInvalidArguments]
|
185
|
+
#
|
186
|
+
def update_expected_return_value_block(*args, &block)
|
187
|
+
values.delete(:custom_return_value)
|
188
|
+
|
189
|
+
values[:expected_return_value_block] =
|
190
|
+
if args.any? && block
|
191
|
+
::ConvenientService.raise Exceptions::ReturnCustomValueChainingInvalidArguments.new
|
192
|
+
elsif args.any?
|
193
|
+
proc { args.first }
|
194
|
+
elsif block
|
195
|
+
block
|
196
|
+
else
|
197
|
+
::ConvenientService.raise Exceptions::ReturnCustomValueChainingInvalidArguments.new
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
##
|
202
|
+
# @api private
|
203
|
+
#
|
204
|
+
# @param other [Object] Can be any type.
|
205
|
+
# @return [Boolean, nil]
|
206
|
+
#
|
207
|
+
# @internal
|
208
|
+
# TODO: Unify `==(other)` YARD tags.
|
209
|
+
#
|
210
|
+
def ==(other)
|
211
|
+
return unless other.instance_of?(self.class)
|
212
|
+
|
213
|
+
return false if values != other.values
|
214
|
+
|
215
|
+
true
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module PrimitiveMatchers
|
6
|
+
module Classes
|
7
|
+
class DelegateTo
|
8
|
+
module Entities
|
9
|
+
class Outputs
|
10
|
+
##
|
11
|
+
# @api private
|
12
|
+
#
|
13
|
+
# @return [Array]
|
14
|
+
#
|
15
|
+
def delegations
|
16
|
+
@delegations ||= []
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# @api private
|
21
|
+
#
|
22
|
+
# @param other [Object] Can be any type.
|
23
|
+
# @return [Boolean, nil]
|
24
|
+
#
|
25
|
+
def ==(other)
|
26
|
+
return unless other.instance_of?(self.class)
|
27
|
+
|
28
|
+
return false if delegations != other.delegations
|
29
|
+
|
30
|
+
true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module PrimitiveMatchers
|
6
|
+
module Classes
|
7
|
+
class DelegateTo
|
8
|
+
module Entities
|
9
|
+
class SubMatcherCollection
|
10
|
+
##
|
11
|
+
# @api private
|
12
|
+
#
|
13
|
+
# @!attribute [r] block_expectation_value
|
14
|
+
# @return [Object]
|
15
|
+
#
|
16
|
+
attr_reader :block_expectation_value
|
17
|
+
|
18
|
+
##
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
# @!attribute [r] matcher
|
22
|
+
# @return [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers]
|
23
|
+
#
|
24
|
+
attr_reader :matcher
|
25
|
+
|
26
|
+
##
|
27
|
+
# @api private
|
28
|
+
#
|
29
|
+
# @!attribute [r] sub_matchers
|
30
|
+
# @return [Hash]
|
31
|
+
#
|
32
|
+
attr_reader :sub_matchers
|
33
|
+
|
34
|
+
##
|
35
|
+
# @api private
|
36
|
+
#
|
37
|
+
# @param matcher [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo]
|
38
|
+
# @return [void]
|
39
|
+
#
|
40
|
+
def initialize(matcher:)
|
41
|
+
@matcher = matcher
|
42
|
+
@sub_matchers = {}
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# @api private
|
47
|
+
#
|
48
|
+
# @param block_expectation [Proc]
|
49
|
+
# @return [Boolean]
|
50
|
+
#
|
51
|
+
def matches?(block_expectation)
|
52
|
+
sub_matchers_ordered_by_index.each(&:apply_stubs!)
|
53
|
+
|
54
|
+
@block_expectation_value = block_expectation.call
|
55
|
+
|
56
|
+
sub_matchers_ordered_by_index.all? { |sub_matcher| sub_matcher.matches?(@block_expectation_value) }
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# @api private
|
61
|
+
#
|
62
|
+
# @return [String]
|
63
|
+
#
|
64
|
+
def failure_message
|
65
|
+
sub_matchers_ordered_by_index
|
66
|
+
.lazy
|
67
|
+
.reject { |sub_matcher| sub_matcher.matches?(block_expectation_value) }
|
68
|
+
.first
|
69
|
+
&.failure_message
|
70
|
+
.to_s
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# @api private
|
75
|
+
#
|
76
|
+
# @return [String]
|
77
|
+
#
|
78
|
+
def failure_message_when_negated
|
79
|
+
sub_matchers_ordered_by_index
|
80
|
+
.reject { |sub_matcher| sub_matcher.does_not_match?(block_expectation_value) }
|
81
|
+
.last
|
82
|
+
&.failure_message_when_negated
|
83
|
+
.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# @api private
|
88
|
+
#
|
89
|
+
# @return [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::Arguments]
|
90
|
+
#
|
91
|
+
def arguments
|
92
|
+
sub_matchers[:arguments] ||= Entities::SubMatchers::WithAnyArguments.new(matcher: matcher)
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# @api private
|
97
|
+
#
|
98
|
+
# @return [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::ReturnValue, nil]
|
99
|
+
#
|
100
|
+
def return_value
|
101
|
+
sub_matchers[:return_value]
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# @api private
|
106
|
+
#
|
107
|
+
# @return [Array]
|
108
|
+
#
|
109
|
+
# @internal
|
110
|
+
# IMPORTANT: Order of sub matcher chainings matters.
|
111
|
+
#
|
112
|
+
def sub_matchers_ordered_by_index
|
113
|
+
[arguments, return_value].compact
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# @api private
|
118
|
+
#
|
119
|
+
# @return [Boolean]
|
120
|
+
#
|
121
|
+
def has_arguments?
|
122
|
+
sub_matchers.has_key?(:arguments)
|
123
|
+
end
|
124
|
+
|
125
|
+
##
|
126
|
+
# @api private
|
127
|
+
#
|
128
|
+
# @return [Boolean]
|
129
|
+
#
|
130
|
+
def has_return_value?
|
131
|
+
sub_matchers.has_key?(:return_value)
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# @api private
|
136
|
+
#
|
137
|
+
# @param sub_matcher [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::Arguments]
|
138
|
+
#
|
139
|
+
def arguments=(sub_matcher)
|
140
|
+
sub_matchers[:arguments] = sub_matcher
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# @api private
|
145
|
+
#
|
146
|
+
# @param sub_matcher [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::ReturnValue]
|
147
|
+
#
|
148
|
+
def return_value=(sub_matcher)
|
149
|
+
sub_matchers[:return_value] = sub_matcher
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module PrimitiveMatchers
|
6
|
+
module Classes
|
7
|
+
class DelegateTo
|
8
|
+
module Entities
|
9
|
+
module SubMatchers
|
10
|
+
class Arguments < SubMatchers::Base
|
11
|
+
module Commands
|
12
|
+
class ApplyStubToTrackDelegations < Support::Command
|
13
|
+
##
|
14
|
+
# @internal
|
15
|
+
# NOTE: `include ::RSpec::Mocks::ExampleMethods`.
|
16
|
+
# - https://github.com/rspec/rspec-mocks/blob/v3.11.1/lib/rspec/mocks/example_methods.rb
|
17
|
+
# - https://github.com/rspec/rspec-mocks/blob/main/lib/rspec/mocks/example_methods.rb
|
18
|
+
#
|
19
|
+
include ::RSpec::Mocks::ExampleMethods
|
20
|
+
|
21
|
+
##
|
22
|
+
# @return [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo]
|
23
|
+
#
|
24
|
+
attr_reader :matcher
|
25
|
+
|
26
|
+
##
|
27
|
+
# @param matcher [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo]
|
28
|
+
# @return [void]
|
29
|
+
#
|
30
|
+
def initialize(matcher:)
|
31
|
+
@matcher = matcher
|
32
|
+
end
|
33
|
+
|
34
|
+
def call
|
35
|
+
##
|
36
|
+
# NOTE: RSpec `allow(object).to receive(method).with(*args, **kwargs)` does NOT support block.
|
37
|
+
# https://github.com/rspec/rspec-mocks/issues/1182#issuecomment-679820352
|
38
|
+
#
|
39
|
+
# NOTE: RSpec `allow(object).to receive(method) do` does NOT support `and_call_original`.
|
40
|
+
# https://github.com/rspec/rspec-mocks/issues/774#issuecomment-54245277
|
41
|
+
#
|
42
|
+
# NOTE: That is why `and_wrap_original` is used.
|
43
|
+
# https://relishapp.com/rspec/rspec-mocks/docs/configuring-responses/wrapping-the-original-implementation
|
44
|
+
#
|
45
|
+
# TODO: Check whether `matcher.object.frozen?` in order to show more explanatory exception instead of the following (provide an example of how to avoid it in the exception message):
|
46
|
+
# ArgumentError:
|
47
|
+
# Cannot proxy frozen objects, rspec-mocks relies on proxies for method stubbing and expectations
|
48
|
+
#
|
49
|
+
allow(matcher.inputs.object).to receive(matcher.inputs.method).and_wrap_original do |original, *actual_args, **actual_kwargs, &actual_block|
|
50
|
+
##
|
51
|
+
# TODO: Add backtrace for easier reason tracing.
|
52
|
+
#
|
53
|
+
matcher.outputs.delegations << Entities::Delegation.new(
|
54
|
+
object: matcher.inputs.object,
|
55
|
+
method: matcher.inputs.method,
|
56
|
+
args: actual_args,
|
57
|
+
kwargs: actual_kwargs,
|
58
|
+
block: actual_block
|
59
|
+
)
|
60
|
+
|
61
|
+
##
|
62
|
+
# NOTE: Imitates `and_call_original`.
|
63
|
+
# TODO: What to do when `original.call` raises an exception?
|
64
|
+
#
|
65
|
+
original.call(*actual_args, **actual_kwargs, &actual_block) if matcher.inputs.should_call_original?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConvenientService
|
4
|
+
module RSpec
|
5
|
+
module PrimitiveMatchers
|
6
|
+
module Classes
|
7
|
+
class DelegateTo
|
8
|
+
module Entities
|
9
|
+
module SubMatchers
|
10
|
+
class Arguments < SubMatchers::Base
|
11
|
+
module Commands
|
12
|
+
class GeneratePrintableArguments < Support::Command
|
13
|
+
include Support::Delegate
|
14
|
+
|
15
|
+
##
|
16
|
+
# @!attribute [r] arguments
|
17
|
+
# @return [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::Arguments]
|
18
|
+
#
|
19
|
+
attr_reader :arguments
|
20
|
+
|
21
|
+
##
|
22
|
+
# @return [Array]
|
23
|
+
#
|
24
|
+
delegate :args, to: :arguments
|
25
|
+
|
26
|
+
##
|
27
|
+
# @return [Hash]
|
28
|
+
#
|
29
|
+
delegate :kwargs, to: :arguments
|
30
|
+
|
31
|
+
##
|
32
|
+
# @return [Proc]
|
33
|
+
#
|
34
|
+
delegate :block, to: :arguments
|
35
|
+
|
36
|
+
##
|
37
|
+
# @param arguments [ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::Arguments]
|
38
|
+
#
|
39
|
+
def initialize(arguments:)
|
40
|
+
@arguments = arguments
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# @return [String]
|
45
|
+
#
|
46
|
+
def call
|
47
|
+
return "" if arguments.null_arguments?
|
48
|
+
|
49
|
+
text =
|
50
|
+
if args.any? && kwargs.any?
|
51
|
+
"(#{printable_args}, #{printable_kwargs})"
|
52
|
+
elsif args.any?
|
53
|
+
"(#{printable_args})"
|
54
|
+
elsif kwargs.any?
|
55
|
+
"(#{printable_kwargs})"
|
56
|
+
else
|
57
|
+
"()"
|
58
|
+
end
|
59
|
+
|
60
|
+
text += " #{printable_block}" if block
|
61
|
+
|
62
|
+
text
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# @return [String]
|
67
|
+
#
|
68
|
+
def printable_args
|
69
|
+
args.map(&:inspect).join(", ")
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# @return [String]
|
74
|
+
#
|
75
|
+
def printable_kwargs
|
76
|
+
kwargs.map { |key, value| "#{key}: #{value.inspect}" }.join(", ")
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# @return [String]
|
81
|
+
#
|
82
|
+
def printable_block
|
83
|
+
block ? Utils::Proc.display(block) : ""
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "arguments/commands"
|
4
|
+
|
5
|
+
module ConvenientService
|
6
|
+
module RSpec
|
7
|
+
module PrimitiveMatchers
|
8
|
+
module Classes
|
9
|
+
class DelegateTo
|
10
|
+
module Entities
|
11
|
+
module SubMatchers
|
12
|
+
class Arguments < SubMatchers::Base
|
13
|
+
##
|
14
|
+
# @return [void]
|
15
|
+
#
|
16
|
+
def apply_stubs!
|
17
|
+
Commands::ApplyStubToTrackDelegations.call(matcher: matcher)
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# @param block_expectation_value [Object]
|
22
|
+
# @return [Boolean]
|
23
|
+
#
|
24
|
+
def matches?(block_expectation_value)
|
25
|
+
super
|
26
|
+
|
27
|
+
outputs.delegations.any? { |delegation| matches_arguments?(delegation.arguments) }
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# @return [String]
|
32
|
+
#
|
33
|
+
# @internal
|
34
|
+
# TODO: Prettier message.
|
35
|
+
#
|
36
|
+
def failure_message
|
37
|
+
<<~MESSAGE.chomp
|
38
|
+
#{failure_message_expected_part}
|
39
|
+
|
40
|
+
#{failure_message_got_part}
|
41
|
+
MESSAGE
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# @return [String]
|
46
|
+
#
|
47
|
+
def failure_message_when_negated
|
48
|
+
"expected `#{inputs.printable_block_expectation}` NOT to delegate to `#{inputs.printable_method}` #{printable_expected_arguments} at least once, but it did."
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# @return [String]
|
53
|
+
#
|
54
|
+
def printable_actual_arguments
|
55
|
+
return "" if outputs.delegations.none?
|
56
|
+
|
57
|
+
outputs.delegations
|
58
|
+
.map { |delegation| Commands::GeneratePrintableArguments.call(arguments: delegation.arguments) }
|
59
|
+
.join(", ")
|
60
|
+
.prepend("with ")
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def failure_message_expected_part
|
66
|
+
"expected `#{inputs.printable_block_expectation}` to delegate to `#{inputs.printable_method}` #{printable_expected_arguments} at least once, but it didn't."
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# @return [String]
|
71
|
+
#
|
72
|
+
# @internal
|
73
|
+
# TODO: String diff.
|
74
|
+
#
|
75
|
+
def failure_message_got_part
|
76
|
+
if outputs.delegations.any?
|
77
|
+
"got delegated #{printable_actual_arguments}"
|
78
|
+
else
|
79
|
+
"got not delegated at all"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|