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,144 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Callback::Registry::MultipleAction do
|
|
2
|
-
let(:registry) { described_class.new(possible_actions) }
|
|
3
|
-
let(:possible_actions) { [:run, :walk] }
|
|
4
|
-
|
|
5
|
-
describe "#register_callback" do
|
|
6
|
-
let(:action) { :run }
|
|
7
|
-
|
|
8
|
-
def register_it
|
|
9
|
-
registry.after(action) { "noop" }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context "when given good action" do
|
|
13
|
-
it "registers it and can return it even when unioned with other actions" do
|
|
14
|
-
expect {
|
|
15
|
-
register_it
|
|
16
|
-
}.to change { registry.callback_sets.size }.from(0).to(1)
|
|
17
|
-
|
|
18
|
-
set = registry.unioned_callback_set_for(:run)
|
|
19
|
-
expect(set.size).to eq(1)
|
|
20
|
-
set = registry.unioned_callback_set_for(nil)
|
|
21
|
-
expect(set.size).to eq(1)
|
|
22
|
-
set = registry.unioned_callback_set_for(:walk)
|
|
23
|
-
expect(set.size).to eq(0)
|
|
24
|
-
expect {
|
|
25
|
-
registry.unioned_callback_set_for(:bad_symbol)
|
|
26
|
-
}.to raise_error(described_class::InvalidAction)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "when given bad action" do
|
|
31
|
-
let(:action) { :bad_key }
|
|
32
|
-
|
|
33
|
-
it "explodes" do
|
|
34
|
-
expect {
|
|
35
|
-
register_it
|
|
36
|
-
}.to raise_error(described_class::InvalidAction)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context "when given nil value" do
|
|
41
|
-
let(:action) { nil }
|
|
42
|
-
|
|
43
|
-
it "is fine" do
|
|
44
|
-
expect {
|
|
45
|
-
register_it
|
|
46
|
-
}.to change { registry.callback_sets.size }.from(0).to(1)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
describe "#runner" do
|
|
52
|
-
context "when no action given" do
|
|
53
|
-
let(:runner) { registry.runner }
|
|
54
|
-
|
|
55
|
-
describe "#run" do
|
|
56
|
-
context "with block" do
|
|
57
|
-
it "calls expected callbacks in order" do
|
|
58
|
-
ran = false
|
|
59
|
-
callback_ran = false
|
|
60
|
-
|
|
61
|
-
registry.around do |&do_it|
|
|
62
|
-
do_it.call
|
|
63
|
-
|
|
64
|
-
callback_ran = true
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
expect {
|
|
68
|
-
runner.run { ran = true }
|
|
69
|
-
}.to change { ran }.from(false).to(true)
|
|
70
|
-
|
|
71
|
-
expect(callback_ran).to be(true)
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context "with blocks" do
|
|
76
|
-
let(:callbacks_ran) { [] }
|
|
77
|
-
|
|
78
|
-
before do
|
|
79
|
-
expect(registry).to_not have_before_callbacks
|
|
80
|
-
expect(registry).to_not have_around_callbacks
|
|
81
|
-
expect(registry).to_not have_after_callbacks
|
|
82
|
-
expect(registry).to_not have_error_callbacks
|
|
83
|
-
|
|
84
|
-
registry.before do
|
|
85
|
-
callbacks_ran << :before
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
expect(registry).to have_before_callbacks
|
|
89
|
-
expect(registry).to_not have_around_callbacks
|
|
90
|
-
expect(registry).to_not have_after_callbacks
|
|
91
|
-
expect(registry).to_not have_error_callbacks
|
|
92
|
-
|
|
93
|
-
registry.around do |&do_it|
|
|
94
|
-
callbacks_ran << :around_start
|
|
95
|
-
|
|
96
|
-
do_it.call
|
|
97
|
-
|
|
98
|
-
callbacks_ran << :around_end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
expect(registry).to have_before_callbacks
|
|
102
|
-
expect(registry).to have_around_callbacks
|
|
103
|
-
expect(registry).to_not have_after_callbacks
|
|
104
|
-
expect(registry).to_not have_error_callbacks
|
|
105
|
-
|
|
106
|
-
registry.after do
|
|
107
|
-
callbacks_ran << :after
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
expect(registry).to have_before_callbacks
|
|
111
|
-
expect(registry).to have_around_callbacks
|
|
112
|
-
expect(registry).to have_after_callbacks
|
|
113
|
-
expect(registry).to_not have_error_callbacks
|
|
114
|
-
|
|
115
|
-
registry.error do |error|
|
|
116
|
-
expect(error).to be_a(Foobara::Callback::Runner::UnexpectedErrorWhileRunningCallback)
|
|
117
|
-
expect(error.message).to eq("kaboom!")
|
|
118
|
-
|
|
119
|
-
callbacks_ran << :error
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
expect(registry).to have_before_callbacks
|
|
123
|
-
expect(registry).to have_around_callbacks
|
|
124
|
-
expect(registry).to have_after_callbacks
|
|
125
|
-
expect(registry).to have_error_callbacks
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it "calls expected callbacks in order" do
|
|
129
|
-
runner.run { "noop" }
|
|
130
|
-
|
|
131
|
-
expect(callbacks_ran).to eq([:before, :around_start, :around_end, :after])
|
|
132
|
-
callbacks_ran.clear
|
|
133
|
-
|
|
134
|
-
expect {
|
|
135
|
-
runner.run { raise "kaboom!" }
|
|
136
|
-
}.to raise_error(RuntimeError)
|
|
137
|
-
|
|
138
|
-
expect(callbacks_ran).to eq([:before, :around_start, :error])
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::Callback::Registry::SingleAction do
|
|
2
|
-
let(:registry) { described_class.new }
|
|
3
|
-
|
|
4
|
-
describe "#register_callback" do
|
|
5
|
-
def register_it
|
|
6
|
-
registry.after { "noop" }
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
context "when given good action" do
|
|
10
|
-
it "registers it and can return it even when unioned with other actions" do
|
|
11
|
-
expect {
|
|
12
|
-
register_it
|
|
13
|
-
}.to change { registry.specific_callback_set_for.size }.from(0).to(1)
|
|
14
|
-
|
|
15
|
-
set = registry.unioned_callback_set_for
|
|
16
|
-
expect(set.size).to eq(1)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe "#runner" do
|
|
22
|
-
context "when no action given" do
|
|
23
|
-
let(:runner) { registry.runner }
|
|
24
|
-
|
|
25
|
-
describe "#run" do
|
|
26
|
-
context "with block" do
|
|
27
|
-
it "calls expected callbacks in order" do
|
|
28
|
-
ran = false
|
|
29
|
-
callback_ran = false
|
|
30
|
-
|
|
31
|
-
registry.around do |&do_it|
|
|
32
|
-
do_it.call
|
|
33
|
-
|
|
34
|
-
callback_ran = true
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
expect {
|
|
38
|
-
runner.run { ran = true }
|
|
39
|
-
}.to change { ran }.from(false).to(true)
|
|
40
|
-
|
|
41
|
-
expect(callback_ran).to be(true)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context "with blocks" do
|
|
46
|
-
let(:callbacks_ran) { [] }
|
|
47
|
-
|
|
48
|
-
before do
|
|
49
|
-
expect(registry).to_not have_before_callbacks
|
|
50
|
-
expect(registry).to_not have_around_callbacks
|
|
51
|
-
expect(registry).to_not have_after_callbacks
|
|
52
|
-
expect(registry).to_not have_error_callbacks
|
|
53
|
-
|
|
54
|
-
registry.before do
|
|
55
|
-
callbacks_ran << :before
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
expect(registry).to have_before_callbacks
|
|
59
|
-
expect(registry).to_not have_around_callbacks
|
|
60
|
-
expect(registry).to_not have_after_callbacks
|
|
61
|
-
expect(registry).to_not have_error_callbacks
|
|
62
|
-
|
|
63
|
-
registry.around do |&do_it|
|
|
64
|
-
callbacks_ran << :around_start
|
|
65
|
-
|
|
66
|
-
do_it.call
|
|
67
|
-
|
|
68
|
-
callbacks_ran << :around_end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
expect(registry).to have_before_callbacks
|
|
72
|
-
expect(registry).to have_around_callbacks
|
|
73
|
-
expect(registry).to_not have_after_callbacks
|
|
74
|
-
expect(registry).to_not have_error_callbacks
|
|
75
|
-
|
|
76
|
-
registry.after do
|
|
77
|
-
callbacks_ran << :after
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
expect(registry).to have_before_callbacks
|
|
81
|
-
expect(registry).to have_around_callbacks
|
|
82
|
-
expect(registry).to have_after_callbacks
|
|
83
|
-
expect(registry).to_not have_error_callbacks
|
|
84
|
-
|
|
85
|
-
registry.error do |error|
|
|
86
|
-
expect(error).to be_a(Foobara::Callback::Runner::UnexpectedErrorWhileRunningCallback)
|
|
87
|
-
expect(error.message).to eq("kaboom!")
|
|
88
|
-
|
|
89
|
-
callbacks_ran << :error
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
expect(registry).to have_before_callbacks
|
|
93
|
-
expect(registry).to have_around_callbacks
|
|
94
|
-
expect(registry).to have_after_callbacks
|
|
95
|
-
expect(registry).to have_error_callbacks
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "calls expected callbacks in order" do
|
|
99
|
-
runner.run { "noop" }
|
|
100
|
-
|
|
101
|
-
expect(callbacks_ran).to eq([:before, :around_start, :around_end, :after])
|
|
102
|
-
callbacks_ran.clear
|
|
103
|
-
|
|
104
|
-
expect {
|
|
105
|
-
runner.run { raise "kaboom!" }
|
|
106
|
-
}.to raise_error(RuntimeError)
|
|
107
|
-
|
|
108
|
-
expect(callbacks_ran).to eq([:before, :around_start, :error])
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::DataPath do
|
|
2
|
-
let(:key) { described_class.new(path) }
|
|
3
|
-
|
|
4
|
-
let(:category) { "some_category" }
|
|
5
|
-
let(:path) { "some_path" }
|
|
6
|
-
let(:runtime_path) { "some_runtime_path" }
|
|
7
|
-
let(:symbol) { "some_symbol" }
|
|
8
|
-
|
|
9
|
-
describe ".prepend_path" do
|
|
10
|
-
let(:new_parts) { [:path1, :path2] }
|
|
11
|
-
|
|
12
|
-
context "when DataPath" do
|
|
13
|
-
subject { described_class.prepend_path(key, new_parts) }
|
|
14
|
-
|
|
15
|
-
it { is_expected.to eq(described_class.parse("path1.path2.some_path")) }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when string" do
|
|
19
|
-
subject { described_class.prepend_path(path, new_parts) }
|
|
20
|
-
|
|
21
|
-
it { is_expected.to eq(described_class.parse("path1.path2.some_path").to_s) }
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe ".append_path" do
|
|
26
|
-
let(:new_parts) { [:path1, :path2] }
|
|
27
|
-
|
|
28
|
-
context "when DataPath" do
|
|
29
|
-
subject { described_class.append_path(key, new_parts) }
|
|
30
|
-
|
|
31
|
-
it { is_expected.to eq(described_class.parse("some_path.path1.path2")) }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context "when string" do
|
|
35
|
-
subject { described_class.append_path(path, new_parts) }
|
|
36
|
-
|
|
37
|
-
it { is_expected.to eq(described_class.parse("some_path.path1.path2").to_s) }
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe ".to_s_type" do
|
|
42
|
-
it "changes integer indices to pound sign" do
|
|
43
|
-
expect(described_class.to_s_type("a.0.b")).to eq("a.#.b")
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe "#to_sym" do
|
|
48
|
-
it "just calls #to_sym on the string path" do
|
|
49
|
-
expect(described_class.new([:a, :b]).to_sym).to eq(:"a.b")
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe ".values_at" do
|
|
54
|
-
subject { described_class.values_at(path, object) }
|
|
55
|
-
|
|
56
|
-
context "when nested with two indices" do
|
|
57
|
-
let(:path) { [:foo, :bar, :"#", :foo, :chars, 2] }
|
|
58
|
-
|
|
59
|
-
let(:object) do
|
|
60
|
-
Struct.new(:foo).new.tap do |o|
|
|
61
|
-
o.foo = {
|
|
62
|
-
bar: [
|
|
63
|
-
{
|
|
64
|
-
foo: "bar",
|
|
65
|
-
foo2: "junk"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
foo: "baz"
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it { is_expected.to eq(["r", "z"]) }
|
|
76
|
-
|
|
77
|
-
context "when object has strings instead of symbols" do
|
|
78
|
-
before do
|
|
79
|
-
bar = object.foo.delete(:bar)
|
|
80
|
-
expect(bar).to be_an(Array)
|
|
81
|
-
|
|
82
|
-
object.foo["bar"] = bar
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it { is_expected.to eq(["r", "z"]) }
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
describe ".value_at" do
|
|
91
|
-
let(:object) do
|
|
92
|
-
Struct.new(:foo).new.tap do |o|
|
|
93
|
-
o.foo = {
|
|
94
|
-
bar: [
|
|
95
|
-
{
|
|
96
|
-
foo: "bar"
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
let(:path) { [:foo, :bar, 0, :foo, :chars, 2] }
|
|
104
|
-
let(:value) { described_class.value_at(path, object) }
|
|
105
|
-
|
|
106
|
-
it "can find the relevant value" do
|
|
107
|
-
expect(value).to eq("r")
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
context "when using strings in the path instead of symbols" do
|
|
111
|
-
# Hmmmm... mildly surprising that this works with "2" instead of 2 but that's likely desirable.
|
|
112
|
-
let(:path) { super().map(&:to_s) }
|
|
113
|
-
|
|
114
|
-
it "can find the relevant value" do
|
|
115
|
-
expect(value).to eq("r")
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
context "when there's more than one value at the path" do
|
|
120
|
-
let(:object) do
|
|
121
|
-
Struct.new(:foo).new.tap do |o|
|
|
122
|
-
o.foo = {
|
|
123
|
-
bar: [
|
|
124
|
-
{
|
|
125
|
-
foo: "bar"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
foo: "baz"
|
|
129
|
-
}
|
|
130
|
-
]
|
|
131
|
-
}
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
let(:path) { [:foo, :bar, :"#", :foo, :chars, 2] }
|
|
136
|
-
|
|
137
|
-
it "raises TooManyValuesAtPathError" do
|
|
138
|
-
expect { described_class.value_at(path, object) }.to raise_error(described_class::TooManyValuesAtPathError)
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
context "when path is empty string" do
|
|
143
|
-
let(:path) { "" }
|
|
144
|
-
let(:object) { 1 }
|
|
145
|
-
|
|
146
|
-
it "returns the object itself" do
|
|
147
|
-
expect(described_class.value_at(path, object)).to eq(object)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
describe "#simple_collection?" do
|
|
153
|
-
subject { described_class.new(path).simple_collection? }
|
|
154
|
-
|
|
155
|
-
context "when not a collection" do
|
|
156
|
-
let(:path) { [:foo, :bar] }
|
|
157
|
-
|
|
158
|
-
it { is_expected.to be(false) }
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
context "when not simple" do
|
|
162
|
-
let(:path) { [:foo, :"#", :bar, :"#"] }
|
|
163
|
-
|
|
164
|
-
it { is_expected.to be(false) }
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
context "when simple and a collection" do
|
|
168
|
-
let(:path) { [:foo, :bar, :baz, :"#"] }
|
|
169
|
-
|
|
170
|
-
it { is_expected.to be(true) }
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
describe ".set_value_at" do
|
|
175
|
-
let(:some_struct) { Struct.new(:z) }
|
|
176
|
-
|
|
177
|
-
let(:object) do
|
|
178
|
-
[
|
|
179
|
-
{
|
|
180
|
-
a: {
|
|
181
|
-
b: [1, 2, { c: 4 }],
|
|
182
|
-
d: some_struct.new("zz")
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
"whatever"
|
|
186
|
-
]
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
context "when changing value of a hash" do
|
|
190
|
-
let(:path) { [0, :a, :b, 2, :c] }
|
|
191
|
-
|
|
192
|
-
it "can dig through the structure and set the value" do
|
|
193
|
-
described_class.set_value_at(object, 100, path)
|
|
194
|
-
|
|
195
|
-
expect(object).to eq(
|
|
196
|
-
[
|
|
197
|
-
{
|
|
198
|
-
a: {
|
|
199
|
-
b: [1, 2, { c: 100 }],
|
|
200
|
-
d: some_struct.new("zz")
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
"whatever"
|
|
204
|
-
]
|
|
205
|
-
)
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
context "when changing value of a hash indifferently" do
|
|
210
|
-
let(:object) do
|
|
211
|
-
{
|
|
212
|
-
"a" => {
|
|
213
|
-
"b" => 10
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
end
|
|
217
|
-
let(:path) { ["a", "b"] }
|
|
218
|
-
|
|
219
|
-
it "can dig through the structure and set the value" do
|
|
220
|
-
described_class.set_value_at(object, 100, path)
|
|
221
|
-
|
|
222
|
-
expect(object).to eq("a" => { "b" => 100 })
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
context "when changing an array element" do
|
|
227
|
-
let(:path) { [0, :a, :b, 1] }
|
|
228
|
-
|
|
229
|
-
it "can dig through the structure and set the value" do
|
|
230
|
-
described_class.set_value_at(object, 100, path)
|
|
231
|
-
|
|
232
|
-
expect(object).to eq(
|
|
233
|
-
[
|
|
234
|
-
{
|
|
235
|
-
a: {
|
|
236
|
-
b: [1, 100, { c: 4 }],
|
|
237
|
-
d: some_struct.new("zz")
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
"whatever"
|
|
241
|
-
]
|
|
242
|
-
)
|
|
243
|
-
end
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
context "when changing via method" do
|
|
247
|
-
let(:path) { [0, :a, :d, :z] }
|
|
248
|
-
|
|
249
|
-
it "can dig through the structure and set the value" do
|
|
250
|
-
object[0][:a][:d].z = 15
|
|
251
|
-
|
|
252
|
-
described_class.set_value_at(object, 200, path)
|
|
253
|
-
|
|
254
|
-
expect(object).to eq(
|
|
255
|
-
[
|
|
256
|
-
{
|
|
257
|
-
a: {
|
|
258
|
-
b: [1, 2, { c: 4 }],
|
|
259
|
-
d: some_struct.new(200)
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
"whatever"
|
|
263
|
-
]
|
|
264
|
-
)
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
end
|
|
268
|
-
end
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::ErrorCollection do
|
|
2
|
-
let(:error_collection) { described_class.new }
|
|
3
|
-
|
|
4
|
-
describe "#success?" do
|
|
5
|
-
context "when no errors" do
|
|
6
|
-
it { is_expected.to be_success }
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe "#add_error" do
|
|
11
|
-
let(:symbol) { :s }
|
|
12
|
-
let(:message) { "m" }
|
|
13
|
-
let(:context) { { foo: :bar } }
|
|
14
|
-
|
|
15
|
-
let(:error_class) do
|
|
16
|
-
Foobara::Error.subclass(symbol:, message:, context: { foo: :symbol }, is_fatal: true)
|
|
17
|
-
end
|
|
18
|
-
let(:error) { error_class.new(context:) }
|
|
19
|
-
|
|
20
|
-
context "when adding error instance" do
|
|
21
|
-
it "creates and adds an error" do
|
|
22
|
-
expect(error_collection).to be_empty
|
|
23
|
-
|
|
24
|
-
error_collection.add_error(error)
|
|
25
|
-
|
|
26
|
-
expect(error_collection).to_not be_empty
|
|
27
|
-
expect(error_collection.size).to eq(1)
|
|
28
|
-
error = error_collection.first
|
|
29
|
-
expect(error).to be_a(Foobara::Error)
|
|
30
|
-
expect(error.is_fatal).to be(true)
|
|
31
|
-
expect(error.symbol).to eq(symbol)
|
|
32
|
-
expect(error.message).to eq(message)
|
|
33
|
-
expect(error.context).to eq(context)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Do we really need to support this?
|
|
38
|
-
context "when adding error by hash" do
|
|
39
|
-
around do |example|
|
|
40
|
-
Foobara::TypeDeclarations.with_validate_error_context_disabled do
|
|
41
|
-
example.run
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
let(:error_hash) do
|
|
46
|
-
{
|
|
47
|
-
symbol:,
|
|
48
|
-
message:,
|
|
49
|
-
context:
|
|
50
|
-
}
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "creates and adds an error" do
|
|
54
|
-
expect(error_collection).to be_empty
|
|
55
|
-
|
|
56
|
-
error_collection.add_error(error_hash)
|
|
57
|
-
|
|
58
|
-
expect(error_collection).to_not be_empty
|
|
59
|
-
expect(error_collection.size).to eq(1)
|
|
60
|
-
error = error_collection.first
|
|
61
|
-
expect(error).to be_a(Foobara::Error)
|
|
62
|
-
expect(error.symbol).to eq(symbol)
|
|
63
|
-
expect(error.message).to eq(message)
|
|
64
|
-
expect(error.context).to eq(context)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context "when passing the same error twice" do
|
|
69
|
-
it "explodes" do
|
|
70
|
-
error_collection.add_error(error)
|
|
71
|
-
expect {
|
|
72
|
-
error_collection.add_error(error)
|
|
73
|
-
}.to raise_error(described_class::ErrorAlreadySetError)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::ErrorKey do
|
|
2
|
-
let(:key) { described_class.new(category:, path:, runtime_path:, symbol:) }
|
|
3
|
-
|
|
4
|
-
let(:category) { "some_category" }
|
|
5
|
-
let(:path) { "some_path" }
|
|
6
|
-
let(:runtime_path) { "some_runtime_path" }
|
|
7
|
-
let(:symbol) { "some_symbol" }
|
|
8
|
-
|
|
9
|
-
describe ".prepend_path" do
|
|
10
|
-
subject { described_class.prepend_path(key, new_parts) }
|
|
11
|
-
|
|
12
|
-
let(:new_parts) { [:path1, :path2] }
|
|
13
|
-
|
|
14
|
-
context "when ErrorKey" do
|
|
15
|
-
it { is_expected.to eq("some_runtime_path>some_category.path1.path2.some_path.some_symbol") }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when String" do
|
|
19
|
-
let(:key) { super().to_s }
|
|
20
|
-
|
|
21
|
-
it { is_expected.to eq("some_runtime_path>some_category.path1.path2.some_path.some_symbol") }
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe ".prepend_runtime_path" do
|
|
26
|
-
subject { described_class.prepend_runtime_path(key, new_parts) }
|
|
27
|
-
|
|
28
|
-
let(:new_parts) { [:path1, :path2] }
|
|
29
|
-
|
|
30
|
-
context "when ErrorKey" do
|
|
31
|
-
it { is_expected.to eq("path1>path2>some_runtime_path>some_category.some_path.some_symbol") }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context "when String" do
|
|
35
|
-
let(:key) { super().to_s }
|
|
36
|
-
|
|
37
|
-
it { is_expected.to eq("path1>path2>some_runtime_path>some_category.some_path.some_symbol") }
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe ".to_h" do
|
|
42
|
-
subject { described_class.to_h(key) }
|
|
43
|
-
|
|
44
|
-
let(:key) { "path1>path2>some_category.some_path.some_symbol" }
|
|
45
|
-
let(:expected_hash) do
|
|
46
|
-
{
|
|
47
|
-
category: :some_category,
|
|
48
|
-
runtime_path: [:path1, :path2],
|
|
49
|
-
path: [:some_path],
|
|
50
|
-
symbol: :some_symbol
|
|
51
|
-
}
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it { is_expected.to eq(expected_hash) }
|
|
55
|
-
end
|
|
56
|
-
end
|