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,490 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::BuiltinTypes::Attributes do
|
|
2
|
-
after { Foobara.reset_alls }
|
|
3
|
-
|
|
4
|
-
let(:type) {
|
|
5
|
-
Foobara::Domain.current.foobara_type_from_declaration(type_declaration)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
context "when value is an attributes array" do
|
|
9
|
-
let(:type_declaration) do
|
|
10
|
-
{ foo: :integer, bar: :symbol }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
let(:value_to_process) do
|
|
14
|
-
[["foo", "10"], ["bar", "baz"]]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "constructs created value" do
|
|
18
|
-
value = type.process_value!(value_to_process)
|
|
19
|
-
expect(value).to be_a(Hash)
|
|
20
|
-
expect(value[:foo]).to eq(10)
|
|
21
|
-
expect(value[:bar]).to eq(:baz)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe "when attributes has its own description and element declaration types do as well" do
|
|
26
|
-
let(:type_declaration) do
|
|
27
|
-
{
|
|
28
|
-
type: :attributes,
|
|
29
|
-
element_type_declarations: {
|
|
30
|
-
foo: { type: :integer, description: "foo desc" },
|
|
31
|
-
bar: { type: :string, description: "bar desc" }
|
|
32
|
-
},
|
|
33
|
-
description: "attributes desc"
|
|
34
|
-
}
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "has all the expected descriptions on the correct types" do
|
|
38
|
-
expect(type.description).to eq("attributes desc")
|
|
39
|
-
expect(type.element_types[:foo].description).to eq("foo desc")
|
|
40
|
-
expect(type.element_types[:bar].description).to eq("bar desc")
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
describe "defaults" do
|
|
45
|
-
context "when defaults is not a hash" do
|
|
46
|
-
let(:type_declaration) do
|
|
47
|
-
{
|
|
48
|
-
type: :attributes,
|
|
49
|
-
element_type_declarations: {
|
|
50
|
-
a: :integer
|
|
51
|
-
},
|
|
52
|
-
defaults: [:b, 1]
|
|
53
|
-
}
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "applies defaults when expected and casts where expected" do
|
|
57
|
-
expect {
|
|
58
|
-
type
|
|
59
|
-
}.to raise_error(
|
|
60
|
-
described_class::SupportedTransformers::Defaults::TypeDeclarationExtension::ExtendAttributesTypeDeclaration::
|
|
61
|
-
TypeDeclarationValidators::HashWithSymbolicKeys::InvalidDefaultValuesGivenError
|
|
62
|
-
)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context "when default is a proc" do
|
|
67
|
-
let(:type_declaration) do
|
|
68
|
-
{
|
|
69
|
-
type: :attributes,
|
|
70
|
-
element_type_declarations: {
|
|
71
|
-
a: :integer,
|
|
72
|
-
b: :integer
|
|
73
|
-
},
|
|
74
|
-
defaults: { a: -> { 10 }, b: 100 }
|
|
75
|
-
}
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "applies defaults and scrubs the value in the manifest data" do
|
|
79
|
-
expect(type.process_value!({})).to eq(a: 10, b: 100)
|
|
80
|
-
|
|
81
|
-
Foobara::GlobalDomain.foobara_register_type(:some_type, type)
|
|
82
|
-
expect(type.foobara_manifest[:declaration_data][:defaults]).to eq(a: "[<Lazily Set>]", b: 100)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context "when defaults contains invalid attribute names" do
|
|
87
|
-
let(:type_declaration) do
|
|
88
|
-
{
|
|
89
|
-
type: :attributes,
|
|
90
|
-
element_type_declarations: {
|
|
91
|
-
a: :integer
|
|
92
|
-
},
|
|
93
|
-
defaults: {
|
|
94
|
-
b: 1
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it "applies defaults when expected and casts where expected" do
|
|
100
|
-
expect {
|
|
101
|
-
type
|
|
102
|
-
}.to raise_error(
|
|
103
|
-
described_class::SupportedTransformers::Defaults::TypeDeclarationExtension::ExtendAttributesTypeDeclaration::
|
|
104
|
-
TypeDeclarationValidators::ValidAttributeNames::InvalidDefaultValueGivenError
|
|
105
|
-
)
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
context "when type_declaration has top-level defaults hash" do
|
|
110
|
-
let(:type_declaration) do
|
|
111
|
-
{
|
|
112
|
-
type: :attributes,
|
|
113
|
-
element_type_declarations: {
|
|
114
|
-
a: :integer,
|
|
115
|
-
b: :integer,
|
|
116
|
-
c: :integer
|
|
117
|
-
},
|
|
118
|
-
defaults: {
|
|
119
|
-
"b" => 1,
|
|
120
|
-
c: "2"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it "applies defaults when expected and casts where expected" do
|
|
126
|
-
attributes = type.process_value!(a: 100, b: 200, c: "300")
|
|
127
|
-
expect(attributes).to eq(a: 100, b: 200, c: 300)
|
|
128
|
-
|
|
129
|
-
attributes = type.process_value!(a: 100, c: "300")
|
|
130
|
-
expect(attributes).to eq(a: 100, b: 1, c: 300)
|
|
131
|
-
|
|
132
|
-
attributes = type.process_value!(a: 100)
|
|
133
|
-
expect(attributes).to eq(a: 100, b: 1, c: 2)
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
context "when type_declaration is a dsl proc" do
|
|
138
|
-
let(:type_declaration) do
|
|
139
|
-
proc do
|
|
140
|
-
a :integer
|
|
141
|
-
b :integer, default: 1
|
|
142
|
-
c :integer, default: "2"
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "works just like a hash declaration of the same type" do
|
|
147
|
-
attributes = type.process_value!(a: 100, b: 200, c: "300")
|
|
148
|
-
expect(attributes).to eq(a: 100, b: 200, c: 300)
|
|
149
|
-
|
|
150
|
-
attributes = type.process_value!(a: 100, c: "300")
|
|
151
|
-
expect(attributes).to eq(a: 100, b: 1, c: 300)
|
|
152
|
-
|
|
153
|
-
attributes = type.process_value!(a: 100)
|
|
154
|
-
expect(attributes).to eq(a: 100, b: 1, c: 2)
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
context "when type_declaration specifies defaults on a per-attribute level" do
|
|
159
|
-
let(:type_declaration) do
|
|
160
|
-
{
|
|
161
|
-
type: :attributes,
|
|
162
|
-
element_type_declarations: {
|
|
163
|
-
a: { type: :integer },
|
|
164
|
-
b: { type: :integer, default: 1 },
|
|
165
|
-
c: { type: :integer, default: "2" }
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it "applies defaults when expected" do
|
|
171
|
-
attributes = type.process_value!(a: 100, b: 200, c: "300")
|
|
172
|
-
expect(attributes).to eq(a: 100, b: 200, c: 300)
|
|
173
|
-
|
|
174
|
-
attributes = type.process_value!(a: 100, c: "300")
|
|
175
|
-
expect(attributes).to eq(a: 100, b: 1, c: 300)
|
|
176
|
-
|
|
177
|
-
attributes = type.process_value!(a: 100)
|
|
178
|
-
expect(attributes).to eq(a: 100, b: 1, c: 2)
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
context "when attribute is present but is nil" do
|
|
183
|
-
subject { type.process_value!(foo: "foo", bar: nil)[:bar] }
|
|
184
|
-
|
|
185
|
-
let(:type_declaration) do
|
|
186
|
-
{
|
|
187
|
-
type: :attributes,
|
|
188
|
-
element_type_declarations: {
|
|
189
|
-
foo: { type: :string },
|
|
190
|
-
bar: { type: :string, allow_nil:, default: "baz" }
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
end
|
|
194
|
-
let(:allow_nil) { false }
|
|
195
|
-
|
|
196
|
-
it { is_expected.to eq("baz") }
|
|
197
|
-
|
|
198
|
-
context "when attribute is marked as allow_nil => true" do
|
|
199
|
-
let(:allow_nil) { true }
|
|
200
|
-
|
|
201
|
-
it { is_expected.to be_nil }
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
describe "required attributes" do
|
|
207
|
-
context "when all strings" do
|
|
208
|
-
let(:type_declaration) do
|
|
209
|
-
{
|
|
210
|
-
"type" => "attributes",
|
|
211
|
-
"element_type_declarations" => {
|
|
212
|
-
"a" => { "type" => "integer" },
|
|
213
|
-
"b" => { "type" => "integer" }
|
|
214
|
-
},
|
|
215
|
-
"required" => ["a"]
|
|
216
|
-
}
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
it "still works" do
|
|
220
|
-
expect(type.process_value!(a: 1)).to eq(a: 1)
|
|
221
|
-
expect {
|
|
222
|
-
type.process_value!(b: 1)
|
|
223
|
-
}.to raise_error(
|
|
224
|
-
Foobara::BuiltinTypes::Attributes::SupportedValidators::Required::MissingRequiredAttributeError
|
|
225
|
-
) do |e|
|
|
226
|
-
expect(e.context[:attribute_name]).to eq(:a)
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
context "when required is not an array of symbols" do
|
|
232
|
-
let(:type_declaration) do
|
|
233
|
-
{
|
|
234
|
-
type: :attributes,
|
|
235
|
-
element_type_declarations: {
|
|
236
|
-
a: :integer,
|
|
237
|
-
b: :integer,
|
|
238
|
-
c: :integer
|
|
239
|
-
},
|
|
240
|
-
required: { a: 1 }
|
|
241
|
-
}
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
it "explodes" do
|
|
245
|
-
expect {
|
|
246
|
-
type
|
|
247
|
-
}.to raise_error(
|
|
248
|
-
Foobara::BuiltinTypes::Attributes::SupportedValidators::Required::TypeDeclarationExtension::
|
|
249
|
-
ExtendAttributesTypeDeclaration::TypeDeclarationValidators::ArrayOfSymbols::
|
|
250
|
-
InvalidRequiredAttributesValuesGivenError
|
|
251
|
-
)
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
context "when required contains an invalid attribute name" do
|
|
256
|
-
let(:type_declaration) do
|
|
257
|
-
{
|
|
258
|
-
type: :attributes,
|
|
259
|
-
element_type_declarations: {
|
|
260
|
-
a: :integer,
|
|
261
|
-
b: :integer,
|
|
262
|
-
c: :integer
|
|
263
|
-
},
|
|
264
|
-
required: [:a, :d]
|
|
265
|
-
}
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
it "explodes" do
|
|
269
|
-
expect {
|
|
270
|
-
type
|
|
271
|
-
}.to raise_error(
|
|
272
|
-
Foobara::BuiltinTypes::Attributes::SupportedValidators::Required::TypeDeclarationExtension::
|
|
273
|
-
ExtendAttributesTypeDeclaration::TypeDeclarationValidators::ArrayWithValidAttributeNames::
|
|
274
|
-
InvalidRequiredAttributeNameGivenError,
|
|
275
|
-
/\bd\b/
|
|
276
|
-
)
|
|
277
|
-
end
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
context "when type_declaration has top-level required array" do
|
|
281
|
-
let(:type_declaration) do
|
|
282
|
-
{
|
|
283
|
-
type: :attributes,
|
|
284
|
-
element_type_declarations: {
|
|
285
|
-
a: :integer,
|
|
286
|
-
b: :integer,
|
|
287
|
-
c: :integer
|
|
288
|
-
},
|
|
289
|
-
required: [:a, :c]
|
|
290
|
-
}
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
it "gives errors when required fields missing" do
|
|
294
|
-
outcome = type.process_value(a: 100, b: 200, c: "300")
|
|
295
|
-
expect(outcome).to be_success
|
|
296
|
-
|
|
297
|
-
outcome = type.process_value(a: 100, c: "300")
|
|
298
|
-
expect(outcome).to be_success
|
|
299
|
-
|
|
300
|
-
outcome = type.process_value(b: 100, c: "300")
|
|
301
|
-
expect(outcome).to_not be_success
|
|
302
|
-
expect(outcome.errors.map { |e| [e.attribute_name, e.symbol] }).to eq([
|
|
303
|
-
[
|
|
304
|
-
:a, :missing_required_attribute
|
|
305
|
-
]
|
|
306
|
-
])
|
|
307
|
-
|
|
308
|
-
outcome = type.process_value(b: 100)
|
|
309
|
-
expect(outcome).to_not be_success
|
|
310
|
-
expect(outcome.errors.map { |e| [e.attribute_name, e.symbol] }).to eq([
|
|
311
|
-
[
|
|
312
|
-
:a, :missing_required_attribute
|
|
313
|
-
],
|
|
314
|
-
[:c,
|
|
315
|
-
:missing_required_attribute]
|
|
316
|
-
])
|
|
317
|
-
|
|
318
|
-
outcome = type.process_value({})
|
|
319
|
-
expect(outcome).to_not be_success
|
|
320
|
-
expect(outcome.errors.map { |e| [e.attribute_name, e.symbol] }).to eq([
|
|
321
|
-
[
|
|
322
|
-
:a, :missing_required_attribute
|
|
323
|
-
],
|
|
324
|
-
[:c,
|
|
325
|
-
:missing_required_attribute]
|
|
326
|
-
])
|
|
327
|
-
end
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
context "when type_declaration has per-attribute required flag" do
|
|
331
|
-
let(:type_declaration) do
|
|
332
|
-
{
|
|
333
|
-
type: :attributes,
|
|
334
|
-
element_type_declarations: {
|
|
335
|
-
a: { type: :integer, required: true },
|
|
336
|
-
b: { type: :integer, required: false },
|
|
337
|
-
c: { type: :integer, required: true }
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
it "gives errors when required fields missing" do
|
|
343
|
-
outcome = type.process_value(a: 100, b: 200, c: "300")
|
|
344
|
-
expect(outcome).to be_success
|
|
345
|
-
|
|
346
|
-
outcome = type.process_value(a: 100, c: "300")
|
|
347
|
-
expect(outcome).to be_success
|
|
348
|
-
|
|
349
|
-
outcome = type.process_value(b: 100, c: "300")
|
|
350
|
-
expect(outcome).to_not be_success
|
|
351
|
-
expect(outcome.errors.map { |e| [e.attribute_name, e.symbol] }).to eq([
|
|
352
|
-
[
|
|
353
|
-
:a, :missing_required_attribute
|
|
354
|
-
]
|
|
355
|
-
])
|
|
356
|
-
|
|
357
|
-
outcome = type.process_value(b: 100)
|
|
358
|
-
expect(outcome).to_not be_success
|
|
359
|
-
expect(outcome.errors.map { |e| [e.attribute_name, e.symbol] }).to eq([
|
|
360
|
-
[
|
|
361
|
-
:a, :missing_required_attribute
|
|
362
|
-
],
|
|
363
|
-
[:c,
|
|
364
|
-
:missing_required_attribute]
|
|
365
|
-
])
|
|
366
|
-
|
|
367
|
-
outcome = type.process_value({})
|
|
368
|
-
expect(outcome).to_not be_success
|
|
369
|
-
expect(outcome.errors.map { |e| [e.attribute_name, e.symbol] }).to eq([
|
|
370
|
-
[
|
|
371
|
-
:a, :missing_required_attribute
|
|
372
|
-
],
|
|
373
|
-
[:c,
|
|
374
|
-
:missing_required_attribute]
|
|
375
|
-
])
|
|
376
|
-
end
|
|
377
|
-
end
|
|
378
|
-
end
|
|
379
|
-
|
|
380
|
-
describe "using :attributes directly as a type to match any hash with symbolizable keys" do
|
|
381
|
-
let(:attributes) do
|
|
382
|
-
{
|
|
383
|
-
foo: "foo",
|
|
384
|
-
bar: 10,
|
|
385
|
-
"baz" => :baz
|
|
386
|
-
}
|
|
387
|
-
end
|
|
388
|
-
|
|
389
|
-
let(:type) { Foobara::BuiltinTypes[:attributes] }
|
|
390
|
-
|
|
391
|
-
describe "#process_value" do
|
|
392
|
-
it "successfully casts and returns it" do
|
|
393
|
-
outcome = type.process_value(attributes)
|
|
394
|
-
expect(outcome).to be_success
|
|
395
|
-
expect(outcome.result).to eq(
|
|
396
|
-
foo: "foo",
|
|
397
|
-
bar: 10,
|
|
398
|
-
baz: :baz
|
|
399
|
-
)
|
|
400
|
-
end
|
|
401
|
-
|
|
402
|
-
context "when using :attributes as an attributes type" do
|
|
403
|
-
let(:type) do
|
|
404
|
-
Foobara::Domain.current.foobara_type_from_declaration do
|
|
405
|
-
foo :attributes, :required
|
|
406
|
-
bar :integer, :required
|
|
407
|
-
baz :symbol, :required
|
|
408
|
-
end
|
|
409
|
-
end
|
|
410
|
-
|
|
411
|
-
let(:attributes) do
|
|
412
|
-
{
|
|
413
|
-
foo: {
|
|
414
|
-
foo: "foo",
|
|
415
|
-
bar: 10,
|
|
416
|
-
"baz" => :baz
|
|
417
|
-
},
|
|
418
|
-
bar: "10",
|
|
419
|
-
baz: "baz"
|
|
420
|
-
}
|
|
421
|
-
end
|
|
422
|
-
|
|
423
|
-
it "can cast it" do
|
|
424
|
-
outcome = type.process_value(attributes)
|
|
425
|
-
expect(outcome).to be_success
|
|
426
|
-
expect(outcome.result).to eq(
|
|
427
|
-
foo: {
|
|
428
|
-
foo: "foo",
|
|
429
|
-
bar: 10,
|
|
430
|
-
baz: :baz
|
|
431
|
-
},
|
|
432
|
-
bar: 10,
|
|
433
|
-
baz: :baz
|
|
434
|
-
)
|
|
435
|
-
end
|
|
436
|
-
|
|
437
|
-
context "with allow_nil" do
|
|
438
|
-
let(:type) do
|
|
439
|
-
Foobara::Domain.current.foobara_type_from_declaration(:attributes, :allow_nil)
|
|
440
|
-
end
|
|
441
|
-
|
|
442
|
-
context "when not nil" do
|
|
443
|
-
let(:attributes) do
|
|
444
|
-
{
|
|
445
|
-
foo: "foo",
|
|
446
|
-
bar: 10,
|
|
447
|
-
"baz" => :baz
|
|
448
|
-
}
|
|
449
|
-
end
|
|
450
|
-
|
|
451
|
-
it "can cast it" do
|
|
452
|
-
outcome = type.process_value(attributes)
|
|
453
|
-
expect(outcome).to be_success
|
|
454
|
-
expect(outcome.result).to eq(
|
|
455
|
-
foo: "foo",
|
|
456
|
-
bar: 10,
|
|
457
|
-
baz: :baz
|
|
458
|
-
)
|
|
459
|
-
end
|
|
460
|
-
end
|
|
461
|
-
|
|
462
|
-
context "when nil" do
|
|
463
|
-
let(:attributes) { nil }
|
|
464
|
-
|
|
465
|
-
it "can cast it" do
|
|
466
|
-
outcome = type.process_value(attributes)
|
|
467
|
-
expect(outcome).to be_success
|
|
468
|
-
expect(outcome.result).to be_nil
|
|
469
|
-
end
|
|
470
|
-
end
|
|
471
|
-
end
|
|
472
|
-
end
|
|
473
|
-
end
|
|
474
|
-
end
|
|
475
|
-
|
|
476
|
-
describe "ignore_unexpected_attributes" do
|
|
477
|
-
let(:type) do
|
|
478
|
-
Foobara::Domain.current.foobara_type_from_declaration :ignore_unexpected_attributes do
|
|
479
|
-
a :integer, :required
|
|
480
|
-
b :string
|
|
481
|
-
end
|
|
482
|
-
end
|
|
483
|
-
|
|
484
|
-
it "excludes unexpected attributes" do
|
|
485
|
-
h = { a: "1", b: "2", c: "3" }
|
|
486
|
-
|
|
487
|
-
expect(type.process_value!(h)).to eq(a: 1, b: "2")
|
|
488
|
-
end
|
|
489
|
-
end
|
|
490
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":big_decimal" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:big_decimal] }
|
|
3
|
-
|
|
4
|
-
describe "#process!" do
|
|
5
|
-
subject { type.process_value!(value) }
|
|
6
|
-
|
|
7
|
-
def is_expected_to_be_big_decimal_for(i_or_s)
|
|
8
|
-
expect(subject).to be_a(BigDecimal)
|
|
9
|
-
expect(subject).to eq(BigDecimal(i_or_s))
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context "when ::BigDecimal" do
|
|
13
|
-
let(:value) { BigDecimal(10) }
|
|
14
|
-
|
|
15
|
-
it { is_expected.to be(value) }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when ::Integer" do
|
|
19
|
-
let(:value) { 10 }
|
|
20
|
-
|
|
21
|
-
it { is_expected_to_be_big_decimal_for(10) }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "when '1.3'" do
|
|
25
|
-
let(:value) { "1.3" }
|
|
26
|
-
|
|
27
|
-
it { is_expected_to_be_big_decimal_for("1.3") }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "when '-1.3E-5'" do
|
|
31
|
-
let(:value) { "-1.3E-5" }
|
|
32
|
-
|
|
33
|
-
it { is_expected_to_be_big_decimal_for("-0.000013") }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context "when not castable" do
|
|
37
|
-
let(:value) { "notcastable" }
|
|
38
|
-
|
|
39
|
-
it { is_expected_to_raise(Foobara::Value::Processor::Casting::CannotCastError) }
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":boolean" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:boolean] }
|
|
3
|
-
|
|
4
|
-
describe "#process!" do
|
|
5
|
-
subject { type.process_value!(value) }
|
|
6
|
-
|
|
7
|
-
context "when true" do
|
|
8
|
-
let(:value) { true }
|
|
9
|
-
|
|
10
|
-
it { is_expected.to be(value) }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when false" do
|
|
14
|
-
let(:value) { false }
|
|
15
|
-
|
|
16
|
-
it { is_expected.to be(value) }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "when 'T'" do
|
|
20
|
-
let(:value) { "T" }
|
|
21
|
-
|
|
22
|
-
it { is_expected.to be(true) }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context "when 0" do
|
|
26
|
-
let(:value) { 0 }
|
|
27
|
-
|
|
28
|
-
it { is_expected.to be(false) }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "when 'n'" do
|
|
32
|
-
let(:value) { "n" }
|
|
33
|
-
|
|
34
|
-
it { is_expected.to be(false) }
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
context "when not castable" do
|
|
38
|
-
let(:value) { "notcastable" }
|
|
39
|
-
|
|
40
|
-
it { is_expected_to_raise(Foobara::Value::Processor::Casting::CannotCastError) }
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
RSpec.describe "ClassTypeDesugarizer" do
|
|
2
|
-
context "when using Class as a type" do
|
|
3
|
-
let(:some_class) do
|
|
4
|
-
stub_class("SomeClass")
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
let(:type) do
|
|
8
|
-
Foobara::Domain.current.foobara_type_from_declaration(type: some_class, allow_nil: true)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "desugarizes to :duck with :instance_of" do
|
|
12
|
-
expect(type.declaration_data).to eq(type: :duck, instance_of: "SomeClass", allow_nil: true)
|
|
13
|
-
expect(type.process_value!(some_class.new)).to be_a(some_class)
|
|
14
|
-
expect(type.process_value!(nil)).to be_nil
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|