open_ehr 0.6.1
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.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +43 -0
- data/Guardfile +9 -0
- data/History.txt +4 -0
- data/Manifest.txt +16 -0
- data/PostInstall.txt +9 -0
- data/README.rdoc +66 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/doc/README_rdoc.html +148 -0
- data/doc/created.rid +2 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +54 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/openehr_terminology.xml +2700 -0
- data/doc/rdoc.css +706 -0
- data/lib/#open_ehr.rb# +11 -0
- data/lib/open_ehr/am/archetype/archetype_description/archetype_description.rb +21 -0
- data/lib/open_ehr/am/archetype/assertion.rb +190 -0
- data/lib/open_ehr/am/archetype/constraint_model/primitive.rb +296 -0
- data/lib/open_ehr/am/archetype/constraint_model.rb +340 -0
- data/lib/open_ehr/am/archetype/ontology.rb +97 -0
- data/lib/open_ehr/am/archetype.rb +134 -0
- data/lib/open_ehr/am/open_ehr_profile/data_types/basic.rb +29 -0
- data/lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb +19 -0
- data/lib/open_ehr/am/open_ehr_profile/data_types/text.rb +12 -0
- data/lib/open_ehr/am.rb +8 -0
- data/lib/open_ehr/assumed_library_types.rb +627 -0
- data/lib/open_ehr/parser/xml_perser.rb +13 -0
- data/lib/open_ehr/parser.rb +19 -0
- data/lib/open_ehr/rm/common/archetyped.rb +182 -0
- data/lib/open_ehr/rm/common/change_control.rb +332 -0
- data/lib/open_ehr/rm/common/directory.rb +29 -0
- data/lib/open_ehr/rm/common/generic.rb +216 -0
- data/lib/open_ehr/rm/common/resource.rb +154 -0
- data/lib/open_ehr/rm/common.rb +14 -0
- data/lib/open_ehr/rm/composition/content/entry.rb +246 -0
- data/lib/open_ehr/rm/composition/content/navigation.rb +31 -0
- data/lib/open_ehr/rm/composition/content.rb +22 -0
- data/lib/open_ehr/rm/composition.rb +103 -0
- data/lib/open_ehr/rm/data_structures/history.rb +117 -0
- data/lib/open_ehr/rm/data_structures/item_structure/representation.rb +63 -0
- data/lib/open_ehr/rm/data_structures/item_structure.rb +216 -0
- data/lib/open_ehr/rm/data_structures.rb +25 -0
- data/lib/open_ehr/rm/data_types/basic.rb +108 -0
- data/lib/open_ehr/rm/data_types/charset.lst +818 -0
- data/lib/open_ehr/rm/data_types/charset_extract.rb +24 -0
- data/lib/open_ehr/rm/data_types/encapsulated.rb +98 -0
- data/lib/open_ehr/rm/data_types/quantity/date_time.rb +229 -0
- data/lib/open_ehr/rm/data_types/quantity.rb +403 -0
- data/lib/open_ehr/rm/data_types/text.rb +168 -0
- data/lib/open_ehr/rm/data_types/time_specification.rb +75 -0
- data/lib/open_ehr/rm/data_types/uri.rb +82 -0
- data/lib/open_ehr/rm/data_types.rb +14 -0
- data/lib/open_ehr/rm/demographic.rb +269 -0
- data/lib/open_ehr/rm/ehr.rb +162 -0
- data/lib/open_ehr/rm/integration.rb +27 -0
- data/lib/open_ehr/rm/security.rb +12 -0
- data/lib/open_ehr/rm/support/assumed_types.rb +81 -0
- data/lib/open_ehr/rm/support/definition.rb +15 -0
- data/lib/open_ehr/rm/support/identification.rb +408 -0
- data/lib/open_ehr/rm/support/measurement.rb +17 -0
- data/lib/open_ehr/rm/support/terminology.rb +135 -0
- data/lib/open_ehr/rm/support.rb +14 -0
- data/lib/open_ehr/rm.rb +16 -0
- data/lib/open_ehr/serializer.rb +272 -0
- data/lib/open_ehr/terminology/open_ehr_terminology.rb +41 -0
- data/lib/open_ehr/terminology.rb +7 -0
- data/lib/open_ehr/writer.rb +12 -0
- data/lib/open_ehr.rb +11 -0
- data/spec/lib/open_ehr/am/archetype/archetype_spec.rb +98 -0
- data/spec/lib/open_ehr/am/archetype/assertion/assertion_spec.rb +60 -0
- data/spec/lib/open_ehr/am/archetype/assertion/assertion_variable_spec.rb +30 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_binary_operator.rb +40 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_item_spec.rb +28 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_leaf_spec.rb +34 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_operator_spec.rb +25 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_unary_operator_spec.rb +26 -0
- data/spec/lib/open_ehr/am/archetype/assertion/operator_kind_spec.rb +110 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_constraint_spec.rb +56 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_internal_ref_spec.rb +36 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_slot_spec.rb +61 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_attribute_spec.rb +59 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_complex_object_spec.rb +39 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_defined_object_spec.rb +53 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_domain_type_spec.rb +25 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_multiple_attribute_spec.rb +29 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_object_spec.rb +61 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb +33 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_reference_object_spec.rb +17 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_single_attribute_spec.rb +28 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/cardinality_spec.rb +68 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/constraint_ref_spec.rb +29 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_boolean_spec.rb +52 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_spec.rb +80 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_time_spec.rb +106 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_duration_spec.rb +69 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_integer_spec.rb +62 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_primitive_spec.rb +39 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_real_spec.rb +14 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_string_spec.rb +69 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_time_spec.rb +79 -0
- data/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb +59 -0
- data/spec/lib/open_ehr/am/archetype/ontology/archetype_term_spec.rb +43 -0
- data/spec/lib/open_ehr/am/archetype/validity_kind_spec.rb +42 -0
- data/spec/lib/open_ehr/assumed_library_types/interval_spec.rb +140 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_date_spec.rb +236 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb +47 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_duration_spec.rb +150 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_time_spec.rb +234 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_timezone_spec.rb +57 -0
- data/spec/lib/open_ehr/assumed_library_types/time_definitions_spec.rb +136 -0
- data/spec/lib/open_ehr/rm/common/archetyped/archetyped_spec.rb +50 -0
- data/spec/lib/open_ehr/rm/common/archetyped/feeder_audit_details_spec.rb +60 -0
- data/spec/lib/open_ehr/rm/common/archetyped/feeder_audit_spec.rb +51 -0
- data/spec/lib/open_ehr/rm/common/archetyped/link_spec.rb +42 -0
- data/spec/lib/open_ehr/rm/common/archetyped/locatable_spec.rb +89 -0
- data/spec/lib/open_ehr/rm/common/archetyped/pathable_spec.rb +42 -0
- data/spec/lib/open_ehr/rm/common/change_control/contribution_spec.rb +56 -0
- data/spec/lib/open_ehr/rm/common/change_control/imported_version_spec.rb +63 -0
- data/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb +71 -0
- data/spec/lib/open_ehr/rm/common/change_control/version_spec.rb +92 -0
- data/spec/lib/open_ehr/rm/common/change_control/versioned_object_spec.rb +285 -0
- data/spec/lib/open_ehr/rm/common/directory/folder_spec.rb +26 -0
- data/spec/lib/open_ehr/rm/common/generic/attestation_spec.rb +62 -0
- data/spec/lib/open_ehr/rm/common/generic/audit_details_spec.rb +51 -0
- data/spec/lib/open_ehr/rm/common/generic/participation_spec.rb +36 -0
- data/spec/lib/open_ehr/rm/common/generic/party_identified_spec.rb +64 -0
- data/spec/lib/open_ehr/rm/common/generic/party_proxy_spec.rb +18 -0
- data/spec/lib/open_ehr/rm/common/generic/party_related_spec.rb +24 -0
- data/spec/lib/open_ehr/rm/common/generic/revision_history_item_spec.rb +43 -0
- data/spec/lib/open_ehr/rm/common/generic/revision_history_spec.rb +45 -0
- data/spec/lib/open_ehr/rm/common/resource/authored_resource_spec.rb +68 -0
- data/spec/lib/open_ehr/rm/common/resource/resource_description_item_spec.rb +105 -0
- data/spec/lib/open_ehr/rm/common/resource/resource_description_spec.rb +74 -0
- data/spec/lib/open_ehr/rm/common/resource/translation_details_spec.rb +35 -0
- data/spec/lib/open_ehr/rm/composition/composition_spec.rb +92 -0
- data/spec/lib/open_ehr/rm/composition/content/content_item_spec.rb +14 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/action_spec.rb +69 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/activity_spec.rb +61 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/admin_entry_spec.rb +38 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/care_entry_spec.rb +37 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/entry_spec.rb +88 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/evaluation_spec.rb +37 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/instruction_details_spec.rb +51 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/instruction_spec.rb +62 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/ism_transition_spec.rb +46 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/observation_spec.rb +45 -0
- data/spec/lib/open_ehr/rm/composition/content/navigation/section_spec.rb +32 -0
- data/spec/lib/open_ehr/rm/composition/event_context_spec.rb +88 -0
- data/spec/lib/open_ehr/rm/data_structures/data_structure_spec.rb +21 -0
- data/spec/lib/open_ehr/rm/data_structures/history/event_spec.rb +44 -0
- data/spec/lib/open_ehr/rm/data_structures/history/history_spec.rb +67 -0
- data/spec/lib/open_ehr/rm/data_structures/history/interval_event_spec.rb +43 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb +53 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/item_single_spec.rb +29 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb +147 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/item_tree_spec.rb +48 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/representation/cluster_spec.rb +26 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/representation/element_spec.rb +22 -0
- data/spec/lib/open_ehr/rm/data_types/basic/data_value_spec.rb +17 -0
- data/spec/lib/open_ehr/rm/data_types/basic/dv_boolean_spec.rb +29 -0
- data/spec/lib/open_ehr/rm/data_types/basic/dv_identifier_spec.rb +108 -0
- data/spec/lib/open_ehr/rm/data_types/basic/dv_state_spec.rb +44 -0
- data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_encapsulated_spec.rb +42 -0
- data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_multimedia_spec.rb +79 -0
- data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_parsable_spec.rb +34 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_spec.rb +64 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb +25 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_tempral_spec.rb +24 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb +37 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_absolute_quantity_spec.rb +35 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_amount_spec.rb +105 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_count_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_interval_spec.rb +17 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_ordered_spec.rb +60 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_ordinal_spec.rb +74 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_proportion_spec.rb +162 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_quantified_spec.rb +36 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_quantity_spec.rb +78 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/proportion_kind_spec.rb +24 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/reference_range_spec.rb +43 -0
- data/spec/lib/open_ehr/rm/data_types/text/code_phrase_spec.rb +23 -0
- data/spec/lib/open_ehr/rm/data_types/text/dv_paragraph_spec.rb +13 -0
- data/spec/lib/open_ehr/rm/data_types/text/dv_text_spec.rb +57 -0
- data/spec/lib/open_ehr/rm/data_types/text/term_mapping_spec.rb +59 -0
- data/spec/lib/open_ehr/rm/data_types/uri/dv_ehr_uri_spec.rb +21 -0
- data/spec/lib/open_ehr/rm/data_types/uri/dv_uri_spec.rb +36 -0
- data/spec/lib/open_ehr/rm/demographic/actor_spec.rb +79 -0
- data/spec/lib/open_ehr/rm/demographic/address_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/demographic/capability_spec.rb +37 -0
- data/spec/lib/open_ehr/rm/demographic/contact_spec.rb +45 -0
- data/spec/lib/open_ehr/rm/demographic/party_identity_spec.rb +32 -0
- data/spec/lib/open_ehr/rm/demographic/party_relationship_spec.rb +84 -0
- data/spec/lib/open_ehr/rm/demographic/party_spec.rb +133 -0
- data/spec/lib/open_ehr/rm/demographic/role_spec.rb +58 -0
- data/spec/lib/open_ehr/rm/ehr/ehr_access_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/ehr/ehr_spec.rb +139 -0
- data/spec/lib/open_ehr/rm/ehr/ehr_status_spec.rb +52 -0
- data/spec/lib/open_ehr/rm/ehr/versioned_composition_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/integration/generic_entry_spec.rb +31 -0
- data/spec/lib/open_ehr/rm/support/identification/access_group_ref_spec.rb +19 -0
- data/spec/lib/open_ehr/rm/support/identification/archetype_id_spec.rb +152 -0
- data/spec/lib/open_ehr/rm/support/identification/generic_id_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/support/identification/hier_object_id_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/support/identification/internet_id_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/support/identification/iso_oid_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/support/identification/locatable_ref_spec.rb +34 -0
- data/spec/lib/open_ehr/rm/support/identification/object_id_spec.rb +24 -0
- data/spec/lib/open_ehr/rm/support/identification/object_ref_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/support/identification/object_version_id_spec.rb +60 -0
- data/spec/lib/open_ehr/rm/support/identification/party_ref_spec.rb +29 -0
- data/spec/lib/open_ehr/rm/support/identification/template_id_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/support/identification/terminology_id_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/support/identification/uid_based_id_spec.rb +50 -0
- data/spec/lib/open_ehr/rm/support/identification/uid_spec.rb +29 -0
- data/spec/lib/open_ehr/rm/support/identification/version_tree_id_spec.rb +104 -0
- data/spec/lib/open_ehr/rm/support/measurement_service_spec.rb +7 -0
- data/spec/lib/open_ehr/rm/support/terminology_service_spec.rb +24 -0
- data/spec/lib/open_ehr/serializer/adl-test-entry.most_minimal.test.adl +20 -0
- data/spec/lib/open_ehr/serializer/adl_serializer_spec.rb +47 -0
- data/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.adl +38 -0
- data/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.xml +58 -0
- data/spec/lib/open_ehr/serializer/sample_archetype_spec.rb +44 -0
- data/spec/lib/open_ehr/serializer/xml_serializer_spec.rb +49 -0
- data/spec/lib/open_ehr/terminology/open_ehr_terminology_spec.rb +40 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +54 -0
- metadata +401 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
2
|
+
include OpenEHR::AM::Archetype::ConstraintModel
|
3
|
+
include OpenEHR::AssumedLibraryTypes
|
4
|
+
|
5
|
+
describe Cardinality do
|
6
|
+
before(:each) do
|
7
|
+
interval = Interval.new(:upper => 1, :lower => 0)
|
8
|
+
@cardinality = Cardinality.new(:is_ordered => true,
|
9
|
+
:is_unique => true,
|
10
|
+
:interval => interval)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should be an instance of Cardinality' do
|
14
|
+
@cardinality.should be_an_instance_of Cardinality
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'is_ordered should be assigned properly' do
|
18
|
+
@cardinality.should be_ordered
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'is_ordered should be false' do
|
22
|
+
@cardinality.is_ordered = false
|
23
|
+
@cardinality.should_not be_ordered
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'is_unique should be assigned properly' do
|
27
|
+
@cardinality.should be_unique
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'is_unique should not be true' do
|
31
|
+
@cardinality.is_unique = false
|
32
|
+
@cardinality.should_not be_unique
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'interval should be assigned properly' do
|
36
|
+
@cardinality.interval.upper.should be_equal 1
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'is_set represent not ordered and unique' do
|
40
|
+
@cardinality.should_not be_set
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'is_set should be true' do
|
44
|
+
@cardinality.is_unique = true
|
45
|
+
@cardinality.is_ordered = false
|
46
|
+
@cardinality.should be_set
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'is_list represent ordered and not unique' do
|
50
|
+
@cardinality.is_ordered = true
|
51
|
+
@cardinality.is_unique = false
|
52
|
+
@cardinality.should be_list
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'is_list should not be true' do
|
56
|
+
@cardinality.should_not be_list
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'is_bag represent not ordered and not unique' do
|
60
|
+
@cardinality.is_ordered = false
|
61
|
+
@cardinality.is_unique = false
|
62
|
+
@cardinality.should be_bag
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'is_bag? should not be true' do
|
66
|
+
@cardinality.should_not be_bag
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
2
|
+
include OpenEHR::AM::Archetype::ConstraintModel
|
3
|
+
include OpenEHR::AssumedLibraryTypes
|
4
|
+
|
5
|
+
describe ConstraintRef do
|
6
|
+
before(:each) do
|
7
|
+
occurrences = Interval.new(:lower => 0, :upper => 1)
|
8
|
+
@constraint_ref =
|
9
|
+
ConstraintRef.new(:path => '/event/[at0001]/',
|
10
|
+
:rm_type_name => 'DV_TIME',
|
11
|
+
:node_id => 'ac0001',
|
12
|
+
:occurrences => occurrences,
|
13
|
+
:reference => 'ac0002')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be an instance of ConstraintRef' do
|
17
|
+
@constraint_ref.should be_an_instance_of ConstraintRef
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'reference should be assigned properly' do
|
21
|
+
@constraint_ref.reference.should == 'ac0002'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should raise ArgumentError when reference is nil' do
|
25
|
+
lambda {
|
26
|
+
@constraint_ref.reference = nil
|
27
|
+
}.should raise_error ArgumentError
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
3
|
+
include OpenEHR::RM::DataTypes::Basic
|
4
|
+
|
5
|
+
describe CBoolean do
|
6
|
+
before(:each) do
|
7
|
+
default_value = DvBoolean.new(:value => true)
|
8
|
+
@c_boolean = CBoolean.new(:default_value => true,
|
9
|
+
:true_valid => true,
|
10
|
+
:false_valid => true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should be_an_instance_of CBoolean' do
|
14
|
+
@c_boolean.should be_an_instance_of CBoolean
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'true_valid should be assigned properly' do
|
18
|
+
@c_boolean.should be_true_valid
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'false_valid should be assigned properly' do
|
22
|
+
@c_boolean.should be_false_valid
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should raise ArgumentError when both true_valid and false_valid are false' do
|
26
|
+
lambda {
|
27
|
+
@c_boolean.true_valid = false
|
28
|
+
@c_boolean.false_valid = false
|
29
|
+
}.should raise_error ArgumentError
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should raise ArgumentError if both false_valid and true_valid are false' do
|
33
|
+
lambda {
|
34
|
+
@c_boolean.false_valid = false
|
35
|
+
@c_boolean.true_valid = false
|
36
|
+
}.should raise_error ArgumentError
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should raise ArgumentError if default_value is false and false_valid is false' do
|
40
|
+
lambda {
|
41
|
+
@c_boolean.false_valid = false
|
42
|
+
@c_boolean.default_value = false
|
43
|
+
}.should raise_error ArgumentError
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should raise ArgumentError if default_value is true and true_valid is false' do
|
47
|
+
lambda {
|
48
|
+
@c_boolean.true_valid = false
|
49
|
+
@c_boolean.default_value = true
|
50
|
+
}.should raise_error ArgumentError
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AM::Archetype
|
3
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
4
|
+
include OpenEHR::AssumedLibraryTypes
|
5
|
+
|
6
|
+
describe CDate do
|
7
|
+
before(:each) do
|
8
|
+
default_value = ISO8601Date.new('2010-01-18')
|
9
|
+
assumed_value = ISO8601Date.new('2007-02-19')
|
10
|
+
range = Interval.new(:lower => ISO8601Date.new('2001-01-01'),
|
11
|
+
:upper => ISO8601Date.new('2010-12-31'))
|
12
|
+
@c_date = CDate.new(:default_value => default_value,
|
13
|
+
:assumed_value => assumed_value,
|
14
|
+
:range => range,
|
15
|
+
:month_validity => ValidityKind::MANDATORY,
|
16
|
+
:day_validity => ValidityKind::OPTIONAL,
|
17
|
+
:timezone_validity => ValidityKind::DISALLOWED)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should be an instance of CDate' do
|
21
|
+
@c_date.should be_an_instance_of CDate
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'range should be assigned properly' do
|
25
|
+
@c_date.range.upper.month.should be_equal 12
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'month_validity should be assigned properly by constructor' do
|
29
|
+
@c_date.month_validity.should be_equal ValidityKind::MANDATORY
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'validity_is_range should be true if range is assigned' do
|
33
|
+
@c_date.should be_validity_is_range
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'validity_is_range should not be true if range is nil' do
|
37
|
+
@c_date.range = nil
|
38
|
+
@c_date.should_not be_validity_is_range
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'day_validity should be assigned properly by constructor' do
|
42
|
+
@c_date.day_validity.should be_equal ValidityKind::OPTIONAL
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'timezone should be assigned properly' do
|
46
|
+
@c_date.timezone_validity.should be_equal ValidityKind::DISALLOWED
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'method' do
|
50
|
+
it 'month_validity should be assigned by method properly' do
|
51
|
+
@c_date.month_validity = ValidityKind::OPTIONAL
|
52
|
+
@c_date.month_validity.should be_equal ValidityKind::OPTIONAL
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'day_validity should be assigned by method properly' do
|
56
|
+
@c_date.day_validity = ValidityKind::MANDATORY
|
57
|
+
@c_date.day_validity.should be_equal ValidityKind::MANDATORY
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should raise ArgumentError if month_validity is optional and day validity is mandatory' do
|
61
|
+
@c_date.day_validity = ValidityKind::MANDATORY
|
62
|
+
lambda {
|
63
|
+
@c_date.month_validity = ValidityKind::OPTIONAL
|
64
|
+
}.should raise_error ArgumentError
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should raise ArgumentError if month_validity is disallowed and day_validity is mandatory' do
|
68
|
+
@c_date.day_validity = ValidityKind::MANDATORY
|
69
|
+
lambda {
|
70
|
+
@c_date.month_validity = ValidityKind::DISALLOWED
|
71
|
+
}.should raise_error ArgumentError
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should raise ArgumentError if month_validity is disallowed and day_validity is optional' do
|
75
|
+
lambda {
|
76
|
+
@c_date.month_validity = ValidityKind::DISALLOWED
|
77
|
+
}.should raise_error ArgumentError
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AssumedLibraryTypes
|
3
|
+
include OpenEHR::AM::Archetype
|
4
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
5
|
+
|
6
|
+
describe CDateTime do
|
7
|
+
before(:each) do
|
8
|
+
default_value = ISO8601DateTime.new('2010-01-25T01:23:45.1')
|
9
|
+
assumed_value = ISO8601DateTime.new('2001-12-23T22:02:33.2')
|
10
|
+
range = Interval.new(:lower => ISO8601DateTime.new('1995-04-19T01:01:22'),
|
11
|
+
:upper => ISO8601DateTime.new('2022-12-31T23:55:59'))
|
12
|
+
@c_date_time =
|
13
|
+
CDateTime.new(:default_value => default_value,
|
14
|
+
:assumed_value => assumed_value,
|
15
|
+
:range => range,
|
16
|
+
:month_validity => ValidityKind::MANDATORY,
|
17
|
+
:day_validity => ValidityKind::MANDATORY,
|
18
|
+
:hour_vaildity => ValidityKind::MANDATORY,
|
19
|
+
:minute_validity => ValidityKind::MANDATORY,
|
20
|
+
:second_validity => ValidityKind::OPTIONAL,
|
21
|
+
:millisecond_validity => ValidityKind::DISALLOWED,
|
22
|
+
:timezone_validity => ValidityKind::OPTIONAL)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should be an instance of CDateTime' do
|
26
|
+
@c_date_time.should be_an_instance_of CDateTime
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'hour_validity should be assigned properly' do
|
30
|
+
@c_date_time.hour_validity.should be_equal ValidityKind::MANDATORY
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should raise ArgumentError if hour_validity is DISALLOWED and minute_validity is not DISALLOWED' do
|
34
|
+
lambda {
|
35
|
+
@c_date_time.hour_validity = ValidityKind::DISALLOWED
|
36
|
+
}.should raise_error ArgumentError
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should not raise ArgumentError if hour_validity is DISALLOWED and minute_validity is DISALLOWED' do
|
40
|
+
@c_date_time.second_validity = ValidityKind::DISALLOWED
|
41
|
+
@c_date_time.minute_validity = ValidityKind::DISALLOWED
|
42
|
+
lambda {
|
43
|
+
@c_date_time.hour_validity = ValidityKind::DISALLOWED
|
44
|
+
}.should_not raise_error ArgumentError
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should raise ArgumentError if hour_validity is OPTIONAL and minute_validity is MANDATORY' do
|
48
|
+
lambda {
|
49
|
+
@c_date_time.hour_validity = ValidityKind::OPTIONAL
|
50
|
+
}.should raise_error ArgumentError
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should not raise ArgumentError if hour_validity is OPTIONAL and minute_validity is OPTIONAL' do
|
54
|
+
@c_date_time.minute_validity = ValidityKind::OPTIONAL
|
55
|
+
lambda {
|
56
|
+
@c_date_time.hour_validity = ValidityKind::OPTIONAL
|
57
|
+
}.should_not raise_error ArgumentError
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should not raise Argument Error if hour_validity is OPTIONAL and minute_validity is DISALLOWED' do
|
61
|
+
@c_date_time.second_validity = ValidityKind::DISALLOWED
|
62
|
+
@c_date_time.minute_validity = ValidityKind::DISALLOWED
|
63
|
+
lambda {
|
64
|
+
@c_date_time.hour_validity = ValidityKind::OPTIONAL
|
65
|
+
}.should_not raise_error ArgumentError
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should raise ArgumentError if day_validity is DISALLOWED and hour_validity is not DISALLOWED' do
|
69
|
+
lambda {
|
70
|
+
@c_date_time.day_validity = ValidityKind::DISALLOWED
|
71
|
+
}.should raise_error ArgumentError
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should not raise ArgumentError if day_validity is DISALLOWED and hour_validity is DISALLOWED' do
|
75
|
+
@c_date_time.second_validity = ValidityKind::DISALLOWED
|
76
|
+
@c_date_time.minute_validity = ValidityKind::DISALLOWED
|
77
|
+
@c_date_time.hour_validity = ValidityKind::DISALLOWED
|
78
|
+
lambda {
|
79
|
+
@c_date_time.day_validity = ValidityKind::DISALLOWED
|
80
|
+
}.should_not raise_error ArgumentError
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should raise ArgumentError if day_validity is OPTIONAL and hour_validity is MANDATORY' do
|
84
|
+
lambda {
|
85
|
+
@c_date_time.day_validity = ValidityKind::OPTIONAL
|
86
|
+
}.should raise_error ArgumentError
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should not raise ArgumentError if day_validity OPTIONAL and hour_validity is OPTIONAL' do
|
90
|
+
@c_date_time.second_validity = ValidityKind::DISALLOWED
|
91
|
+
@c_date_time.minute_validity = ValidityKind::DISALLOWED
|
92
|
+
@c_date_time.hour_validity = ValidityKind::OPTIONAL
|
93
|
+
lambda {
|
94
|
+
@c_date_time.day_validity = ValidityKind::OPTIONAL
|
95
|
+
}.should_not raise_error ArgumentError
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should not raise ArgumentError if day_validity OPTIONAL and hour_validity is DISALLOWED' do
|
99
|
+
@c_date_time.second_validity = ValidityKind::DISALLOWED
|
100
|
+
@c_date_time.minute_validity = ValidityKind::DISALLOWED
|
101
|
+
@c_date_time.hour_validity = ValidityKind::DISALLOWED
|
102
|
+
lambda {
|
103
|
+
@c_date_time.day_validity = ValidityKind::OPTIONAL
|
104
|
+
}.should_not raise_error ArgumentError
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AssumedLibraryTypes
|
3
|
+
include OpenEHR::AM::Archetype
|
4
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
5
|
+
|
6
|
+
describe CDuration do
|
7
|
+
before(:each) do
|
8
|
+
assumed_value = stub(ISO8601Duration, :year => 2)
|
9
|
+
default_value = stub(ISO8601Duration, :month => 3)
|
10
|
+
range = stub(Interval, :upper => assumed_value, :lower => default_value)
|
11
|
+
@c_duration = CDuration.new(:assumed_value => assumed_value,
|
12
|
+
:default_value => default_value,
|
13
|
+
:range => range,
|
14
|
+
:years_allowed => true,
|
15
|
+
:months_allowed => false,
|
16
|
+
:weeks_allowed => true,
|
17
|
+
:days_allowed => false,
|
18
|
+
:hours_allowed => true,
|
19
|
+
:minutes_allowed => false,
|
20
|
+
:seconds_allowed => true,
|
21
|
+
:fractional_seconds_allowed => false)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should be an instance of CDuration' do
|
25
|
+
@c_duration.should be_an_instance_of CDuration
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'years_allowed should be assigned properly' do
|
29
|
+
@c_duration.years_allowed.should be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'months_allowed should be assigned properly' do
|
33
|
+
@c_duration.months_allowed.should be_false
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'weeks_allowed should be assigned properly' do
|
37
|
+
@c_duration.weeks_allowed.should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'days_allowed should be assigned properly' do
|
41
|
+
@c_duration.days_allowed.should be_false
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'hours_allowed should be assigned properly' do
|
45
|
+
@c_duration.hours_allowed.should be_true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'minutes_allowed should be assigned properly' do
|
49
|
+
@c_duration.minutes_allowed.should be_false
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'seconds_allowed should be assigned properly' do
|
53
|
+
@c_duration.seconds_allowed.should be_true
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'fractional_seconds_allowed should be assigned properly' do
|
57
|
+
@c_duration.fractional_seconds_allowed.should be_false
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should raise ArgumentError if range is nil and all parameters are not allowed' do
|
61
|
+
@c_duration.years_allowed = false
|
62
|
+
@c_duration.weeks_allowed = false
|
63
|
+
@c_duration.hours_allowed = false
|
64
|
+
@c_duration.seconds_allowed = false
|
65
|
+
lambda {
|
66
|
+
@c_duration.range = nil
|
67
|
+
}.should raise_error ArgumentError
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
3
|
+
include OpenEHR::AssumedLibraryTypes
|
4
|
+
|
5
|
+
describe CInteger do
|
6
|
+
before(:each) do
|
7
|
+
@c_integer = CInteger.new(:default_value => 3,
|
8
|
+
:assumed_value => 2,
|
9
|
+
:list => [1,2])
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should be an instance of CInteger' do
|
13
|
+
@c_integer.should be_an_instance_of CInteger
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should raise ArgumentError if both range and list are nil' do
|
17
|
+
lambda {
|
18
|
+
@c_integer.list = nil
|
19
|
+
}.should raise_error ArgumentError
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'list method' do
|
23
|
+
it 'constructor should assign list properly' do
|
24
|
+
@c_integer.list.should == [1,2]
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'list method should re-assign properly' do
|
28
|
+
@c_integer.list = [2,3]
|
29
|
+
@c_integer.list.should == [2,3]
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should be raise ArgumentError if both list and range are not nil' do
|
33
|
+
lambda {
|
34
|
+
@c_integer.range = Interval.new(:lower => 1,:upper =>3)
|
35
|
+
}.should raise_error ArgumentError
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'range mathod' do
|
40
|
+
before(:each) do
|
41
|
+
@c_integer =
|
42
|
+
CInteger.new(:default_value => 2,
|
43
|
+
:assumed_value => 3,
|
44
|
+
:range => Interval.new(:lower => 0, :upper => 5))
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'constructor should assign range properly' do
|
48
|
+
@c_integer.range.lower.should be_equal 0
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'range method should re-assigne properly' do
|
52
|
+
@c_integer.range = Interval.new(:lower => 20)
|
53
|
+
@c_integer.range.lower.should be_equal 20
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should raise ArgumentError if bhot range and list are not nil' do
|
57
|
+
lambda {
|
58
|
+
@c_integer.list = [10,100]
|
59
|
+
}.should raise_error ArgumentError
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
3
|
+
include OpenEHR::RM::DataTypes::Text
|
4
|
+
|
5
|
+
describe CPrimitive do
|
6
|
+
before(:each) do
|
7
|
+
default = DvText.new(:value => 'DEFAULT')
|
8
|
+
assumed = DvText.new(:value => 'ASSUMED')
|
9
|
+
@c_primitive = CPrimitive.new(:default_value => default,
|
10
|
+
:assumed_value => assumed)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should be an instance of CPrimitive' do
|
14
|
+
@c_primitive.should be_an_instance_of CPrimitive
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'default value should be assigned properly' do
|
18
|
+
@c_primitive.default_value.value.should == 'DEFAULT'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should raise ArgumentError when default_value is nil' do
|
22
|
+
lambda {
|
23
|
+
@c_primitive.default_value = nil
|
24
|
+
}.should raise_error ArgumentError
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'assumed_value should be assigned properly' do
|
28
|
+
@c_primitive.assumed_value.value.should == 'ASSUMED'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should be true when assumed_value is assigned' do
|
32
|
+
@c_primitive.should have_assumed_value
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should not be true when assumed_value is not assigned' do
|
36
|
+
@c_primitive.assumed_value = nil
|
37
|
+
@c_primitive.should_not have_assumed_value
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
3
|
+
|
4
|
+
describe CReal do
|
5
|
+
before(:each) do
|
6
|
+
@c_real = CReal.new(:default_value => 1.5,
|
7
|
+
:assumed_value => 2.3,
|
8
|
+
:list => [-1.5,20.3])
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should be an instance of CReal' do
|
12
|
+
@c_real.should be_an_instance_of CReal
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
3
|
+
include OpenEHR::RM::DataTypes::Text
|
4
|
+
|
5
|
+
describe CString do
|
6
|
+
before(:each) do
|
7
|
+
@default_value = DvText.new(:value => 'default')
|
8
|
+
@c_string = CString.new(:default_value => @default_value,
|
9
|
+
:assumed_value => 'assumed',
|
10
|
+
:pattern => 't[a-z]st')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should be an instance of CString' do
|
14
|
+
@c_string.should be_an_instance_of CString
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'default should be assigned properly' do
|
18
|
+
@c_string.default_value.value.should == 'default'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'assumed_value should be assigned properly' do
|
22
|
+
@c_string.assumed_value.should == 'assumed'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'pattern should be assigned properly by constructor' do
|
26
|
+
@c_string.pattern.should == 't[a-z]st'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'pattern should be assigned properly by method' do
|
30
|
+
@c_string.pattern = '.*'
|
31
|
+
@c_string.pattern.should == '.*'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should raise ArgumentError if either list or pattern is not nil' do
|
35
|
+
lambda {
|
36
|
+
@c_string.list = ['test','driven']
|
37
|
+
}.should raise_error ArgumentError
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should raise ArgumentError if both list and pattern are nil' do
|
41
|
+
lambda {
|
42
|
+
@c_string.pattern = nil
|
43
|
+
}.should raise_error ArgumentError
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'list attribute' do
|
47
|
+
before(:each) do
|
48
|
+
@default_value = DvText.new(:value => 'default')
|
49
|
+
@c_string = CString.new(:default_value => @default_value,
|
50
|
+
:assumed_value => 'assumed',
|
51
|
+
:list => ['test', 'behavior'])
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'list should be assigned properly by constructor' do
|
55
|
+
@c_string.list.should == ['test', 'behavior']
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'list shoudl be assigned properly by method' do
|
59
|
+
@c_string.list = ['spec']
|
60
|
+
@c_string.list.should == ['spec']
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should raise ArgumentError if both pattern and list is not nil' do
|
64
|
+
lambda {
|
65
|
+
@c_string.pattern = 'file.*'
|
66
|
+
}.should raise_error ArgumentError
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
2
|
+
include OpenEHR::AssumedLibraryTypes
|
3
|
+
include OpenEHR::AM::Archetype
|
4
|
+
include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
5
|
+
|
6
|
+
describe CTime do
|
7
|
+
before(:each) do
|
8
|
+
default_value = ISO8601Time.new('01:23:45')
|
9
|
+
assumed_value = ISO8601Time.new('22:02:33')
|
10
|
+
range = Interval.new(:lower => ISO8601Time.new('01:01:22'),
|
11
|
+
:upper => ISO8601Time.new('23:55:59'))
|
12
|
+
@c_time = CTime.new(:default_value => default_value,
|
13
|
+
:assumed_value => assumed_value,
|
14
|
+
:range => range,
|
15
|
+
:minute_validity => ValidityKind::MANDATORY,
|
16
|
+
:second_validity => ValidityKind::OPTIONAL,
|
17
|
+
:millisecond_validity => ValidityKind::DISALLOWED)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should be an instance of CTime' do
|
21
|
+
@c_time.should be_an_instance_of CTime
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'minute_validity should be assigned' do
|
25
|
+
@c_time.minute_validity.should be_equal ValidityKind::MANDATORY
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'seconds_validity should be assigned properly' do
|
29
|
+
@c_time.second_validity.should be_equal ValidityKind::OPTIONAL
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'millisecond_validity should be assigned properly' do
|
33
|
+
@c_time.millisecond_validity.should be_equal ValidityKind::DISALLOWED
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should be true if range is not nil' do
|
37
|
+
@c_time.should be_validity_is_range
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'second_validity should not be MANDATORY if minute_validity is optional' do
|
41
|
+
@c_time.second_validity = ValidityKind::MANDATORY
|
42
|
+
lambda {
|
43
|
+
@c_time.minute_validity = ValidityKind::OPTIONAL
|
44
|
+
}.should raise_error ArgumentError
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'second_validity should be DISALLOWED if minute_validity is DISALLOWED' do
|
48
|
+
lambda {
|
49
|
+
@c_time.minute_validity = ValidityKind::DISALLOWED
|
50
|
+
}.should raise_error ArgumentError
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should not raise ArgumentError if minute_validity and second_validity are DISALLOWED' do
|
54
|
+
@c_time.second_validity = ValidityKind::DISALLOWED
|
55
|
+
lambda {
|
56
|
+
@c_time.minute_validity = ValidityKind::DISALLOWED
|
57
|
+
}.should_not raise_error ArgumentError
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'millisecond_validity should not be MANDATORY if second_validity is optional' do
|
61
|
+
@c_time.millisecond_validity = ValidityKind::MANDATORY
|
62
|
+
lambda {
|
63
|
+
@c_time.second_validity = ValidityKind::OPTIONAL
|
64
|
+
}.should raise_error ArgumentError
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'millisecond_validity should be DISALLOWED if second_validity is DISALLOWED' do
|
68
|
+
lambda {
|
69
|
+
@c_time.second_validity = ValidityKind::DISALLOWED
|
70
|
+
}.should_not raise_error ArgumentError
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should raise ArgumentError if second_validity is DISALLOWED and millisecond_validity is OPTIONAL' do
|
74
|
+
@c_time.millisecond_validity = ValidityKind::OPTIONAL
|
75
|
+
lambda {
|
76
|
+
@c_time.second_validity = ValidityKind::DISALLOWED
|
77
|
+
}.should raise_error ArgumentError
|
78
|
+
end
|
79
|
+
end
|