foobara 0.5.10 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +22 -0
- data/lib/foobara/all.rb +4 -2
- data/projects/command/src/command_pattern_implementation/concerns/command_data.rb +3 -3
- data/projects/command/src/command_pattern_implementation/concerns/domain_mappers.rb +2 -2
- data/projects/command/src/command_pattern_implementation/concerns/errors.rb +27 -27
- data/projects/command/src/command_pattern_implementation/concerns/errors_type.rb +7 -11
- data/projects/command/src/command_pattern_implementation/concerns/inputs.rb +4 -24
- data/projects/command/src/command_pattern_implementation/concerns/inputs_type.rb +9 -14
- data/projects/command/src/command_pattern_implementation/concerns/reflection.rb +7 -20
- data/projects/command/src/command_pattern_implementation/concerns/runtime.rb +3 -48
- data/projects/command/src/command_pattern_implementation/concerns/subcommands.rb +5 -5
- data/projects/command/src/command_pattern_implementation.rb +0 -1
- data/projects/command_connectors/lib/foobara/command_connectors.rb +1 -1
- data/projects/command_connectors/src/command_connector/concerns/desugarizers.rb +5 -5
- data/projects/command_connectors/src/command_connector/concerns/reflection.rb +63 -17
- data/projects/command_connectors/src/command_connector/request.rb +26 -10
- data/projects/command_connectors/src/command_connector/response.rb +2 -0
- data/projects/command_connectors/src/command_connector.rb +62 -58
- data/projects/command_connectors/src/command_registry/exposed_command.rb +7 -2
- data/projects/command_connectors/src/command_registry.rb +24 -18
- data/projects/command_connectors/src/desugarizer.rb +2 -2
- data/projects/command_connectors/src/desugarizers/attributes.rb +8 -8
- data/projects/command_connectors/src/desugarizers/auth.rb +1 -1
- data/projects/command_connectors/src/desugarizers/set_inputs.rb +3 -3
- data/projects/command_connectors/src/desugarizers/symbols_to_true.rb +2 -2
- data/projects/command_connectors/src/request_mutator.rb +6 -6
- data/projects/command_connectors/src/response_mutator.rb +6 -6
- data/projects/command_connectors/src/transformed_command.rb +39 -36
- data/projects/command_connectors/src/transformers/auth_errors_transformer.rb +2 -2
- data/projects/command_connectors/src/transformers/entity_to_primary_key_inputs_transformer.rb +2 -2
- data/projects/command_connectors/src/transformers/load_delegated_attributes_entities_pre_commit_transformer.rb +1 -1
- data/projects/domain_mapper/src/domain_mapper.rb +4 -4
- data/projects/domain_mapper/src/domain_mapper_lookups.rb +3 -3
- data/projects/entities/projects/detached_entity/lib/foobara/detached_entity.rb +1 -1
- data/projects/entities/projects/detached_entity/src/concerns/associations.rb +18 -18
- data/projects/entities/projects/detached_entity/src/concerns/initialization.rb +2 -2
- data/projects/entities/projects/detached_entity/src/concerns/primary_key.rb +4 -4
- data/projects/entities/projects/detached_entity/src/concerns/types.rb +2 -2
- data/projects/entities/projects/detached_entity/src/detached_entity_type.rb +4 -4
- data/projects/entities/projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/primary_key.rb +1 -1
- data/projects/entities/projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/model_instance_is_valid.rb +2 -2
- data/projects/entities/projects/detached_entity/src/extensions/type_declarations/handlers/registered_type_declaration/validate_primary_key_present.rb +30 -0
- data/projects/entities/projects/detached_entity/src/remove_sensitive_values_transformer_extensions.rb +2 -2
- data/projects/entities/projects/entity/lib/foobara/entity.rb +1 -1
- data/projects/entities/projects/entity/src/concerns/attributes.rb +6 -6
- data/projects/entities/projects/entity/src/concerns/callbacks.rb +1 -1
- data/projects/entities/projects/entity/src/concerns/initialization.rb +8 -8
- data/projects/entities/projects/entity/src/concerns/mutations.rb +4 -4
- data/projects/entities/projects/entity/src/concerns/persistence.rb +3 -3
- data/projects/entities/projects/entity/src/concerns/queries.rb +7 -7
- data/projects/entities/projects/entity/src/extensions/domain/domain_module_extension.rb +4 -4
- data/projects/entities/projects/entity/src/new_prepend.rb +2 -2
- data/projects/entities/projects/entity/src/not_found_error.rb +8 -8
- data/projects/entities/projects/entity/src/sensitive_value_removers/entity.rb +8 -5
- data/projects/entities/projects/in_memory_crud_driver_minimal/src/in_memory_minimal.rb +4 -4
- data/projects/entities/projects/model_attribute_helpers/lib/foobara/model_attribute_helpers.rb +0 -2
- data/projects/entities/projects/model_attribute_helpers/src/attribute_helper_aliases.rb +1 -1
- data/projects/entities/projects/model_attribute_helpers/src/attribute_helpers.rb +2 -2
- data/projects/entities/projects/nested_transactionable/lib/foobara/nested_transactionable.rb +5 -5
- data/projects/entities/projects/persistence/lib/foobara/persistence.rb +1 -1
- data/projects/entities/projects/persistence/src/entity_attributes_crud_driver.rb +35 -37
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/entity_callback_handling.rb +25 -25
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/state_transitions.rb +8 -8
- data/projects/entities/projects/persistence/src/entity_base/transaction/concerns/transaction_tracking.rb +1 -1
- data/projects/entities/projects/persistence/src/entity_base/transaction.rb +9 -9
- data/projects/entities/projects/persistence/src/entity_base/transaction_table/concerns/record_tracking.rb +4 -4
- data/projects/entities/projects/persistence/src/entity_base/transaction_table.rb +52 -52
- data/projects/entities/projects/persistence/src/entity_base.rb +7 -7
- data/projects/entities/projects/persistence/src/persistence.rb +23 -23
- data/projects/entities/projects/weak_object_set/src/weak_object_set.rb +16 -16
- data/projects/entities_plumbing/lib/foobara/entities_plumbing.rb +6 -2
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entities.rb +21 -5
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_errors_type.rb +23 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_inputs.rb +33 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/entity_reflection.rb +39 -0
- data/projects/entities_plumbing/src/extensions/command_pattern_implementation/concerns/runtime.rb +39 -0
- data/projects/manifest/src/base_manifest.rb +9 -9
- data/projects/manifest/src/model.rb +4 -4
- data/projects/manifest/src/type.rb +3 -3
- data/projects/manifest/src/type_declaration.rb +4 -4
- data/projects/model_plumbing/lib/foobara/model_plumbing.rb +2 -0
- data/projects/model_plumbing/src/extensions/command_pattern_implementation/concerns/model_inputs_type.rb +35 -0
- data/projects/typesystem/projects/builtin_types/lib/foobara/builtin_types.rb +2 -1
- data/projects/typesystem/projects/builtin_types/src/builtin_types.rb +8 -8
- data/projects/typesystem/projects/builtin_types/src/duck/supported_validators/one_of/type_declaration_extension/extend_registered_type_declaration/desugarizers/module_desugarizer.rb +2 -2
- data/projects/typesystem/projects/builtin_types/src/email/validator_base.rb +4 -4
- data/projects/typesystem/projects/callback/src/block/concerns/block_parameter_required.rb +2 -2
- data/projects/typesystem/projects/callback/src/block/concerns/keyword_argumentable_block.rb +2 -2
- data/projects/typesystem/projects/callback/src/block/concerns/single_argument_block.rb +2 -2
- data/projects/typesystem/projects/callback/src/block.rb +4 -4
- data/projects/typesystem/projects/callback/src/registry/base.rb +10 -10
- data/projects/typesystem/projects/callback/src/registry/conditioned.rb +2 -2
- data/projects/typesystem/projects/callback/src/registry/multiple_action.rb +6 -6
- data/projects/typesystem/projects/callback/src/runner.rb +4 -4
- data/projects/typesystem/projects/callback/src/set.rb +4 -4
- data/projects/typesystem/projects/common/src/data_path.rb +14 -14
- data/projects/typesystem/projects/common/src/error.rb +11 -11
- data/projects/typesystem/projects/common/src/error_collection.rb +14 -14
- data/projects/typesystem/projects/common/src/error_key.rb +5 -3
- data/projects/typesystem/projects/common/src/outcome.rb +5 -5
- data/projects/typesystem/projects/common/src/possible_error.rb +2 -2
- data/projects/typesystem/projects/concerns/src/concern.rb +3 -3
- data/projects/typesystem/projects/delegate/src/extensions/module.rb +4 -4
- data/projects/typesystem/projects/domain/lib/foobara/domain.rb +2 -2
- data/projects/typesystem/projects/domain/src/domain.rb +5 -5
- data/projects/typesystem/projects/domain/src/domain_module_extension.rb +22 -22
- data/projects/typesystem/projects/domain/src/extensions/foobara.rb +14 -6
- data/projects/typesystem/projects/domain/src/module_extension.rb +4 -4
- data/projects/typesystem/projects/domain/src/organization.rb +6 -6
- data/projects/typesystem/projects/enumerated/src/accessors.rb +4 -4
- data/projects/typesystem/projects/enumerated/src/values.rb +14 -14
- data/projects/{entities → typesystem}/projects/model/lib/foobara/model.rb +1 -1
- data/projects/{entities → typesystem}/projects/model/src/concerns/classes.rb +4 -4
- data/projects/{entities → typesystem}/projects/model/src/concerns/types.rb +5 -5
- data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/casters/hash.rb +1 -1
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/attributes_handler_desugarizer.rb +2 -2
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb +6 -6
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/to_type_transformer.rb +4 -4
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration.rb +2 -2
- data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/registered_type_declaration/model_class_desugarizer.rb +6 -10
- data/projects/{entities → typesystem}/projects/model/src/model.rb +13 -13
- data/projects/{entities → typesystem}/projects/model/src/sensitive_value_removers/model.rb +1 -1
- data/projects/typesystem/projects/namespace/src/ambiguous_registry.rb +5 -5
- data/projects/typesystem/projects/namespace/src/base_registry.rb +8 -8
- data/projects/typesystem/projects/namespace/src/is_namespace.rb +19 -19
- data/projects/typesystem/projects/namespace/src/namespace/lookup_mode.rb +2 -2
- data/projects/typesystem/projects/namespace/src/namespace.rb +5 -5
- data/projects/typesystem/projects/namespace/src/namespace_helpers.rb +4 -4
- data/projects/typesystem/projects/namespace/src/prefixless_registry.rb +3 -3
- data/projects/typesystem/projects/namespace/src/scoped.rb +7 -7
- data/projects/typesystem/projects/project/src/foobara.rb +13 -7
- data/projects/typesystem/projects/project/src/project.rb +1 -1
- data/projects/typesystem/projects/state_machine/src/callbacks.rb +14 -14
- data/projects/typesystem/projects/state_machine/src/state_machine.rb +2 -2
- data/projects/typesystem/projects/state_machine/src/sugar.rb +3 -3
- data/projects/typesystem/projects/type_declarations/lib/foobara/type_declarations.rb +1 -1
- data/projects/typesystem/projects/type_declarations/src/attributes.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/from_yaml.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/only.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/reject.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/attributes_transformers/set.rb +4 -4
- data/projects/typesystem/projects/type_declarations/src/desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/dsl/attributes.rb +9 -9
- data/projects/typesystem/projects/type_declarations/src/error_extension.rb +6 -6
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/array_desugarizer.rb +3 -3
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/element_type_declaration_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_attributes_type_declaration/element_type_declarations_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_registered_type_declaration.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/extend_tuple_type_declaration/array_desugarizer.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/handlers/registered_type_declaration.rb +4 -3
- data/projects/typesystem/projects/type_declarations/src/remove_sensitive_values_transformer.rb +3 -3
- data/projects/typesystem/projects/type_declarations/src/type_builder.rb +5 -5
- data/projects/typesystem/projects/type_declarations/src/type_declaration.rb +7 -1
- data/projects/typesystem/projects/type_declarations/src/type_declaration_handler.rb +13 -13
- data/projects/typesystem/projects/type_declarations/src/type_declaration_handler_registry.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/type_declaration_validator.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/type_declarations.rb +2 -2
- data/projects/typesystem/projects/type_declarations/src/with_registries.rb +2 -2
- data/projects/typesystem/projects/types/lib/foobara/types.rb +0 -2
- data/projects/typesystem/projects/types/src/extensions/error.rb +5 -5
- data/projects/typesystem/projects/types/src/type/concerns/reflection.rb +22 -22
- data/projects/typesystem/projects/types/src/type/concerns/supported_processor_registration.rb +4 -4
- data/projects/typesystem/projects/types/src/type.rb +25 -25
- data/projects/typesystem/projects/value/src/caster.rb +11 -11
- data/projects/typesystem/projects/value/src/data_error.rb +1 -1
- data/projects/typesystem/projects/value/src/mutator.rb +3 -3
- data/projects/typesystem/projects/value/src/processor/casting.rb +6 -6
- data/projects/typesystem/projects/value/src/processor/pipeline.rb +2 -2
- data/projects/typesystem/projects/value/src/processor/runner.rb +1 -1
- data/projects/typesystem/projects/value/src/processor/selection.rb +3 -3
- data/projects/typesystem/projects/value/src/processor.rb +23 -23
- data/projects/typesystem/projects/value/src/transformer.rb +5 -5
- data/projects/typesystem/projects/value/src/validator.rb +3 -3
- data/version.rb +2 -2
- metadata +44 -160
- data/projects/command_connectors/Guardfile +0 -6
- data/projects/command_connectors/spec/allowed_rules_spec.rb +0 -77
- data/projects/command_connectors/spec/ambiguous_lookups_spec.rb +0 -143
- data/projects/command_connectors/spec/auth_mappers_spec.rb +0 -201
- data/projects/command_connectors/spec/command_connector_spec.rb +0 -2460
- data/projects/command_connectors/spec/command_registry_spec.rb +0 -9
- data/projects/command_connectors/spec/commands/describe_spec.rb +0 -83
- data/projects/command_connectors/spec/commands/ping_spec.rb +0 -14
- data/projects/command_connectors/spec/commands/query_git_commit_info_spec.rb +0 -55
- data/projects/command_connectors/spec/fixtures/command_connectors/manifest_with_errors_with_missing_command_parents.yaml +0 -1662
- data/projects/command_connectors/spec/not_found_error_spec.rb +0 -17
- data/projects/command_connectors/spec/pre_commit_transformers/load_atoms_pre_commit_transformer_spec.rb +0 -108
- data/projects/command_connectors/spec/request_spec.rb +0 -118
- data/projects/command_connectors/spec/serializer_spec.rb +0 -9
- data/projects/command_connectors/spec/serializers/aggregate_serializer_spec.rb +0 -45
- data/projects/command_connectors/spec/serializers/atomic_serializer_spec.rb +0 -68
- data/projects/command_connectors/spec/serializers/entities_to_primary_keys_serializer_spec.rb +0 -36
- data/projects/command_connectors/spec/serializers/json_serializer_spec.rb +0 -22
- data/projects/command_connectors/spec/serializers/noop_serializer_spec.rb +0 -22
- data/projects/command_connectors/spec/serializers/yaml_serializer_spec.rb +0 -22
- data/projects/command_connectors/spec/spec_helper.rb +0 -56
- data/projects/command_connectors/spec/support/rubyprof.rb +0 -32
- data/projects/command_connectors/spec/support/term_trap.rb +0 -6
- data/projects/command_connectors/spec/transformers/entity_to_primary_key_inputs_transformer_spec.rb +0 -119
- data/projects/entities/Guardfile +0 -6
- data/projects/entities/spec/builtin_types/detached_entity_spec.rb +0 -300
- data/projects/entities/spec/builtin_types/entity_spec.rb +0 -501
- data/projects/entities/spec/builtin_types/model_spec.rb +0 -420
- data/projects/entities/spec/detached_entity/casting_spec.rb +0 -31
- data/projects/entities/spec/entity/concerns/associations_spec.rb +0 -73
- data/projects/entities/spec/entity/concerns/attribute_helpers_spec.rb +0 -220
- data/projects/entities/spec/entity/concerns/callbacks_spec.rb +0 -61
- data/projects/entities/spec/entity/concerns/initialization_spec.rb +0 -213
- data/projects/entities/spec/entity/concerns/mutations_spec.rb +0 -38
- data/projects/entities/spec/entity/concerns/queries_spec.rb +0 -184
- data/projects/entities/spec/entity/entity_spec.rb +0 -240
- data/projects/entities/spec/entity/extending_existing_spec.rb +0 -137
- data/projects/entities/spec/entity/extensions/domain_module_extension_spec.rb +0 -42
- data/projects/entities/spec/entity/from_type_declaration_spec.rb +0 -34
- data/projects/entities/spec/entity/that_owns_spec.rb +0 -243
- data/projects/entities/spec/entity/weak_object_set_spec.rb +0 -91
- data/projects/entities/spec/model/model_spec.rb +0 -135
- data/projects/entities/spec/model/types_spec.rb +0 -397
- data/projects/entities/spec/nested_transactionable/nested_transactionable_spec.rb +0 -67
- data/projects/entities/spec/persistence/entity_attributes_crud_drivers/in_memory_minimal_spec.rb +0 -13
- data/projects/entities/spec/persistence/entity_base/transaction_spec.rb +0 -509
- data/projects/entities/spec/persistence/entity_base/transaction_table_spec.rb +0 -58
- data/projects/entities/spec/persistence/persistence_spec.rb +0 -148
- data/projects/entities/spec/spec_helper.rb +0 -54
- data/projects/entities/spec/support/rubyprof.rb +0 -32
- data/projects/entities/spec/support/term_trap.rb +0 -6
- data/projects/entities/spec/type_declarations/sensitive_type_removers_spec.rb +0 -90
- data/projects/entities_plumbing/Guardfile +0 -6
- data/projects/entities_plumbing/spec/auth_mappers_spec.rb +0 -159
- data/projects/entities_plumbing/spec/spec_helper.rb +0 -55
- data/projects/entities_plumbing/spec/support/rubyprof.rb +0 -32
- data/projects/entities_plumbing/spec/support/term_trap.rb +0 -6
- data/projects/entities_plumbing/spec/transaction_spec.rb +0 -534
- data/projects/manifest/Guardfile +0 -6
- data/projects/manifest/spec/associations_spec.rb +0 -67
- data/projects/manifest/spec/manifest_spec.rb +0 -382
- data/projects/manifest/spec/model_spec.rb +0 -126
- data/projects/manifest/spec/spec_helper.rb +0 -54
- data/projects/manifest/spec/type_declaration_spec.rb +0 -39
- data/projects/manifest/spec/type_spec.rb +0 -30
- data/projects/typesystem/spec/builtin_types/allow_nil_spec.rb +0 -138
- data/projects/typesystem/spec/builtin_types/array_spec.rb +0 -140
- data/projects/typesystem/spec/builtin_types/associative_array_spec.rb +0 -228
- data/projects/typesystem/spec/builtin_types/attributes_spec.rb +0 -490
- data/projects/typesystem/spec/builtin_types/big_decimal_spec.rb +0 -42
- data/projects/typesystem/spec/builtin_types/boolean_spec.rb +0 -43
- data/projects/typesystem/spec/builtin_types/class_type_desugarizer_spec.rb +0 -17
- data/projects/typesystem/spec/builtin_types/custom_type_spec.rb +0 -430
- data/projects/typesystem/spec/builtin_types/date_spec.rb +0 -37
- data/projects/typesystem/spec/builtin_types/datetime_spec.rb +0 -49
- data/projects/typesystem/spec/builtin_types/email_spec.rb +0 -44
- data/projects/typesystem/spec/builtin_types/float_spec.rb +0 -59
- data/projects/typesystem/spec/builtin_types/instance_of_spec.rb +0 -75
- data/projects/typesystem/spec/builtin_types/one_of_spec.rb +0 -73
- data/projects/typesystem/spec/builtin_types/string_spec.rb +0 -117
- data/projects/typesystem/spec/builtin_types/symbol_spec.rb +0 -24
- data/projects/typesystem/spec/builtin_types/tuple_spec.rb +0 -125
- data/projects/typesystem/spec/callback/callback_spec.rb +0 -155
- data/projects/typesystem/spec/callback/registry/conditioned_spec.rb +0 -152
- data/projects/typesystem/spec/callback/registry/multiple_action_spec.rb +0 -144
- data/projects/typesystem/spec/callback/registry/single_action_spec.rb +0 -114
- data/projects/typesystem/spec/common/data_path_spec.rb +0 -268
- data/projects/typesystem/spec/common/error_collection_spec.rb +0 -77
- data/projects/typesystem/spec/common/error_key_spec.rb +0 -56
- data/projects/typesystem/spec/common/outcome_spec.rb +0 -65
- data/projects/typesystem/spec/common/possible_error_spec.rb +0 -17
- data/projects/typesystem/spec/concerns/concern_spec.rb +0 -122
- data/projects/typesystem/spec/enumerated/accessors_spec.rb +0 -182
- data/projects/typesystem/spec/enumerated/enumerated_spec.rb +0 -32
- data/projects/typesystem/spec/enumerated/values_spec.rb +0 -67
- data/projects/typesystem/spec/foobara/foobara_spec.rb +0 -45
- data/projects/typesystem/spec/namespace/ambiguous_registry_spec.rb +0 -70
- data/projects/typesystem/spec/namespace/foobara_simulation_spec.rb +0 -254
- data/projects/typesystem/spec/namespace/is_namespace_spec.rb +0 -103
- data/projects/typesystem/spec/namespace/namespace_helpers_spec.rb +0 -67
- data/projects/typesystem/spec/namespace/namespace_spec.rb +0 -335
- data/projects/typesystem/spec/namespace/prefixless_registry_spec.rb +0 -30
- data/projects/typesystem/spec/namespace/unambiguous_registry_spec.rb +0 -50
- data/projects/typesystem/spec/spec_helper.rb +0 -52
- data/projects/typesystem/spec/state_machine/callbacks_spec.rb +0 -144
- data/projects/typesystem/spec/state_machine/state_machine_spec.rb +0 -224
- data/projects/typesystem/spec/state_machine/target_attribute_spec.rb +0 -46
- data/projects/typesystem/spec/support/rubyprof.rb +0 -32
- data/projects/typesystem/spec/support/term_trap.rb +0 -6
- data/projects/typesystem/spec/type_declarations/attributes_spec.rb +0 -14
- data/projects/typesystem/spec/type_declarations/attributes_transformer_spec.rb +0 -95
- data/projects/typesystem/spec/type_declarations/dsl/attributes_spec.rb +0 -107
- data/projects/typesystem/spec/type_declarations/handlers/extend_registered_type_declaration_spec.rb +0 -13
- data/projects/typesystem/spec/type_declarations/sensitive_type_removers_spec.rb +0 -210
- data/projects/typesystem/spec/type_declarations/type_builder_spec.rb +0 -47
- data/projects/typesystem/spec/type_declarations/type_declaration_spec.rb +0 -252
- data/projects/typesystem/spec/type_declarations/type_declarations_spec.rb +0 -11
- data/projects/typesystem/spec/type_declarations/typed_transformer_spec.rb +0 -65
- data/projects/typesystem/spec/types/sensitive_spec.rb +0 -36
- data/projects/typesystem/spec/types/type_spec.rb +0 -102
- data/projects/typesystem/spec/value/caster_spec.rb +0 -23
- data/projects/typesystem/spec/value/processor/runner_spec.rb +0 -34
- data/projects/typesystem/spec/value/processor/selection_spec.rb +0 -71
- data/projects/typesystem/spec/value/processor_spec.rb +0 -76
- data/projects/typesystem/spec/value/transformer_spec.rb +0 -27
- /data/projects/{command/src → entities_plumbing/src/extensions}/command_pattern_implementation/concerns/transactions.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/concerns/aliases.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/concerns/reflection.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/supported_transformers/mutable.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/builtin_types/model/validators/model_instance_is_valid.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/array_with_symbolic_elements.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_validator.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/hash_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/move_private_from_element_types_to_root.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/symbolize_private.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/valid_attribute_names.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/hash_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/model_class_type_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/mutable_validator.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/to_type_transformer.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/extensions/type_declarations/lazy_element_types/model.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/sensitive_type_removers/extended_model.rb +0 -0
- /data/projects/{entities → typesystem}/projects/model/src/sensitive_type_removers/model.rb +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::BuiltinTypes::Duck::SupportedValidators::OneOf do
|
|
2
|
-
let(:type_declaration) { [:integer, { one_of: }] }
|
|
3
|
-
let(:one_of) { [1, 3, 5] }
|
|
4
|
-
|
|
5
|
-
let(:type) do
|
|
6
|
-
Foobara::GlobalDomain.foobara_type_from_declaration(*Foobara::Util.array(type_declaration))
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
context "when valid" do
|
|
10
|
-
it "works as usual" do
|
|
11
|
-
expect(type.process_value!(5)).to be(5)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context "when allow_nil" do
|
|
16
|
-
let(:type_declaration) { [:integer, :allow_nil, { one_of: }] }
|
|
17
|
-
|
|
18
|
-
it "can be nil" do
|
|
19
|
-
expect(type.process_value!(nil)).to be_nil
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context "when not valid" do
|
|
24
|
-
it "is not success" do
|
|
25
|
-
outcome = type.process_value(2)
|
|
26
|
-
|
|
27
|
-
expect(outcome).to_not be_success
|
|
28
|
-
|
|
29
|
-
expect(outcome.errors_hash).to eq(
|
|
30
|
-
"data.value_not_valid" => {
|
|
31
|
-
key: "data.value_not_valid",
|
|
32
|
-
path: [],
|
|
33
|
-
runtime_path: [],
|
|
34
|
-
category: :data,
|
|
35
|
-
symbol: :value_not_valid,
|
|
36
|
-
message: "2 is not one of [1, 3, 5]",
|
|
37
|
-
context: { value: 2, valid_values: [1, 3, 5] },
|
|
38
|
-
is_fatal: false
|
|
39
|
-
}
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context "when module" do
|
|
45
|
-
let(:type_declaration) { [:string, { one_of: }] }
|
|
46
|
-
let(:one_of) do
|
|
47
|
-
stub_module "SomeEnum" do
|
|
48
|
-
const_set(:FOO, :foo)
|
|
49
|
-
const_set(:BAR, :bar)
|
|
50
|
-
const_set(:BAZ, :baz)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "works with expected value" do
|
|
55
|
-
expect(type.process_value!(:foo)).to eq("foo")
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
context "when not valid" do
|
|
59
|
-
it "is not success" do
|
|
60
|
-
expect(type.declaration_data[:one_of]).to contain_exactly("foo", "bar", "baz")
|
|
61
|
-
|
|
62
|
-
outcome = type.process_value(:not_valid)
|
|
63
|
-
|
|
64
|
-
expect(outcome).to_not be_success
|
|
65
|
-
|
|
66
|
-
expect(outcome.errors.size).to eq(1)
|
|
67
|
-
|
|
68
|
-
expect(outcome.errors_hash["data.value_not_valid"][:context][:valid_values]).to contain_exactly("baz", "foo",
|
|
69
|
-
"bar")
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":string" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:string] }
|
|
3
|
-
|
|
4
|
-
describe "#process!" do
|
|
5
|
-
subject { type.process_value!(value) }
|
|
6
|
-
|
|
7
|
-
context "when string" do
|
|
8
|
-
let(:value) { "foo" }
|
|
9
|
-
|
|
10
|
-
it { is_expected.to eq("foo") }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when symbol" do
|
|
14
|
-
let(:value) { :foo }
|
|
15
|
-
|
|
16
|
-
it { is_expected.to eq("foo") }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "when not castable" do
|
|
20
|
-
let(:value) { Object.new }
|
|
21
|
-
|
|
22
|
-
it {
|
|
23
|
-
is_expected_to_raise(
|
|
24
|
-
Foobara::Value::Processor::Casting::CannotCastError,
|
|
25
|
-
/Expected it to be a String, be a Numeric, or be a Symbol\z/
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "with transformers" do
|
|
31
|
-
let(:type) do
|
|
32
|
-
Foobara::Domain.current.foobara_type_from_declaration(:string, :downcase)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "when uppercase" do
|
|
36
|
-
let(:value) { "FooBar" }
|
|
37
|
-
|
|
38
|
-
it { is_expected.to eq("foobar") }
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context "with transformers and empty processor data" do
|
|
43
|
-
let(:type) do
|
|
44
|
-
Foobara::Domain.current.foobara_type_from_declaration(:string, :downcase, {})
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
context "when uppercase" do
|
|
48
|
-
let(:value) { "FooBar" }
|
|
49
|
-
|
|
50
|
-
it { is_expected.to eq("foobar") }
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context "with validators" do
|
|
55
|
-
let(:type) do
|
|
56
|
-
Foobara::Domain.current.foobara_type_from_declaration(:string, max_length: 10)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
context "when too long" do
|
|
60
|
-
let(:value) { "Foo Bar Baz" }
|
|
61
|
-
|
|
62
|
-
it {
|
|
63
|
-
is_expected_to_raise(
|
|
64
|
-
Foobara::BuiltinTypes::String::SupportedValidators::MaxLength::MaxLengthExceededError,
|
|
65
|
-
/\b10\b/
|
|
66
|
-
) { |error| expect(error.context[:max_length]).to eq(10) }
|
|
67
|
-
}
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
context "with :matches validator" do
|
|
72
|
-
let(:type) do
|
|
73
|
-
Foobara::Domain.current.foobara_type_from_declaration(:string, matches: /bar/i)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
context "when matches" do
|
|
77
|
-
let(:value) { "Foo Bar" }
|
|
78
|
-
|
|
79
|
-
it { is_expected.to eq(value) }
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
context "when does not match" do
|
|
83
|
-
let(:value) { "Foo Baz" }
|
|
84
|
-
|
|
85
|
-
it {
|
|
86
|
-
is_expected_to_raise(
|
|
87
|
-
Foobara::BuiltinTypes::String::SupportedValidators::Matches::DoesNotMatchError,
|
|
88
|
-
/\/bar\/i\b/
|
|
89
|
-
) { |error| expect(error.context[:regex]).to eq(/bar/i.to_s) } # TODO: eliminate this .to_s call
|
|
90
|
-
}
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context "with validators and transformers" do
|
|
95
|
-
let(:type) do
|
|
96
|
-
Foobara::Domain.current.foobara_type_from_declaration(:string, :downcase, max_length: 10)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
context "when uppercase" do
|
|
100
|
-
let(:value) { "FooBar" }
|
|
101
|
-
|
|
102
|
-
it { is_expected.to eq("foobar") }
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
context "when too long" do
|
|
106
|
-
let(:value) { "Foo Bar Baz" }
|
|
107
|
-
|
|
108
|
-
it {
|
|
109
|
-
is_expected_to_raise(
|
|
110
|
-
Foobara::BuiltinTypes::String::SupportedValidators::MaxLength::MaxLengthExceededError,
|
|
111
|
-
/\b10\b/
|
|
112
|
-
) { |error| expect(error.context[:max_length]).to eq(10) }
|
|
113
|
-
}
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":symbol" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:symbol] }
|
|
3
|
-
|
|
4
|
-
describe "#process!" do
|
|
5
|
-
subject { type.process_value!(value) }
|
|
6
|
-
|
|
7
|
-
context "when string" do
|
|
8
|
-
let(:value) { "foo" }
|
|
9
|
-
|
|
10
|
-
it { is_expected.to be(:foo) }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when not castable" do
|
|
14
|
-
let(:value) { Object.new }
|
|
15
|
-
|
|
16
|
-
it {
|
|
17
|
-
is_expected_to_raise(
|
|
18
|
-
Foobara::Value::Processor::Casting::CannotCastError,
|
|
19
|
-
/Expected it to be a Symbol, or be a String\z/
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":tuple" do
|
|
2
|
-
let(:type) do
|
|
3
|
-
Foobara::Domain.current.foobara_type_from_declaration(type_declaration)
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
let(:outcome) { type.process_value(value) }
|
|
7
|
-
let(:errors) { outcome.errors }
|
|
8
|
-
let(:error) do
|
|
9
|
-
expect(errors.size).to eq(1)
|
|
10
|
-
errors.first
|
|
11
|
-
end
|
|
12
|
-
let(:result) { outcome.result! }
|
|
13
|
-
|
|
14
|
-
let(:type_declaration) do
|
|
15
|
-
[:big_decimal, { a: :integer }]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when using array sugar" do
|
|
19
|
-
describe "#declaration_data" do
|
|
20
|
-
it "converts to strict type declaration successfully" do
|
|
21
|
-
expect(type.declaration_data).to eq(
|
|
22
|
-
type: :tuple,
|
|
23
|
-
element_type_declarations: [
|
|
24
|
-
:big_decimal,
|
|
25
|
-
{ type: :attributes, element_type_declarations: { a: :integer } }
|
|
26
|
-
],
|
|
27
|
-
size: 2
|
|
28
|
-
)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "when array sugar contains a Type" do
|
|
32
|
-
let(:type_declaration) { [:string, Foobara::BuiltinTypes[:integer], :symbol] }
|
|
33
|
-
|
|
34
|
-
it "converts to strict type declaration successfully" do
|
|
35
|
-
expect(type.declaration_data).to eq(
|
|
36
|
-
type: :tuple,
|
|
37
|
-
element_type_declarations: [:string, :integer, :symbol],
|
|
38
|
-
size: 3
|
|
39
|
-
)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
describe "#possible_errors" do
|
|
45
|
-
it "converts to strict type declaration successfully" do
|
|
46
|
-
expect(type.possible_errors.to_h { |p| [p.key.to_sym, p.error_class] }).to eq(
|
|
47
|
-
"data.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError,
|
|
48
|
-
"data.incorrect_tuple_size": Foobara::BuiltinTypes::Array::SupportedValidators::Size::IncorrectTupleSizeError,
|
|
49
|
-
"data.0.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError,
|
|
50
|
-
"data.1.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError,
|
|
51
|
-
"data.1.unexpected_attributes":
|
|
52
|
-
Foobara::BuiltinTypes::Attributes::SupportedProcessors::ElementTypeDeclarations::UnexpectedAttributesError,
|
|
53
|
-
"data.1.a.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError
|
|
54
|
-
)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
context "when using strict hash" do
|
|
60
|
-
let(:type_declaration) do
|
|
61
|
-
{
|
|
62
|
-
type: :tuple,
|
|
63
|
-
element_type_declarations: [
|
|
64
|
-
{ type: :big_decimal },
|
|
65
|
-
{ type: :attributes, element_type_declarations: { a: { type: :integer } } }
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
describe "#process_value!" do
|
|
71
|
-
subject { result }
|
|
72
|
-
|
|
73
|
-
context "when valid value" do
|
|
74
|
-
let(:value) { ["3", { a: "2" }] }
|
|
75
|
-
|
|
76
|
-
it { is_expected.to eq([BigDecimal(3), { a: 2 }]) }
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
context "when value has too many elements" do
|
|
80
|
-
let(:value) { ["3", { a: "2" }, :z] }
|
|
81
|
-
|
|
82
|
-
it { is_expected_to_raise(Foobara::BuiltinTypes::Array::SupportedValidators::Size::IncorrectTupleSizeError) }
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "when an element has an error" do
|
|
86
|
-
let(:value) { ["3", { a: "not valid" }] }
|
|
87
|
-
|
|
88
|
-
it "has error for that element" do
|
|
89
|
-
expect(error.to_h).to eq(
|
|
90
|
-
key: "data.1.a.cannot_cast",
|
|
91
|
-
path: [1, :a],
|
|
92
|
-
runtime_path: [],
|
|
93
|
-
category: :data,
|
|
94
|
-
is_fatal: true,
|
|
95
|
-
symbol: :cannot_cast,
|
|
96
|
-
message: 'At 1.a: Cannot cast "not valid" to an integer. Expected it to be a Integer, ' \
|
|
97
|
-
"or be a string of digits optionally with a minus sign in front",
|
|
98
|
-
context: { cast_to: :integer, value: "not valid" }
|
|
99
|
-
)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
context "when size doesn't match" do
|
|
105
|
-
let(:type_declaration) { super().merge(size: 3) }
|
|
106
|
-
|
|
107
|
-
it "explodes" do
|
|
108
|
-
expect { type }.to raise_error(
|
|
109
|
-
Foobara::BuiltinTypes::Tuple::SupportedProcessors::ElementTypeDeclarations::TypeDeclarationExtension::
|
|
110
|
-
ExtendTupleTypeDeclaration::TypeDeclarationValidators::SizeMatches::IncorrectSizeError
|
|
111
|
-
)
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
describe "#process_value!" do
|
|
117
|
-
subject { type.process_value!(value) }
|
|
118
|
-
|
|
119
|
-
context "when not castable" do
|
|
120
|
-
let(:value) { Object.new }
|
|
121
|
-
|
|
122
|
-
it { is_expected_to_raise(Foobara::Value::Processor::Casting::CannotCastError) }
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Callback do
|
|
2
|
-
context "with single multiple action registry" do
|
|
3
|
-
let(:registry) { Foobara::Callback::Registry::MultipleAction.new(:walk, :jump) }
|
|
4
|
-
|
|
5
|
-
let(:calls) { {} }
|
|
6
|
-
|
|
7
|
-
def called(action, type, data)
|
|
8
|
-
for_type = calls[action] ||= {}
|
|
9
|
-
data_array = for_type[type] ||= []
|
|
10
|
-
data_array << data
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
before do
|
|
14
|
-
[:walk, :jump].each do |action|
|
|
15
|
-
Foobara::Callback::Block.types.each do |type|
|
|
16
|
-
basic_block = ->(foo) {
|
|
17
|
-
called(action, type, foo)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
callback = if type == :around
|
|
21
|
-
->(**opts, &do_it) {
|
|
22
|
-
basic_block.call(opts)
|
|
23
|
-
do_it.call
|
|
24
|
-
}
|
|
25
|
-
else
|
|
26
|
-
basic_block
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
registry.register_callback(type, action, &callback)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe Foobara::Callback::Runner do
|
|
35
|
-
let(:runner) { registry.runner(:walk).callback_data(foo: :bar) }
|
|
36
|
-
|
|
37
|
-
describe "#run" do
|
|
38
|
-
context "with a block for a callback type that does not allow a block" do
|
|
39
|
-
it "raises an error" do
|
|
40
|
-
expect {
|
|
41
|
-
registry.register_callback(:before, :walk) { |&block| block.call }
|
|
42
|
-
}.to raise_error(
|
|
43
|
-
Foobara::Callback::Block::Concerns::BlockParameterNotAllowed::BlockParameterNotAllowedError
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context "with block" do
|
|
49
|
-
it "calls expected callbacks in order" do
|
|
50
|
-
ran = false
|
|
51
|
-
|
|
52
|
-
expect(calls).to eq({})
|
|
53
|
-
|
|
54
|
-
registry.around(:walk) do |&do_it|
|
|
55
|
-
expect(calls).to eq(
|
|
56
|
-
walk: {
|
|
57
|
-
before: [{ foo: :bar }]
|
|
58
|
-
}
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
do_it.call
|
|
62
|
-
|
|
63
|
-
expect(calls).to eq(
|
|
64
|
-
walk: {
|
|
65
|
-
before: [{ foo: :bar }],
|
|
66
|
-
around: [{ foo: :bar }]
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
expect {
|
|
72
|
-
runner.run { ran = true }
|
|
73
|
-
}.to change { ran }.from(false).to(true)
|
|
74
|
-
|
|
75
|
-
expect(calls).to eq(
|
|
76
|
-
walk: {
|
|
77
|
-
before: [{ foo: :bar }],
|
|
78
|
-
around: [{ foo: :bar }],
|
|
79
|
-
after: [{ foo: :bar }]
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "with any action callback" do
|
|
86
|
-
before do
|
|
87
|
-
registry.before(nil) do
|
|
88
|
-
called(nil, :before, :any_called)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "calls the any callback on any action" do
|
|
93
|
-
runner1 = registry.runner(:walk).callback_data(foo: :w)
|
|
94
|
-
runner2 = registry.runner(:jump).callback_data(foo: :j)
|
|
95
|
-
|
|
96
|
-
runner1.run do
|
|
97
|
-
# empty block
|
|
98
|
-
end
|
|
99
|
-
runner2.run do
|
|
100
|
-
# empty block
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
expect(calls).to eq(
|
|
104
|
-
{
|
|
105
|
-
nil => {
|
|
106
|
-
before: [:any_called, :any_called]
|
|
107
|
-
},
|
|
108
|
-
walk: {
|
|
109
|
-
before: [{ foo: :w }],
|
|
110
|
-
around: [{ foo: :w }],
|
|
111
|
-
after: [{ foo: :w }]
|
|
112
|
-
},
|
|
113
|
-
jump: {
|
|
114
|
-
before: [{ foo: :j }],
|
|
115
|
-
around: [{ foo: :j }],
|
|
116
|
-
after: [{ foo: :j }]
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
context "when error occurs" do
|
|
124
|
-
let(:kaboom) { Class.new(StandardError) }
|
|
125
|
-
|
|
126
|
-
it "calls the any callback on any action" do
|
|
127
|
-
expect {
|
|
128
|
-
runner.run do
|
|
129
|
-
raise kaboom, "Kaboom!"
|
|
130
|
-
end
|
|
131
|
-
}.to raise_error(kaboom)
|
|
132
|
-
|
|
133
|
-
expect(calls.keys).to eq([:walk])
|
|
134
|
-
walk = calls[:walk]
|
|
135
|
-
expect(walk.keys).to eq([:before, :around, :error])
|
|
136
|
-
|
|
137
|
-
expect(walk[:before]).to eq([{ foo: :bar }])
|
|
138
|
-
expect(walk[:around]).to eq([{ foo: :bar }])
|
|
139
|
-
errors = walk[:error]
|
|
140
|
-
|
|
141
|
-
expect(errors.length).to eq(1)
|
|
142
|
-
error = errors.first
|
|
143
|
-
|
|
144
|
-
expect(error).to be_a(runner.class::UnexpectedErrorWhileRunningCallback)
|
|
145
|
-
expect(error.cause).to be_a(kaboom)
|
|
146
|
-
expect(error.callback_data).to eq(foo: :bar)
|
|
147
|
-
expect(error.message).to eq("Kaboom!")
|
|
148
|
-
expect(error.cause).to be_a(kaboom)
|
|
149
|
-
expect(error.cause.message).to eq("Kaboom!")
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
end
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Callback::Registry::Conditioned do
|
|
2
|
-
let(:registry) { described_class.new(charge: [:positive, :negative], mass: [:high, :low]) }
|
|
3
|
-
|
|
4
|
-
describe "#register_callback" do
|
|
5
|
-
let(:condition_key) { :charge }
|
|
6
|
-
let(:condition_value) { :positive }
|
|
7
|
-
let(:conditions) { { condition_key => condition_value } }
|
|
8
|
-
|
|
9
|
-
def register_it
|
|
10
|
-
registry.after(conditions) { "noop" }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when given good condition" do
|
|
14
|
-
it "registers it and can return it even when unioned with other conditions" do
|
|
15
|
-
expect {
|
|
16
|
-
register_it
|
|
17
|
-
}.to change { registry.callback_sets.size }.from(0).to(1)
|
|
18
|
-
|
|
19
|
-
registry.unioned_callback_set_for(charge: :positive, mass: nil)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context "when given bad condition key" do
|
|
24
|
-
let(:condition_key) { :bad_key }
|
|
25
|
-
|
|
26
|
-
it "explodes" do
|
|
27
|
-
expect {
|
|
28
|
-
register_it
|
|
29
|
-
}.to raise_error(described_class::InvalidConditions)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "when given bad condition value" do
|
|
34
|
-
let(:condition_value) { :bad_value }
|
|
35
|
-
|
|
36
|
-
it "explodes" do
|
|
37
|
-
expect {
|
|
38
|
-
register_it
|
|
39
|
-
}.to raise_error(described_class::InvalidConditions)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "when given nil value" do
|
|
44
|
-
let(:condition_value) { nil }
|
|
45
|
-
|
|
46
|
-
it "is fine" do
|
|
47
|
-
expect {
|
|
48
|
-
register_it
|
|
49
|
-
}.to change { registry.callback_sets.size }.from(0).to(1)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe "#runner" do
|
|
55
|
-
context "when no conditions given" do
|
|
56
|
-
let(:runner) { registry.runner.callback_data(foo: :bar) }
|
|
57
|
-
|
|
58
|
-
describe "#run" do
|
|
59
|
-
context "with block" do
|
|
60
|
-
it "calls expected callbacks in order" do
|
|
61
|
-
ran = false
|
|
62
|
-
callback_ran = false
|
|
63
|
-
|
|
64
|
-
registry.around do |foo:, &do_it|
|
|
65
|
-
expect(foo).to eq(:bar)
|
|
66
|
-
|
|
67
|
-
do_it.call
|
|
68
|
-
|
|
69
|
-
callback_ran = true
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
expect {
|
|
73
|
-
runner.run { ran = true }
|
|
74
|
-
}.to change { ran }.from(false).to(true)
|
|
75
|
-
|
|
76
|
-
expect(callback_ran).to be(true)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context "with blocks" do
|
|
81
|
-
let(:callbacks_ran) { [] }
|
|
82
|
-
|
|
83
|
-
before do
|
|
84
|
-
expect(registry).to_not have_before_callbacks
|
|
85
|
-
expect(registry).to_not have_around_callbacks
|
|
86
|
-
expect(registry).to_not have_after_callbacks
|
|
87
|
-
expect(registry).to_not have_error_callbacks
|
|
88
|
-
|
|
89
|
-
registry.before do |foo:|
|
|
90
|
-
expect(foo).to eq(:bar)
|
|
91
|
-
callbacks_ran << :before
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
expect(registry).to have_before_callbacks
|
|
95
|
-
expect(registry).to_not have_around_callbacks
|
|
96
|
-
expect(registry).to_not have_after_callbacks
|
|
97
|
-
expect(registry).to_not have_error_callbacks
|
|
98
|
-
|
|
99
|
-
registry.around do |foo:, &do_it|
|
|
100
|
-
callbacks_ran << :around_start
|
|
101
|
-
expect(foo).to eq(:bar)
|
|
102
|
-
|
|
103
|
-
do_it.call
|
|
104
|
-
|
|
105
|
-
callbacks_ran << :around_end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
expect(registry).to have_before_callbacks
|
|
109
|
-
expect(registry).to have_around_callbacks
|
|
110
|
-
expect(registry).to_not have_after_callbacks
|
|
111
|
-
expect(registry).to_not have_error_callbacks
|
|
112
|
-
|
|
113
|
-
registry.after do |foo:|
|
|
114
|
-
expect(foo).to eq(:bar)
|
|
115
|
-
callbacks_ran << :after
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
expect(registry).to have_before_callbacks
|
|
119
|
-
expect(registry).to have_around_callbacks
|
|
120
|
-
expect(registry).to have_after_callbacks
|
|
121
|
-
expect(registry).to_not have_error_callbacks
|
|
122
|
-
|
|
123
|
-
registry.error do |error|
|
|
124
|
-
expect(error).to be_a(Foobara::Callback::Runner::UnexpectedErrorWhileRunningCallback)
|
|
125
|
-
expect(error.message).to eq("kaboom!")
|
|
126
|
-
|
|
127
|
-
callbacks_ran << :error
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
expect(registry).to have_before_callbacks
|
|
131
|
-
expect(registry).to have_around_callbacks
|
|
132
|
-
expect(registry).to have_after_callbacks
|
|
133
|
-
expect(registry).to have_error_callbacks
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it "calls expected callbacks in order" do
|
|
137
|
-
runner.run { "noop" }
|
|
138
|
-
|
|
139
|
-
expect(callbacks_ran).to eq([:before, :around_start, :around_end, :after])
|
|
140
|
-
callbacks_ran.clear
|
|
141
|
-
|
|
142
|
-
expect {
|
|
143
|
-
runner.run { raise "kaboom!" }
|
|
144
|
-
}.to raise_error(RuntimeError)
|
|
145
|
-
|
|
146
|
-
expect(callbacks_ran).to eq([:before, :around_start, :error])
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|