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,138 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::BuiltinTypes::Duck::SupportedCasters::AllowNil do
|
|
2
|
-
let(:type_declaration) do
|
|
3
|
-
:integer
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
let(:type) do
|
|
7
|
-
Foobara::GlobalDomain.foobara_type_from_declaration(*Foobara::Util.array(type_declaration))
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe ".instance" do
|
|
11
|
-
it "has false declaration data" do
|
|
12
|
-
expect(described_class.instance.declaration_data).to be(false)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context "when not set" do
|
|
17
|
-
it "does not allow nil" do
|
|
18
|
-
outcome = type.process_value(5)
|
|
19
|
-
expect(outcome).to be_success
|
|
20
|
-
expect(outcome.result).to eq(5)
|
|
21
|
-
|
|
22
|
-
outcome = type.process_value(nil)
|
|
23
|
-
expect(outcome).to_not be_success
|
|
24
|
-
expect(outcome.error_keys).to eq(["data.cannot_cast"])
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context "when set to true" do
|
|
29
|
-
let(:type_declaration) do
|
|
30
|
-
[:integer, { allow_nil: true }]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "does allow nil" do
|
|
34
|
-
outcome = type.process_value(5)
|
|
35
|
-
expect(outcome).to be_success
|
|
36
|
-
expect(outcome.result).to eq(5)
|
|
37
|
-
|
|
38
|
-
outcome = type.process_value(nil)
|
|
39
|
-
expect(outcome).to be_success
|
|
40
|
-
expect(outcome.result).to be_nil
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context "with entire attributes that allow_nil" do
|
|
45
|
-
let(:type_declaration) do
|
|
46
|
-
{
|
|
47
|
-
type: :attributes,
|
|
48
|
-
element_type_declarations: {
|
|
49
|
-
foo: :integer
|
|
50
|
-
},
|
|
51
|
-
required: :foo,
|
|
52
|
-
allow_nil: true
|
|
53
|
-
}
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "when not nil" do
|
|
57
|
-
it "works as usual" do
|
|
58
|
-
outcome = type.process_value(foo: 5)
|
|
59
|
-
|
|
60
|
-
expect(outcome).to be_success
|
|
61
|
-
expect(outcome.result).to eq(foo: 5)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context "when nil" do
|
|
66
|
-
it "returns nil" do
|
|
67
|
-
outcome = type.process_value(nil)
|
|
68
|
-
|
|
69
|
-
expect(outcome).to be_success
|
|
70
|
-
expect(outcome.result).to be_nil
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context "with attribute that is allow_nil" do
|
|
76
|
-
let(:type_declaration) do
|
|
77
|
-
proc do
|
|
78
|
-
default :integer
|
|
79
|
-
implicit_true :integer, :allow_nil
|
|
80
|
-
explicit_true :integer, allow_nil: true
|
|
81
|
-
explicit_false :integer, allow_nil: false
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "allows nil the implicit true and the explicit true" do
|
|
86
|
-
outcome = type.process_value(
|
|
87
|
-
default: nil,
|
|
88
|
-
implicit_true: nil,
|
|
89
|
-
explicit_true: nil,
|
|
90
|
-
explicit_false: nil
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
expect(outcome).to_not be_success
|
|
94
|
-
expect(outcome.error_keys).to eq(
|
|
95
|
-
[
|
|
96
|
-
"data.default.cannot_cast",
|
|
97
|
-
"data.explicit_false.cannot_cast"
|
|
98
|
-
]
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
outcome = type.process_value(
|
|
102
|
-
default: 5,
|
|
103
|
-
implicit_true: nil,
|
|
104
|
-
explicit_true: nil,
|
|
105
|
-
explicit_false: 5
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
expect(outcome).to be_success
|
|
109
|
-
expect(outcome.result).to eq(
|
|
110
|
-
default: 5,
|
|
111
|
-
implicit_true: nil,
|
|
112
|
-
explicit_true: nil,
|
|
113
|
-
explicit_false: 5
|
|
114
|
-
)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
context "when registering it" do
|
|
118
|
-
before do
|
|
119
|
-
# TODO: we need a helper to simplify this...
|
|
120
|
-
Foobara::Namespace::NamespaceHelpers.foobara_namespace!(type)
|
|
121
|
-
|
|
122
|
-
type.type_symbol = :some_type
|
|
123
|
-
|
|
124
|
-
expect {
|
|
125
|
-
Foobara::GlobalDomain.foobara_register(type)
|
|
126
|
-
}.to change { Foobara::GlobalDomain.foobara_registered?(type) }.from(false).to(true)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
it "shows up in the manifest" do
|
|
130
|
-
manifest = Foobara.manifest
|
|
131
|
-
|
|
132
|
-
expect(
|
|
133
|
-
manifest[:type][:some_type][:declaration_data][:element_type_declarations][:implicit_true][:allow_nil]
|
|
134
|
-
).to be(true)
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":array" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:array] }
|
|
3
|
-
|
|
4
|
-
it "is a builtin type" do
|
|
5
|
-
expect(Foobara::BuiltinTypes.builtin?(type)).to be(true)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it "is a builtin reference" do
|
|
9
|
-
expect(Foobara::BuiltinTypes.builtin_reference?("array")).to be(true)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#process_value!" do
|
|
13
|
-
subject { type.process_value!(value) }
|
|
14
|
-
|
|
15
|
-
context "when array" do
|
|
16
|
-
let(:value) { [1, 2] }
|
|
17
|
-
|
|
18
|
-
it { is_expected.to eq([1, 2]) }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context "when hash" do
|
|
22
|
-
let(:value) { { a: 1, b: 2 } }
|
|
23
|
-
|
|
24
|
-
it { is_expected.to eq([[:a, 1], [:b, 2]]) }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context "when not castable" do
|
|
28
|
-
let(:value) { Object.new }
|
|
29
|
-
|
|
30
|
-
it {
|
|
31
|
-
is_expected_to_raise(
|
|
32
|
-
Foobara::Value::Processor::Casting::CannotCastError,
|
|
33
|
-
/Expected it to be a Array, or respond to :to_a/
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
describe "#cast!" do
|
|
40
|
-
subject { type.cast!(value) }
|
|
41
|
-
|
|
42
|
-
context "when not castable" do
|
|
43
|
-
let(:value) { Object.new }
|
|
44
|
-
|
|
45
|
-
it {
|
|
46
|
-
is_expected_to_raise(
|
|
47
|
-
Foobara::Value::Processor::Casting::CannotCastError, /Expected it to be a Array, or respond to :to_a/
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context "when using an element_type_declaration" do
|
|
54
|
-
let(:type) { Foobara::Domain.current.foobara_type_from_declaration([:integer]) }
|
|
55
|
-
|
|
56
|
-
context "when element types match the element_type_declaration" do
|
|
57
|
-
let(:array) { [1, 2, 3, 4] }
|
|
58
|
-
|
|
59
|
-
it "can process it" do
|
|
60
|
-
expect(type.process_value!(array)).to eq(array)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
context "when element types do not match the element_type_declaration" do
|
|
65
|
-
let(:array) { [1, 2, { not: :valid }, 4] }
|
|
66
|
-
|
|
67
|
-
it "can process it" do
|
|
68
|
-
outcome = type.process_value(array)
|
|
69
|
-
expect(outcome).to_not be_success
|
|
70
|
-
|
|
71
|
-
expect(outcome.errors_hash).to eq(
|
|
72
|
-
"data.2.cannot_cast" => {
|
|
73
|
-
key: "data.2.cannot_cast",
|
|
74
|
-
path: [2],
|
|
75
|
-
runtime_path: [],
|
|
76
|
-
is_fatal: true,
|
|
77
|
-
category: :data,
|
|
78
|
-
symbol: :cannot_cast,
|
|
79
|
-
message: "At 2: Cannot cast {not: :valid} to an integer. Expected it to be a Integer, " \
|
|
80
|
-
"or be a string of digits optionally with a minus sign in front",
|
|
81
|
-
context: { cast_to: :integer, value: { not: :valid } }
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
expect(type.possible_errors.to_h { |p| [p.key.to_sym, p.error_class] }).to eq(
|
|
86
|
-
"data.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError,
|
|
87
|
-
"data.#.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError
|
|
88
|
-
)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
context "when using a type declaration" do
|
|
94
|
-
let(:type) do
|
|
95
|
-
Foobara::Domain.current.foobara_type_from_declaration(type_declaration)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
context "when extending with an array literal and a description" do
|
|
99
|
-
let(:type_declaration) do
|
|
100
|
-
{ type: [:string], description: "An array of strings", sensitive: true, sensitive_exposed: true }
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "has the description and is an array type as expected" do
|
|
104
|
-
expect(type.extends?(:array)).to be(true)
|
|
105
|
-
expect(type.description).to eq("An array of strings")
|
|
106
|
-
expect(type).to be_sensitive
|
|
107
|
-
expect(type).to be_sensitive_exposed
|
|
108
|
-
expect(type.process_value!([:foo, 1])).to eq(["foo", "1"])
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
context "when element type declaration is a Type" do
|
|
113
|
-
let(:type_declaration) do
|
|
114
|
-
{ type: :array, element_type_declaration: Foobara::BuiltinTypes[:integer] }
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "creates the expected type" do
|
|
118
|
-
s = type.process_value!(["1", "2"])
|
|
119
|
-
expect(s).to eq([1, 2])
|
|
120
|
-
|
|
121
|
-
outcome = type.process_value(["asdf"])
|
|
122
|
-
expect(outcome).to_not be_success
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
context "when using array sugar of a Type" do
|
|
127
|
-
let(:type_declaration) do
|
|
128
|
-
[Foobara::BuiltinTypes[:integer]]
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it "creates the expected type" do
|
|
132
|
-
s = type.process_value!(["1", "2"])
|
|
133
|
-
expect(s).to eq([1, 2])
|
|
134
|
-
|
|
135
|
-
outcome = type.process_value(["asdf"])
|
|
136
|
-
expect(outcome).to_not be_success
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":associative_array" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:associative_array] }
|
|
3
|
-
|
|
4
|
-
describe "#process_value!" do
|
|
5
|
-
subject { type.process_value!(value) }
|
|
6
|
-
|
|
7
|
-
context "when array of pairs" do
|
|
8
|
-
let(:value) { [[:a, 1], [:b, 2]] }
|
|
9
|
-
|
|
10
|
-
it { is_expected.to eq(a: 1, b: 2) }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when hash" do
|
|
14
|
-
let(:value) { { key1 => 1, key2 => 2 } }
|
|
15
|
-
let(:key1) { Object.new }
|
|
16
|
-
let(:key2) { Object.new }
|
|
17
|
-
|
|
18
|
-
it { is_expected.to eq(key1 => 1, key2 => 2) }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context "when not castable" do
|
|
22
|
-
let(:value) { Object.new }
|
|
23
|
-
|
|
24
|
-
it {
|
|
25
|
-
is_expected_to_raise(Foobara::Value::Processor::Casting::CannotCastError,
|
|
26
|
-
/Expected it to be a Hash, or be a an array of pairs/)
|
|
27
|
-
}
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "when there's a key_type_declaration" do
|
|
31
|
-
let(:type) do
|
|
32
|
-
Foobara::Domain.current.foobara_type_from_declaration(
|
|
33
|
-
:associative_array,
|
|
34
|
-
key_type_declaration: :boolean
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe "#types_depended_on" do
|
|
39
|
-
it "includes the key type" do
|
|
40
|
-
expect(type.types_depended_on.map(&:type_symbol)).to include(:boolean)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "when working with stringified values" do
|
|
44
|
-
let(:type) do
|
|
45
|
-
Foobara::Domain.current.foobara_type_from_declaration(
|
|
46
|
-
"type" => "associative_array",
|
|
47
|
-
"key_type_declaration" => "boolean"
|
|
48
|
-
)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "includes the key type" do
|
|
52
|
-
expect(type.types_depended_on.map(&:type_symbol)).to include(:boolean)
|
|
53
|
-
expect(type.declaration_data).to eq(type: :associative_array, key_type_declaration: :boolean)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when key_type_declaration is a Type" do
|
|
58
|
-
let(:type) do
|
|
59
|
-
Foobara::Domain.current.foobara_type_from_declaration(
|
|
60
|
-
:associative_array,
|
|
61
|
-
key_type_declaration: Foobara::BuiltinTypes[:boolean]
|
|
62
|
-
)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "includes the key type" do
|
|
66
|
-
expect(type.types_depended_on.map(&:type_symbol)).to include(:boolean)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context "when it's a deep-duped declaration" do
|
|
71
|
-
let(:type) do
|
|
72
|
-
declaration_data = {
|
|
73
|
-
type: :associative_array,
|
|
74
|
-
key_type_declaration: { type: :boolean }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
declaration = Foobara::TypeDeclaration.new(declaration_data)
|
|
78
|
-
handler = Foobara::Domain.current.foobara_type_builder.type_declaration_handler_for(declaration)
|
|
79
|
-
|
|
80
|
-
declaration = Foobara::TypeDeclaration.new(declaration_data)
|
|
81
|
-
declaration.is_deep_duped = true
|
|
82
|
-
|
|
83
|
-
handler.process_value!(declaration)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "includes the key type" do
|
|
87
|
-
expect(type.types_depended_on.map(&:type_symbol)).to include(:boolean)
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe "#possible_errors" do
|
|
93
|
-
it "contains expected possible errors" do
|
|
94
|
-
expect(type.possible_errors.to_h { |p| [p.key.to_sym, p.error_class] }).to eq(
|
|
95
|
-
"data.#.key.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError,
|
|
96
|
-
"data.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError
|
|
97
|
-
)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context "when keys adhere to type" do
|
|
102
|
-
let(:value) do
|
|
103
|
-
{ y: 1, "FaLsE" => 2 }
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it { is_expected.to eq(true => 1, false => 2) }
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
context "when keys do not adhere" do
|
|
110
|
-
let(:outcome) { type.process_value(value) }
|
|
111
|
-
let(:errors) { outcome.errors }
|
|
112
|
-
|
|
113
|
-
let(:value) { { a: 1, b: 2 } }
|
|
114
|
-
|
|
115
|
-
it "is not success" do
|
|
116
|
-
expect(outcome).to_not be_success
|
|
117
|
-
|
|
118
|
-
expect(errors.size).to eq(2)
|
|
119
|
-
expect(errors.map(&:path)).to contain_exactly([0, :key], [1, :key])
|
|
120
|
-
expect(errors).to all be_a(Foobara::Value::Processor::Casting::CannotCastError)
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
context "when there's a value_type_declaration" do
|
|
126
|
-
let(:type) do
|
|
127
|
-
Foobara::Domain.current.foobara_type_from_declaration(
|
|
128
|
-
:associative_array,
|
|
129
|
-
value_type_declaration: :boolean
|
|
130
|
-
)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
describe "#possible_errors" do
|
|
134
|
-
it "contains expected possible errors" do
|
|
135
|
-
expect(type.possible_errors.to_h { |possible_error|
|
|
136
|
-
[possible_error.key.to_sym, possible_error.error_class]
|
|
137
|
-
}).to eq(
|
|
138
|
-
"data.#.value.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError,
|
|
139
|
-
"data.cannot_cast": Foobara::Value::Processor::Casting::CannotCastError
|
|
140
|
-
)
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
context "when values adhere to type" do
|
|
145
|
-
let(:value) do
|
|
146
|
-
{ a: 1, b: "FalsE" }
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it { is_expected.to eq(a: true, b: false) }
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
context "when values do not adhere" do
|
|
153
|
-
let(:outcome) { type.process_value(value) }
|
|
154
|
-
let(:errors) { outcome.errors }
|
|
155
|
-
|
|
156
|
-
let(:value) { { a: :foo, b: 2 } }
|
|
157
|
-
|
|
158
|
-
it "is not success" do
|
|
159
|
-
expect(outcome).to_not be_success
|
|
160
|
-
|
|
161
|
-
expect(errors.size).to eq(2)
|
|
162
|
-
expect(errors.map(&:path)).to contain_exactly([0, :value], [1, :value])
|
|
163
|
-
expect(errors).to all be_a(Foobara::Value::Processor::Casting::CannotCastError)
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
context "when working with stringified values" do
|
|
168
|
-
let(:type) do
|
|
169
|
-
Foobara::Domain.current.foobara_type_from_declaration(
|
|
170
|
-
"type" => "associative_array",
|
|
171
|
-
"value_type_declaration" => "boolean"
|
|
172
|
-
)
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it "includes the key type" do
|
|
176
|
-
expect(type.types_depended_on.map(&:type_symbol)).to include(:boolean)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
context "when value_type_declaration is a Type" do
|
|
181
|
-
let(:type) do
|
|
182
|
-
Foobara::Domain.current.foobara_type_from_declaration(
|
|
183
|
-
:associative_array,
|
|
184
|
-
value_type_declaration: Foobara::BuiltinTypes[:boolean]
|
|
185
|
-
)
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
it "includes the key type" do
|
|
189
|
-
expect(type.types_depended_on.map(&:type_symbol)).to include(:boolean)
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
context "when it's a deep-duped declaration" do
|
|
194
|
-
let(:type) do
|
|
195
|
-
declaration_data = {
|
|
196
|
-
type: :associative_array,
|
|
197
|
-
value_type_declaration: { type: :boolean }
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
declaration = Foobara::TypeDeclaration.new(declaration_data)
|
|
201
|
-
handler = Foobara::Domain.current.foobara_type_builder.type_declaration_handler_for(declaration)
|
|
202
|
-
|
|
203
|
-
declaration = Foobara::TypeDeclaration.new(declaration_data)
|
|
204
|
-
declaration.is_deep_duped = true
|
|
205
|
-
|
|
206
|
-
handler.process_value!(declaration)
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it "includes the key type" do
|
|
210
|
-
expect(type.types_depended_on.map(&:type_symbol)).to include(:boolean)
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
describe "#cast!" do
|
|
217
|
-
subject { type.cast!(value) }
|
|
218
|
-
|
|
219
|
-
context "when not castable" do
|
|
220
|
-
let(:value) { Object.new }
|
|
221
|
-
|
|
222
|
-
it {
|
|
223
|
-
is_expected_to_raise(Foobara::Value::Processor::Casting::CannotCastError,
|
|
224
|
-
/Expected it to be a Hash, or be a an array of pairs\z/)
|
|
225
|
-
}
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
end
|