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,430 +0,0 @@
|
|
|
1
|
-
RSpec.describe "custom types" do
|
|
2
|
-
context "when defining a custom complex type" do
|
|
3
|
-
after do
|
|
4
|
-
Foobara.reset_alls
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
let(:complex_class) do
|
|
8
|
-
stub_class :CustomComplex do
|
|
9
|
-
attr_accessor :real, :imaginary
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
let(:type_declaration) do
|
|
14
|
-
{
|
|
15
|
-
type: :attributes,
|
|
16
|
-
element_type_declarations: {
|
|
17
|
-
n: :integer,
|
|
18
|
-
# not entirely complex since we only support integers for the components for now but whatever
|
|
19
|
-
c: { type: :custom_complex, be_pointless: :true_symbol }
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
end
|
|
23
|
-
let(:type) { type_builder.type_for_declaration(type_declaration) }
|
|
24
|
-
|
|
25
|
-
let(:type_declaration_handler) { type_builder.type_declaration_handler_for(type_declaration) }
|
|
26
|
-
let(:type_declaration_handler_class) do
|
|
27
|
-
custom_caster = array_to_complex_caster.new
|
|
28
|
-
klass = complex_class
|
|
29
|
-
|
|
30
|
-
pointless = pointless_validator
|
|
31
|
-
|
|
32
|
-
stub_class :ComplexTypeDeclarationHandler, Foobara::TypeDeclarations::TypeDeclarationHandler do
|
|
33
|
-
class << self
|
|
34
|
-
def sugar_for_complex?(sugary_type_declaration)
|
|
35
|
-
sugary_type_declaration = sugary_type_declaration.declaration_data
|
|
36
|
-
|
|
37
|
-
if sugary_type_declaration.is_a?(Symbol)
|
|
38
|
-
sugary_type_declaration = sugary_type_declaration.to_s
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
if sugary_type_declaration.is_a?(String)
|
|
42
|
-
@complex_form_regex ||= /\A([a-z])\s*\+\s*(?!\1)([a-z])i\z/
|
|
43
|
-
|
|
44
|
-
@complex_form_regex.match?(sugary_type_declaration)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def applicable?(sugary_type_declaration)
|
|
50
|
-
(sugary_type_declaration.hash? && sugary_type_declaration[:type] == :custom_complex) ||
|
|
51
|
-
sugar_for_complex?(sugary_type_declaration)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
define_method :desugarizers do
|
|
55
|
-
[
|
|
56
|
-
ComplexTypeDeclarationHandler::SomeDesugarizer.instance
|
|
57
|
-
]
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def sugar_for_complex?(sugary_type_declaration)
|
|
61
|
-
self.class.sugar_for_complex?(sugary_type_declaration)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
stub_class "ComplexTypeDeclarationHandler::SomeDesugarizer", Foobara::TypeDeclarations::Desugarizer do
|
|
66
|
-
def applicable?(value)
|
|
67
|
-
ComplexTypeDeclarationHandler.sugar_for_complex?(value)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def desugarize(_value)
|
|
71
|
-
declaration = Foobara::TypeDeclaration.new(type: :custom_complex)
|
|
72
|
-
|
|
73
|
-
declaration.is_strict = true
|
|
74
|
-
declaration.is_duped = true
|
|
75
|
-
declaration.is_deep_duped = true
|
|
76
|
-
|
|
77
|
-
declaration
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
stub_class "ComplexTypeDeclarationHandler::ToTypeTransformer", Foobara::TypeDeclarations::ToTypeTransformer do
|
|
82
|
-
define_method :transform do |strict_type_declaration|
|
|
83
|
-
be_pointless = strict_type_declaration[:be_pointless]
|
|
84
|
-
|
|
85
|
-
validators = be_pointless ? [pointless.new(be_pointless)] : []
|
|
86
|
-
|
|
87
|
-
type = Foobara::Types::Type.new(
|
|
88
|
-
strict_type_declaration,
|
|
89
|
-
base_type: Foobara::Namespace.global.foobara_lookup_type!(:number),
|
|
90
|
-
name: :custom_complex,
|
|
91
|
-
transformers: [],
|
|
92
|
-
validators:,
|
|
93
|
-
element_processors: nil,
|
|
94
|
-
target_classes: klass
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
type.add_caster(custom_caster)
|
|
98
|
-
|
|
99
|
-
type
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
ComplexTypeDeclarationHandler
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
let(:array_to_complex_caster) do
|
|
107
|
-
klass = complex_class
|
|
108
|
-
|
|
109
|
-
stub_class :SomeCaster, Foobara::Value::Caster do
|
|
110
|
-
def applicable?(value)
|
|
111
|
-
value.is_a?(Array) && value.size == 2
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
define_method :cast do |(real, imaginary)|
|
|
115
|
-
complex = klass.new
|
|
116
|
-
|
|
117
|
-
complex.real = real
|
|
118
|
-
complex.imaginary = imaginary
|
|
119
|
-
|
|
120
|
-
complex
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
let(:pointless_validator) do
|
|
126
|
-
stub_class :PointlessValidator, Foobara::Value::Validator do
|
|
127
|
-
class << self
|
|
128
|
-
def symbol
|
|
129
|
-
:be_pointless
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def be_pointless
|
|
134
|
-
declaration_data
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def validation_errors(complex)
|
|
138
|
-
# :nocov:
|
|
139
|
-
return unless be_pointless == :true_symbol
|
|
140
|
-
|
|
141
|
-
# :nocov:
|
|
142
|
-
|
|
143
|
-
if complex.real == complex.imaginary
|
|
144
|
-
build_error
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
stub_class "PointlessValidator::Error", Foobara::Value::DataError do
|
|
150
|
-
message "cant be the same!"
|
|
151
|
-
context foo: :symbol
|
|
152
|
-
symbol :real_should_not_match_imaginary
|
|
153
|
-
|
|
154
|
-
class << self
|
|
155
|
-
def context
|
|
156
|
-
{ foo: :bar }
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
PointlessValidator
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
let(:domain) do
|
|
165
|
-
stub_module :CustomTypeSpec do
|
|
166
|
-
foobara_domain!
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
let(:type_builder) do
|
|
171
|
-
domain.foobara_type_builder
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def in_namespace(&)
|
|
175
|
-
Foobara::Namespace.use(domain, &)
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
before do
|
|
179
|
-
type_builder.register_type_declaration_handler(type_declaration_handler_class.new)
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
context "when type declaration invalid" do
|
|
183
|
-
let(:type_declaration) do
|
|
184
|
-
:"x + yi"
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
let(:type_declaration_handler) { type_declaration_handler_class.new }
|
|
188
|
-
let(:type_declaration_validator_class) {
|
|
189
|
-
stub_class :WhateverValidator, Foobara::TypeDeclarations::TypeDeclarationValidator do
|
|
190
|
-
def validation_errors(_value)
|
|
191
|
-
[build_error]
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
def error_context(_value)
|
|
195
|
-
{ foo: :bar }
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
stub_class "WhateverValidator::WhateverError", Foobara::Value::DataError do
|
|
200
|
-
class << self
|
|
201
|
-
def message
|
|
202
|
-
"whatevs!"
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
def context_type_declaration
|
|
206
|
-
{ foo: :symbol }
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
WhateverValidator
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
before do
|
|
215
|
-
validator = type_declaration_validator_class.instance
|
|
216
|
-
ComplexTypeDeclarationHandler.define_method :type_declaration_validators do
|
|
217
|
-
[validator]
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it "cannot get a type from the type declaration handler" do
|
|
222
|
-
outcome = type_declaration_handler.process_value(Foobara::TypeDeclaration.new(type_declaration))
|
|
223
|
-
|
|
224
|
-
expect(outcome).to_not be_success
|
|
225
|
-
|
|
226
|
-
# TODO: why isn't errors an error collection??
|
|
227
|
-
expect(outcome.errors_hash).to eq(
|
|
228
|
-
"data.whatever" => {
|
|
229
|
-
category: :data,
|
|
230
|
-
key: "data.whatever",
|
|
231
|
-
path: [],
|
|
232
|
-
runtime_path: [],
|
|
233
|
-
is_fatal: false,
|
|
234
|
-
context: { foo: :bar },
|
|
235
|
-
message: "whatevs!",
|
|
236
|
-
symbol: :whatever
|
|
237
|
-
}
|
|
238
|
-
)
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
context "when using the type against valid data from complex type non sugar type declaration" do
|
|
243
|
-
around do |example|
|
|
244
|
-
in_namespace { example.run }
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
before do
|
|
248
|
-
type.register_supported_processor_class(pointless_validator)
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
context "when valid" do
|
|
252
|
-
it "can process the thing" do
|
|
253
|
-
value = type.process_value!(n: 5, c: [1, 2])
|
|
254
|
-
|
|
255
|
-
complex = value[:c]
|
|
256
|
-
|
|
257
|
-
expect(complex).to be_a(complex_class)
|
|
258
|
-
expect(complex.real).to eq(1)
|
|
259
|
-
expect(complex.imaginary).to eq(2)
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
describe "#remove_processor_by_symbol" do
|
|
263
|
-
it "removes all processors with the given symbol" do
|
|
264
|
-
expect(type.processors.last.processors.map(&:symbol)).to include(:element_type_declarations)
|
|
265
|
-
expect(type.element_processors.map(&:symbol)).to include(:element_type_declarations)
|
|
266
|
-
|
|
267
|
-
type.remove_processor_by_symbol(:element_type_declarations)
|
|
268
|
-
|
|
269
|
-
expect(type.processors.last.processors.map(&:symbol)).to_not include(:element_type_declarations)
|
|
270
|
-
expect(type.element_processors.map(&:symbol)).to_not include(:element_type_declarations)
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
context "when invalid" do
|
|
276
|
-
it "can process the thing" do
|
|
277
|
-
outcome = in_namespace { type.process_value(n: 5, c: [2, 2]) }
|
|
278
|
-
|
|
279
|
-
expect(outcome).to_not be_success
|
|
280
|
-
errors = outcome.errors
|
|
281
|
-
|
|
282
|
-
expect(errors.size).to eq(1)
|
|
283
|
-
error = errors.first
|
|
284
|
-
expect(error.to_h).to eq(
|
|
285
|
-
category: :data,
|
|
286
|
-
key: "data.c.real_should_not_match_imaginary",
|
|
287
|
-
path: [:c],
|
|
288
|
-
runtime_path: [],
|
|
289
|
-
is_fatal: false,
|
|
290
|
-
symbol: :real_should_not_match_imaginary,
|
|
291
|
-
context: { foo: :bar },
|
|
292
|
-
message: "cant be the same!"
|
|
293
|
-
)
|
|
294
|
-
end
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
context "when using the type against valid data from complex type sugar type declaration" do
|
|
299
|
-
let(:type_declaration) do
|
|
300
|
-
{
|
|
301
|
-
type: :attributes,
|
|
302
|
-
element_type_declarations: {
|
|
303
|
-
n: :integer,
|
|
304
|
-
c: :"x + yi"
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
context "when valid" do
|
|
310
|
-
around do |example|
|
|
311
|
-
in_namespace { example.run }
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
it "can process the thing" do
|
|
315
|
-
value = type.process_value!(n: 5, c: [1, 2])
|
|
316
|
-
complex = value[:c]
|
|
317
|
-
|
|
318
|
-
expect(complex).to be_a(complex_class)
|
|
319
|
-
expect(complex.real).to eq(1)
|
|
320
|
-
expect(complex.imaginary).to eq(2)
|
|
321
|
-
end
|
|
322
|
-
end
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
context "when registering type" do
|
|
326
|
-
describe "#type_for_declaration" do
|
|
327
|
-
context "when not registered" do
|
|
328
|
-
it "raises" do
|
|
329
|
-
expect {
|
|
330
|
-
type_builder.type_for_declaration(:custom_complex)
|
|
331
|
-
}.to raise_error(Foobara::TypeDeclarations::TypeBuilder::NoTypeDeclarationHandlerFoundError)
|
|
332
|
-
end
|
|
333
|
-
end
|
|
334
|
-
|
|
335
|
-
context "when registered" do
|
|
336
|
-
let(:type_declaration_handler) { type_declaration_handler_class.new }
|
|
337
|
-
let(:type) do
|
|
338
|
-
type_declaration_handler.process_value!(
|
|
339
|
-
Foobara::TypeDeclaration.new(type: :custom_complex, be_pointless: :true_symbol)
|
|
340
|
-
)
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
before do
|
|
344
|
-
# TODO: make this less awkward...
|
|
345
|
-
type.type_symbol = :custom_complex
|
|
346
|
-
Foobara::GlobalDomain.foobara_register(type)
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
it "gives the complex type for the complex symbol" do
|
|
350
|
-
expect(type_builder.type_for_declaration(:custom_complex)).to be(type)
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
it "can cast if needed" do
|
|
354
|
-
# TODO: this is very confusing.
|
|
355
|
-
# Maybe call this complex type? Too much nested behavior being tested in this test.
|
|
356
|
-
outcome = type.cast([100, 200])
|
|
357
|
-
|
|
358
|
-
expect(outcome).to be_success
|
|
359
|
-
value = outcome.result
|
|
360
|
-
expect(value.real).to eq(100)
|
|
361
|
-
expect(value.imaginary).to eq(200)
|
|
362
|
-
end
|
|
363
|
-
|
|
364
|
-
it "can give validation_errors if needed" do
|
|
365
|
-
errors = type.validation_errors([-40, -40])
|
|
366
|
-
expect(Foobara::ErrorCollection.to_h(errors)).to eq(
|
|
367
|
-
"data.real_should_not_match_imaginary" => {
|
|
368
|
-
key: "data.real_should_not_match_imaginary",
|
|
369
|
-
path: [],
|
|
370
|
-
runtime_path: [],
|
|
371
|
-
is_fatal: false,
|
|
372
|
-
category: :data,
|
|
373
|
-
symbol: :real_should_not_match_imaginary,
|
|
374
|
-
message: "cant be the same!",
|
|
375
|
-
context: { foo: :bar }
|
|
376
|
-
}
|
|
377
|
-
)
|
|
378
|
-
end
|
|
379
|
-
|
|
380
|
-
context "with a transformer" do
|
|
381
|
-
let(:transformer_class) do
|
|
382
|
-
stub_class :SomeTransformer, Foobara::TypeDeclarations::Transformer do
|
|
383
|
-
def always_applicable?
|
|
384
|
-
true
|
|
385
|
-
end
|
|
386
|
-
|
|
387
|
-
def transform(value)
|
|
388
|
-
value
|
|
389
|
-
end
|
|
390
|
-
end
|
|
391
|
-
end
|
|
392
|
-
|
|
393
|
-
let(:transformer) { transformer_class.instance }
|
|
394
|
-
|
|
395
|
-
before do
|
|
396
|
-
type.transformers << transformer
|
|
397
|
-
end
|
|
398
|
-
|
|
399
|
-
it "can give validation_errors if needed" do
|
|
400
|
-
errors = type.validation_errors([-40, -40])
|
|
401
|
-
|
|
402
|
-
expect(Foobara::ErrorCollection.to_h(errors)).to eq(
|
|
403
|
-
"data.real_should_not_match_imaginary" => {
|
|
404
|
-
key: "data.real_should_not_match_imaginary",
|
|
405
|
-
path: [],
|
|
406
|
-
runtime_path: [],
|
|
407
|
-
is_fatal: false,
|
|
408
|
-
category: :data,
|
|
409
|
-
symbol: :real_should_not_match_imaginary,
|
|
410
|
-
message: "cant be the same!",
|
|
411
|
-
context: { foo: :bar }
|
|
412
|
-
}
|
|
413
|
-
)
|
|
414
|
-
end
|
|
415
|
-
|
|
416
|
-
context "when no errors" do
|
|
417
|
-
before do
|
|
418
|
-
type.validators = []
|
|
419
|
-
end
|
|
420
|
-
|
|
421
|
-
it "is empty" do
|
|
422
|
-
expect(type.validation_errors([2, -40])).to eq([])
|
|
423
|
-
end
|
|
424
|
-
end
|
|
425
|
-
end
|
|
426
|
-
end
|
|
427
|
-
end
|
|
428
|
-
end
|
|
429
|
-
end
|
|
430
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":date" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:date] }
|
|
3
|
-
|
|
4
|
-
describe "#process!" do
|
|
5
|
-
subject { type.process_value!(value) }
|
|
6
|
-
|
|
7
|
-
context "when ::Date" do
|
|
8
|
-
let(:value) { Date.new(2020, 1, 2) }
|
|
9
|
-
|
|
10
|
-
it { is_expected.to be(value) }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when ::Hash" do
|
|
14
|
-
let(:value) { { year: 2020, month: 1, day: 2 } }
|
|
15
|
-
|
|
16
|
-
it { is_expected.to eq(Date.new(2020, 1, 2)) }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "when '20200102'" do
|
|
20
|
-
let(:value) { "20200102" }
|
|
21
|
-
|
|
22
|
-
it { is_expected.to eq(Date.new(2020, 1, 2)) }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context "when '2020-01-2'" do
|
|
26
|
-
let(:value) { "2020-01-2" }
|
|
27
|
-
|
|
28
|
-
it { is_expected.to eq(Date.new(2020, 1, 2)) }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "when not castable" do
|
|
32
|
-
let(:value) { "notcastable" }
|
|
33
|
-
|
|
34
|
-
it { is_expected_to_raise(Foobara::Value::Processor::Casting::CannotCastError) }
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":datetime" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:datetime] }
|
|
3
|
-
|
|
4
|
-
describe "#process!" do
|
|
5
|
-
subject { type.process_value!(value) }
|
|
6
|
-
|
|
7
|
-
context "when ::Time" do
|
|
8
|
-
let(:value) { Time.new(2020, 1, 2, 3, 4, 5, 6) }
|
|
9
|
-
|
|
10
|
-
it { is_expected.to be(value) }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when ::Date" do
|
|
14
|
-
let(:value) { Date.new(2020, 1, 2) }
|
|
15
|
-
|
|
16
|
-
it { is_expected.to eq(Time.new(2020, 1, 2)) }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "when ::Hash" do
|
|
20
|
-
let(:value) { { year: "2020", month: 1, day: 2, hours: 3, minutes: 4, seconds: 5 } }
|
|
21
|
-
|
|
22
|
-
it { is_expected.to eq(Time.new(2020, 1, 2, 3, 4, 5)) }
|
|
23
|
-
|
|
24
|
-
context "with milliseconds" do
|
|
25
|
-
let(:value) { { year: "2020", month: 1, day: 2, hours: 3, minutes: 4, seconds: 5, milliseconds: 500 } }
|
|
26
|
-
|
|
27
|
-
it { is_expected.to eq(Time.new(2020, 1, 2, 3, 4, 5.5)) }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "with zone" do
|
|
31
|
-
let(:value) { { year: "2020", month: 1, day: 2, hours: 3, minutes: 4, seconds: 5, zone: "-0700" } }
|
|
32
|
-
|
|
33
|
-
it { is_expected.to eq(Time.new(2020, 1, 2, 3, 4, 5, in: "-0700")) }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
context "when '2020-01-02 03:04:05.500 -1200'" do
|
|
38
|
-
let(:value) { "2020-01-02 03:04:05.500 -1200" }
|
|
39
|
-
|
|
40
|
-
it { is_expected.to eq(Time.new(2020, 1, 2, 3, 4, 5.5, in: "-12:00")) }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "when not castable" do
|
|
44
|
-
let(:value) { "notcastable" }
|
|
45
|
-
|
|
46
|
-
it { is_expected_to_raise(Foobara::Value::Processor::Casting::CannotCastError) }
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":email" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:email] }
|
|
3
|
-
|
|
4
|
-
describe "#process!" do
|
|
5
|
-
subject { type.process_value!(value) }
|
|
6
|
-
|
|
7
|
-
context "when valid string" do
|
|
8
|
-
let(:value) { "foo@bar.baz" }
|
|
9
|
-
|
|
10
|
-
it { is_expected.to eq("foo@bar.baz") }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context "when not castable" do
|
|
14
|
-
let(:value) { Object.new }
|
|
15
|
-
|
|
16
|
-
it {
|
|
17
|
-
is_expected_to_raise(
|
|
18
|
-
Foobara::Value::Processor::Casting::CannotCastError,
|
|
19
|
-
/Expected it to be a String/
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "when uppercase" do
|
|
25
|
-
let(:value) { "FooBar@examPLE.com" }
|
|
26
|
-
|
|
27
|
-
it { is_expected.to eq("foobar@example.com") }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "when too long" do
|
|
31
|
-
let(:value) { "#{"a" * 70}@example.com" }
|
|
32
|
-
|
|
33
|
-
it {
|
|
34
|
-
is_expected_to_raise(
|
|
35
|
-
Foobara::BuiltinTypes::Email::Validators::CannotExceed64Characters.error_class,
|
|
36
|
-
# TODO: this is goofy that it doesn't put a space before 64. Eliminate a bunch of this magic.
|
|
37
|
-
"Cannot exceed64 characters"
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# TODO: test the other rules
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
RSpec.describe ":float" do
|
|
2
|
-
let(:type) { Foobara::BuiltinTypes[:float] }
|
|
3
|
-
|
|
4
|
-
describe "caster names" do
|
|
5
|
-
it "gives the names of the casters including the dynamically generated class matcher" do
|
|
6
|
-
expect(type.value_caster.processor_names).to contain_exactly("Foobara::BuiltinTypes::Float::Casters::Integer", "Foobara::BuiltinTypes::Float::Casters::String")
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe "#needs_cast?" do
|
|
11
|
-
subject { type.needs_cast?(value) }
|
|
12
|
-
|
|
13
|
-
context "when Float" do
|
|
14
|
-
let(:value) { 1.3 }
|
|
15
|
-
|
|
16
|
-
it { is_expected.to be(false) }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "when something else" do
|
|
20
|
-
let(:value) { Object.new }
|
|
21
|
-
|
|
22
|
-
it { is_expected.to be(true) }
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe "#process!" do
|
|
27
|
-
subject { type.process_value!(value) }
|
|
28
|
-
|
|
29
|
-
context "when ::Float" do
|
|
30
|
-
let(:value) { 1.3 }
|
|
31
|
-
|
|
32
|
-
it { is_expected.to be(value) }
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context "when ::Integer" do
|
|
36
|
-
let(:value) { 10 }
|
|
37
|
-
|
|
38
|
-
it { is_expected.to be(10.to_f) }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context "when '1.3'" do
|
|
42
|
-
let(:value) { "1.3" }
|
|
43
|
-
|
|
44
|
-
it { is_expected.to be(1.3) }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
context "when '-1.3E-5'" do
|
|
48
|
-
let(:value) { "-1.3E-5" }
|
|
49
|
-
|
|
50
|
-
it { is_expected.to be(-0.000013) }
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context "when not castable" do
|
|
54
|
-
let(:value) { "notcastable" }
|
|
55
|
-
|
|
56
|
-
it { is_expected_to_raise(Foobara::Value::Processor::Casting::CannotCastError) }
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
RSpec.describe Foobara::BuiltinTypes::Duck::SupportedValidators::OneOf do
|
|
2
|
-
let(:type) do
|
|
3
|
-
Foobara::GlobalDomain.foobara_type_from_declaration(*Foobara::Util.array(type_declaration))
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
before do
|
|
7
|
-
stub_class("Foo")
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context "when class" do
|
|
11
|
-
let(:type_declaration) { Foo }
|
|
12
|
-
|
|
13
|
-
it "desugarizes as a duck and works as a duck but validates instance of" do
|
|
14
|
-
expect(type.declaration_data).to eq(type: :duck, instance_of: "Foo")
|
|
15
|
-
|
|
16
|
-
foo = Foo.new
|
|
17
|
-
expect(type.process_value!(foo)).to be(foo)
|
|
18
|
-
|
|
19
|
-
not_foo = Object.new
|
|
20
|
-
outcome = type.process_value(not_foo)
|
|
21
|
-
expect(outcome).to_not be_success
|
|
22
|
-
errors = outcome.errors
|
|
23
|
-
expect(errors.size).to eq(1)
|
|
24
|
-
error = errors.first
|
|
25
|
-
expect(error).to be_a(Foobara::BuiltinTypes::Duck::SupportedValidators::InstanceOf::NotInstanceOfError)
|
|
26
|
-
expect(error.message).to match(/is not an instance of Foo/)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "when :duck with instance_of: processor declaration" do
|
|
31
|
-
let(:type_declaration) do
|
|
32
|
-
[:duck, { instance_of: :Foo }]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "casts instance_of: to a string" do
|
|
36
|
-
expect(type.declaration_data).to eq(type: :duck, instance_of: "Foo")
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context "when intance_of: some class" do
|
|
40
|
-
let(:type_declaration) do
|
|
41
|
-
[:duck, { instance_of: Foo }]
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "casts instance_of: to a string" do
|
|
45
|
-
expect(type.declaration_data).to eq(type: :duck, instance_of: "Foo")
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
context "when not the name of an existing class" do
|
|
51
|
-
let(:type_declaration) do
|
|
52
|
-
[:duck, { instance_of: "NotAnExistingClassName" }]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "explodes" do
|
|
56
|
-
expect {
|
|
57
|
-
type
|
|
58
|
-
}.to raise_error(Foobara::BuiltinTypes::Duck::SupportedValidators::InstanceOf::TypeDeclarationExtension::
|
|
59
|
-
ExtendRegisteredTypeDeclaration::TypeDeclarationValidators::IsValidClass::InvalidInstanceOfValueGivenError)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context "when not something that can be desugarized at all" do
|
|
64
|
-
let(:type_declaration) do
|
|
65
|
-
[:duck, { instance_of: 100 }]
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "explodes" do
|
|
69
|
-
expect {
|
|
70
|
-
type
|
|
71
|
-
}.to raise_error(Foobara::BuiltinTypes::Duck::SupportedValidators::InstanceOf::TypeDeclarationExtension::
|
|
72
|
-
ExtendRegisteredTypeDeclaration::TypeDeclarationValidators::IsValidClass::InvalidInstanceOfValueGivenError)
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
end
|