scorm2004-manifest 0.1.0
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 +12 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +94 -0
- data/Rakefile +39 -0
- data/VERSION +1 -0
- data/lib/scorm2004/manifest/adlseq_map_info.rb +17 -0
- data/lib/scorm2004/manifest/adlseq_objective.rb +14 -0
- data/lib/scorm2004/manifest/adlseq_objectives.rb +11 -0
- data/lib/scorm2004/manifest/attributes.rb +147 -0
- data/lib/scorm2004/manifest/children.rb +83 -0
- data/lib/scorm2004/manifest/completion_threshold.rb +13 -0
- data/lib/scorm2004/manifest/condition_rule.rb +12 -0
- data/lib/scorm2004/manifest/constrained_choice_considerations.rb +12 -0
- data/lib/scorm2004/manifest/control_mode.rb +16 -0
- data/lib/scorm2004/manifest/custom_error.rb +15 -0
- data/lib/scorm2004/manifest/data.rb +11 -0
- data/lib/scorm2004/manifest/data_from_lms.rb +21 -0
- data/lib/scorm2004/manifest/delivery_controls.rb +13 -0
- data/lib/scorm2004/manifest/dependency.rb +21 -0
- data/lib/scorm2004/manifest/error.rb +5 -0
- data/lib/scorm2004/manifest/file.rb +16 -0
- data/lib/scorm2004/manifest/hide_lmsui.rb +21 -0
- data/lib/scorm2004/manifest/href.rb +24 -0
- data/lib/scorm2004/manifest/item.rb +36 -0
- data/lib/scorm2004/manifest/limit_conditions.rb +12 -0
- data/lib/scorm2004/manifest/manifest.rb +26 -0
- data/lib/scorm2004/manifest/map.rb +13 -0
- data/lib/scorm2004/manifest/map_info.rb +15 -0
- data/lib/scorm2004/manifest/min_normalized_measure.rb +18 -0
- data/lib/scorm2004/manifest/navigation_interface.rb +10 -0
- data/lib/scorm2004/manifest/objective.rb +16 -0
- data/lib/scorm2004/manifest/objectives.rb +12 -0
- data/lib/scorm2004/manifest/organization.rb +20 -0
- data/lib/scorm2004/manifest/organizations.rb +24 -0
- data/lib/scorm2004/manifest/presentation.rb +10 -0
- data/lib/scorm2004/manifest/primary_objective.rb +24 -0
- data/lib/scorm2004/manifest/randomization_controls.rb +16 -0
- data/lib/scorm2004/manifest/resource.rb +18 -0
- data/lib/scorm2004/manifest/resources.rb +12 -0
- data/lib/scorm2004/manifest/rollup_action.rb +13 -0
- data/lib/scorm2004/manifest/rollup_condition.rb +24 -0
- data/lib/scorm2004/manifest/rollup_conditions.rb +14 -0
- data/lib/scorm2004/manifest/rollup_considerations.rb +17 -0
- data/lib/scorm2004/manifest/rollup_rule.rb +19 -0
- data/lib/scorm2004/manifest/rollup_rules.rb +16 -0
- data/lib/scorm2004/manifest/rule_action.rb +31 -0
- data/lib/scorm2004/manifest/rule_condition.rb +41 -0
- data/lib/scorm2004/manifest/rule_conditions.rb +14 -0
- data/lib/scorm2004/manifest/schema.rb +18 -0
- data/lib/scorm2004/manifest/schemaversion.rb +18 -0
- data/lib/scorm2004/manifest/sequencing.rb +24 -0
- data/lib/scorm2004/manifest/sequencing_collection.rb +11 -0
- data/lib/scorm2004/manifest/sequencing_rules.rb +13 -0
- data/lib/scorm2004/manifest/text_node.rb +11 -0
- data/lib/scorm2004/manifest/time_limit_action.rb +24 -0
- data/lib/scorm2004/manifest/title.rb +16 -0
- data/lib/scorm2004/manifest/visitor_pattern.rb +31 -0
- data/lib/scorm2004/manifest/xml_base.rb +38 -0
- data/lib/scorm2004/manifest.rb +76 -0
- data/lib/scorm2004-manifest.rb +1 -0
- data/test/functional_test.rb +45 -0
- data/test/helper.rb +18 -0
- data/test/mbce_test.rb +66 -0
- data/test/msce_test.rb +55 -0
- data/test/scorm2004/manifest/adlseq_map_info_test.rb +47 -0
- data/test/scorm2004/manifest/adlseq_objective_test.rb +44 -0
- data/test/scorm2004/manifest/adlseq_objectives_test.rb +29 -0
- data/test/scorm2004/manifest/any_uri_token_test.rb +40 -0
- data/test/scorm2004/manifest/attributes_test.rb +224 -0
- data/test/scorm2004/manifest/children_test.rb +330 -0
- data/test/scorm2004/manifest/completion_threshold_test.rb +80 -0
- data/test/scorm2004/manifest/condition_rule_test.rb +40 -0
- data/test/scorm2004/manifest/constrained_choice_considerations_test.rb +25 -0
- data/test/scorm2004/manifest/control_mode_test.rb +41 -0
- data/test/scorm2004/manifest/custom_error_test.rb +43 -0
- data/test/scorm2004/manifest/data_from_lms_test.rb +47 -0
- data/test/scorm2004/manifest/data_test.rb +31 -0
- data/test/scorm2004/manifest/delivery_controls_test.rb +27 -0
- data/test/scorm2004/manifest/dependency_test.rb +53 -0
- data/test/scorm2004/manifest/duration_attribute_test.rb +59 -0
- data/test/scorm2004/manifest/file_test.rb +40 -0
- data/test/scorm2004/manifest/hide_lmsui_test.rb +40 -0
- data/test/scorm2004/manifest/href_test.rb +43 -0
- data/test/scorm2004/manifest/item_test.rb +86 -0
- data/test/scorm2004/manifest/limit_conditions_test.rb +34 -0
- data/test/scorm2004/manifest/manifest_test.rb +152 -0
- data/test/scorm2004/manifest/map_info_test.rb +41 -0
- data/test/scorm2004/manifest/map_test.rb +32 -0
- data/test/scorm2004/manifest/min_normalized_measure_test.rb +28 -0
- data/test/scorm2004/manifest/navigation_interface_test.rb +29 -0
- data/test/scorm2004/manifest/non_negative_integer_attribute_test.rb +64 -0
- data/test/scorm2004/manifest/objective_test.rb +45 -0
- data/test/scorm2004/manifest/objectives_test.rb +37 -0
- data/test/scorm2004/manifest/organization_test.rb +115 -0
- data/test/scorm2004/manifest/organizations_test.rb +68 -0
- data/test/scorm2004/manifest/partial_manifest.rb +23 -0
- data/test/scorm2004/manifest/partial_manifest_test.rb +44 -0
- data/test/scorm2004/manifest/presentation_test.rb +26 -0
- data/test/scorm2004/manifest/primary_objective_test.rb +65 -0
- data/test/scorm2004/manifest/randomization_controls_test.rb +71 -0
- data/test/scorm2004/manifest/resource_test.rb +96 -0
- data/test/scorm2004/manifest/resources_test.rb +41 -0
- data/test/scorm2004/manifest/rollup_action_test.rb +33 -0
- data/test/scorm2004/manifest/rollup_condition_test.rb +42 -0
- data/test/scorm2004/manifest/rollup_conditions_test.rb +53 -0
- data/test/scorm2004/manifest/rollup_considerations_test.rb +42 -0
- data/test/scorm2004/manifest/rollup_rule_test.rb +87 -0
- data/test/scorm2004/manifest/rollup_rules_test.rb +60 -0
- data/test/scorm2004/manifest/rule_action_test.rb +79 -0
- data/test/scorm2004/manifest/rule_condition_test.rb +70 -0
- data/test/scorm2004/manifest/rule_conditions_test.rb +37 -0
- data/test/scorm2004/manifest/schema_test.rb +29 -0
- data/test/scorm2004/manifest/schemaversion_test.rb +29 -0
- data/test/scorm2004/manifest/sequencing_collection_test.rb +31 -0
- data/test/scorm2004/manifest/sequencing_rules_test.rb +36 -0
- data/test/scorm2004/manifest/sequencing_test.rb +42 -0
- data/test/scorm2004/manifest/string_attribute_test.rb +68 -0
- data/test/scorm2004/manifest/text_node_test.rb +37 -0
- data/test/scorm2004/manifest/time_limit_action_test.rb +51 -0
- data/test/scorm2004/manifest/title_test.rb +59 -0
- data/test/scorm2004/manifest/token_attribute_test.rb +53 -0
- data/test/scorm2004/manifest/visitor_pattern_test.rb +85 -0
- data/test/scorm2004/manifest/xml_base_test.rb +125 -0
- data/test/scorm2004/manifest_test.rb +33 -0
- data/test/scorm2004_test.rb +9 -0
- data/test/sece_test.rb +53 -0
- metadata +260 -0
@@ -0,0 +1,152 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class ManifestTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@v = Manifest.new
|
10
|
+
@v.stubs(:schema_visitor).returns(stub(:visit))
|
11
|
+
@v.stubs(:schemaversion_visitor).returns(stub(:visit))
|
12
|
+
@v.stubs(:resources_visitor).returns(stub(:visit))
|
13
|
+
@v.stubs(:organizations_visitor).returns(stub(:visit))
|
14
|
+
@v.stubs(:sequencing_collection_visitor).returns(stub(:visit))
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'a manifest visitor' do
|
18
|
+
should 'be able to handle xml:base' do
|
19
|
+
assert @v.respond_to? :base
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'a manifest visitor visiting a valid manifest element' do
|
24
|
+
should 'visit its offsprings and set attributes' do
|
25
|
+
@v.expects(:schema_visitor).once.returns(mock(:visit))
|
26
|
+
@v.expects(:schemaversion_visitor).once.returns(mock(:visit))
|
27
|
+
@v.expects(:resources_visitor).once.returns(mock(:visit))
|
28
|
+
@v.expects(:organizations_visitor).once.returns(mock(:visit))
|
29
|
+
@v.expects(:sequencing_collection_visitor).once.returns(mock(:visit))
|
30
|
+
el(<<-XML).accept(@v)
|
31
|
+
<dummy identifier="sample" version="1.0" xml:base="path/to/root/">
|
32
|
+
<metadata>
|
33
|
+
<schema />
|
34
|
+
<schemaversion />
|
35
|
+
</metadata>
|
36
|
+
<resources />
|
37
|
+
<organizations />
|
38
|
+
<imsss:sequencingCollection />
|
39
|
+
</dummy>
|
40
|
+
XML
|
41
|
+
assert_equal "sample", @v.identifier
|
42
|
+
assert_equal "1.0", @v.version
|
43
|
+
assert_equal Pathname('path/to/root'), @v.base
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'a manifest visitor visiting a manifest element without <schema>' do
|
48
|
+
should 'raise exceptoin' do
|
49
|
+
assert_error do
|
50
|
+
el(<<-XML).accept @v
|
51
|
+
<dummy identifier="sample" version="1.0">
|
52
|
+
<metadata>
|
53
|
+
<schemaversion />
|
54
|
+
</metadata>
|
55
|
+
<resources />
|
56
|
+
<organizations />
|
57
|
+
</dummy>
|
58
|
+
XML
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'a manifest visitor visiting a manifest element without <schemaversion>' do
|
64
|
+
should 'raise exceptoin' do
|
65
|
+
assert_error do
|
66
|
+
el(<<-XML).accept @v
|
67
|
+
<dummy identifier="sample" version="1.0">
|
68
|
+
<metadata>
|
69
|
+
<schema />
|
70
|
+
</metadata>
|
71
|
+
<resources />
|
72
|
+
<organizations />
|
73
|
+
</dummy>
|
74
|
+
XML
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'a manifest visitor visiting a manifest element without <resources>' do
|
80
|
+
should 'raise exceptoin' do
|
81
|
+
assert_error do
|
82
|
+
el(<<-XML).accept @v
|
83
|
+
<dummy identifier="sample" version="1.0">
|
84
|
+
<metadata>
|
85
|
+
<schema />
|
86
|
+
<schemaversion />
|
87
|
+
</metadata>
|
88
|
+
<organizations />
|
89
|
+
</dummy>
|
90
|
+
XML
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'a manifest visitor visiting a manifest element without <organizations>' do
|
96
|
+
should 'raise exceptoin' do
|
97
|
+
assert_error do
|
98
|
+
el(<<-XML).accept @v
|
99
|
+
<dummy identifier="sample" version="1.0">
|
100
|
+
<metadata>
|
101
|
+
<schema />
|
102
|
+
<schemaversion />
|
103
|
+
</metadata>
|
104
|
+
<resources />
|
105
|
+
</dummy>
|
106
|
+
XML
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'a manifest visitor visiting a manifest element without identifier' do
|
112
|
+
should 'raise exeption' do
|
113
|
+
assert_error do
|
114
|
+
el(<<-XML).accept(@v)
|
115
|
+
<dummy version="1.0">
|
116
|
+
<metadata>
|
117
|
+
<schema />
|
118
|
+
<schemaversion />
|
119
|
+
</metadata>
|
120
|
+
<resources />
|
121
|
+
<organizations />
|
122
|
+
</dummy>
|
123
|
+
XML
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'a manifest visitor visiting a manifest element with version too long' do
|
129
|
+
should 'raise exeption' do
|
130
|
+
assert_error do
|
131
|
+
el(<<-XML).accept(@v)
|
132
|
+
<dummy identifier="dummy" version="01234567890123456789x">
|
133
|
+
<metadata>
|
134
|
+
<schema />
|
135
|
+
<schemaversion />
|
136
|
+
</metadata>
|
137
|
+
<resources />
|
138
|
+
<organizations />
|
139
|
+
</dummy>
|
140
|
+
XML
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
private
|
146
|
+
|
147
|
+
def assert_error(&block)
|
148
|
+
assert_raise Manifest::Error, &block
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class MapInfoTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@v = MapInfo.new
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'an empty element causes error' do
|
13
|
+
assert_raise(MapInfo::Error) { el.accept(@v) }
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'default value' do
|
17
|
+
el('<dummy targetObjectiveID="dummy" />').accept(@v)
|
18
|
+
assert_equal true, @v.read_satisfied_status
|
19
|
+
assert_equal true, @v.read_normalized_measure
|
20
|
+
assert_equal false, @v.write_satisfied_status
|
21
|
+
assert_equal false, @v.write_normalized_measure
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'a visitor set attribute values as its attributes' do
|
25
|
+
el(<<-XML).accept(@v)
|
26
|
+
<dummy
|
27
|
+
targetObjectiveID="bar"
|
28
|
+
readSatisfiedStatus="0"
|
29
|
+
readNormalizedMeasure="0"
|
30
|
+
writeSatisfiedStatus="1"
|
31
|
+
writeNormalizedMeasure="1" />
|
32
|
+
XML
|
33
|
+
assert_equal 'bar', @v.target_objective_id
|
34
|
+
assert_equal false, @v.read_satisfied_status
|
35
|
+
assert_equal false, @v.read_normalized_measure
|
36
|
+
assert_equal true, @v.write_satisfied_status
|
37
|
+
assert_equal true, @v.write_normalized_measure
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class MapTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@v = Map.new
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'an empty element' do
|
13
|
+
assert_raise Map::Error do
|
14
|
+
el('<dummy />').accept(@v)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'default value' do
|
19
|
+
el('<dummy targetID="dummy" />').accept(@v)
|
20
|
+
assert_equal true, @v.read_shared_data
|
21
|
+
assert_equal true, @v.write_shared_data
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'attributes' do
|
25
|
+
el('<dummy targetID="foo" readSharedData="0" writeSharedData="0" />').accept(@v)
|
26
|
+
assert_equal 'foo', @v.target_id
|
27
|
+
assert_equal false, @v.read_shared_data
|
28
|
+
assert_equal false, @v.write_shared_data
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class MinNormalizedMeasureTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@v = MinNormalizedMeasure.new
|
10
|
+
end
|
11
|
+
|
12
|
+
[-1.0, 0, 1.0].each do |valid_value|
|
13
|
+
tag = "<dummy>#{valid_value}</dummy>"
|
14
|
+
test tag do
|
15
|
+
el(tag).accept(@v)
|
16
|
+
assert_equal valid_value, @v.to_f
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
[-1.0001, 1.0001].each do |invalid_value|
|
21
|
+
tag = "<dummy>#{invalid_value}</dummy>"
|
22
|
+
test tag do
|
23
|
+
assert_raise(MinNormalizedMeasure::Error) { el(tag).accept(@v) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class NavigationInterfaceTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@v = NavigationInterface.new
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'an empty element' do
|
13
|
+
assert el('<dummy />').accept(@v)
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'an element with children' do
|
17
|
+
hide_lmsui_visitor = mock()
|
18
|
+
hide_lmsui_visitor.expects(:visit).twice
|
19
|
+
@v.expects(:hide_lmsui_visitor).twice.returns(hide_lmsui_visitor)
|
20
|
+
assert el(<<-XML).accept(@v)
|
21
|
+
<dummy>
|
22
|
+
<adlnav:hideLMSUI />
|
23
|
+
<adlnav:hideLMSUI />
|
24
|
+
</dummy>
|
25
|
+
XML
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class NonNegativeIntegerAttributeTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
context 'a visitor with xs:nonNegativeInteger attribute' do
|
9
|
+
class Visitor
|
10
|
+
include VisitorPattern
|
11
|
+
include CustomError
|
12
|
+
include Attributes
|
13
|
+
|
14
|
+
attribute :non_negative_integer, 'foo'
|
15
|
+
end
|
16
|
+
|
17
|
+
setup do
|
18
|
+
@v = Visitor.new
|
19
|
+
end
|
20
|
+
|
21
|
+
should 'raise exception when visiting an empty element' do
|
22
|
+
assert_error do
|
23
|
+
el('<dummy />').accept(@v)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
%w( 0 +21 00009 411 ).each do |valid_number|
|
28
|
+
tag = "<dummy foo='#{valid_number}' />"
|
29
|
+
should "accept #{tag}" do
|
30
|
+
el(tag).accept(@v)
|
31
|
+
assert_equal Integer(valid_number, 10), @v.foo
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
%w( 1.000 -50 ).each do |invalid_number|
|
36
|
+
tag = "<dummy foo='#{invalid_number}' />"
|
37
|
+
should "raise exception when visiting #{tag}" do
|
38
|
+
assert_error { el(tag).accept(@v) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def assert_error(&block)
|
43
|
+
assert_raise Visitor::Error, &block
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'a visitor with xs:nonNegativeInteger attribute optional' do
|
48
|
+
class VisitorWithOptionalAttribute
|
49
|
+
include VisitorPattern
|
50
|
+
include CustomError
|
51
|
+
include Attributes
|
52
|
+
|
53
|
+
attribute :non_negative_integer, 'bar', allow_nil: true
|
54
|
+
end
|
55
|
+
|
56
|
+
should 'raise nothing' do
|
57
|
+
assert_nothing_raised do
|
58
|
+
el('<dummy />').accept(VisitorWithOptionalAttribute.new)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class ObjectiveTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@v = Objective.new
|
10
|
+
@v.stubs(:min_normalized_measure_visitor).returns(stub(:visit))
|
11
|
+
@v.stubs(:map_info_visitor).returns(stub(:visit))
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'an empty element cause error' do
|
15
|
+
assert_raise(Objective::Error) { el.accept(@v) }
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'default satisfiedByMeasure' do
|
19
|
+
el('<dummy objectiveID="dummy" />').accept(@v)
|
20
|
+
assert_equal false, @v.satisfied_by_measure
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'a visitor visits <minNormalizedMeasure>' do
|
24
|
+
@v.expects(:min_normalized_measure_visitor).once.returns(mock(:visit))
|
25
|
+
el(<<-XML).accept(@v)
|
26
|
+
<dummy objectiveID="dummy">
|
27
|
+
<imsss:minNormalizedMeasure />
|
28
|
+
</dummy>
|
29
|
+
XML
|
30
|
+
end
|
31
|
+
|
32
|
+
test 'a visitor visits multiple <mapInfo>s' do
|
33
|
+
map_info_visitor = mock()
|
34
|
+
map_info_visitor.expects(:visit).twice
|
35
|
+
@v.expects(:map_info_visitor).twice.returns(map_info_visitor)
|
36
|
+
el(<<-XML).accept(@v)
|
37
|
+
<dummy objectiveID="dummy">
|
38
|
+
<imsss:mapInfo />
|
39
|
+
<imsss:mapInfo />
|
40
|
+
</dummy>
|
41
|
+
XML
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class ObjectivesTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@v = Objectives.new
|
10
|
+
@v.stubs(:primary_objective_visitor).returns(stub(:visit))
|
11
|
+
@v.stubs(:objective_visitor).returns(stub(:visit))
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'an empty element causes error' do
|
15
|
+
assert_raise(Objectives::Error) { el.accept(@v) }
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'a minimal element' do
|
19
|
+
assert_nothing_raised { el('<dummy><imsss:primaryObjective />').accept(@v) }
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'a fat element' do
|
23
|
+
objective_visitor = mock()
|
24
|
+
objective_visitor.expects(:visit).twice
|
25
|
+
@v.expects(:objective_visitor).twice.returns(objective_visitor)
|
26
|
+
@v.expects(:primary_objective_visitor).once.returns(mock(:visit))
|
27
|
+
el(<<-XML).accept(@v)
|
28
|
+
<dummy>
|
29
|
+
<imsss:primaryObjective />
|
30
|
+
<imsss:objective />
|
31
|
+
<imsss:objective />
|
32
|
+
</dummy>
|
33
|
+
XML
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class OrganizationTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
context 'an organization visitor with its parent no base' do
|
9
|
+
setup do
|
10
|
+
@v = Organization.new
|
11
|
+
@v.stubs(:item_visitor).returns(stub(:visit))
|
12
|
+
@v.stubs(:title_visitor).returns(stub(:visit))
|
13
|
+
@v.stubs(:completion_threshold_visitor).returns(stub(:visit))
|
14
|
+
@v.stubs(:sequencing_visitor).returns(stub(:visit))
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'visiting a fully equipped element' do
|
18
|
+
setup do
|
19
|
+
item_visitor = mock()
|
20
|
+
item_visitor.expects(:visit).twice
|
21
|
+
@v.expects(:item_visitor).twice.returns(item_visitor)
|
22
|
+
@v.expects(:title_visitor).once.returns(mock(:visit))
|
23
|
+
@v.expects(:completion_threshold_visitor).once.returns(mock(:visit))
|
24
|
+
@v.expects(:sequencing_visitor).once.returns(mock(:visit))
|
25
|
+
el(<<-XML).accept(@v)
|
26
|
+
<organization identifier="toc1"
|
27
|
+
adlseq:objectivesGlobalToSystem=" false "
|
28
|
+
adlcp:sharedDataGlobalToSystem=" 0 ">
|
29
|
+
<item />
|
30
|
+
<item />
|
31
|
+
<title />
|
32
|
+
<adlcp:completionThreshold />
|
33
|
+
<imsss:sequencing />
|
34
|
+
</organization>
|
35
|
+
XML
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'set an identifier value as its attribute' do
|
39
|
+
assert_equal 'toc1', @v.identifier
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'set an objectivesGlobalToSystem value as its attribute' do
|
43
|
+
assert_equal false, @v.objectives_global_to_system
|
44
|
+
end
|
45
|
+
|
46
|
+
should 'set a sharedDataGlobalToSystem value as its attribute' do
|
47
|
+
assert_equal false, @v.shared_data_global_to_system
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'visiting an element with optional attributes missing' do
|
52
|
+
setup do
|
53
|
+
el(<<-XML).accept(@v)
|
54
|
+
<organization identifier="toc1">
|
55
|
+
<item />
|
56
|
+
<item />
|
57
|
+
<title />
|
58
|
+
</organization>
|
59
|
+
XML
|
60
|
+
end
|
61
|
+
|
62
|
+
should 'set default values as the optional attributes' do
|
63
|
+
assert_equal false, @v.objectives_global_to_system
|
64
|
+
assert_equal false, @v.shared_data_global_to_system
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'visiting an element without an item element' do
|
69
|
+
should 'raise exception' do
|
70
|
+
assert_error do
|
71
|
+
el('<organization identifier="b00"><title /></organization>').accept(@v)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'visiting an element without a title element' do
|
77
|
+
should 'raise exception' do
|
78
|
+
assert_error do
|
79
|
+
el('<organization identifier="b11"><item /></organization').accept(@v)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'an organization visitor with its parent having XML Base' do
|
86
|
+
setup do
|
87
|
+
@v = Organization.new(base: Pathname('path/to/base'))
|
88
|
+
@v.stubs(:item_visitor).returns(stub(:visit))
|
89
|
+
@v.stubs(:title_visitor).returns(stub(:visit))
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'visiting a minimal organization element with XML Base' do
|
93
|
+
should 'handle xml:base' do
|
94
|
+
el(<<-XML).accept(@v)
|
95
|
+
<organization identifier="toc2" xml:base="x/y/z/">
|
96
|
+
<item />
|
97
|
+
<title />
|
98
|
+
</organization>
|
99
|
+
XML
|
100
|
+
assert_equal Pathname('path/to/base/x/y/z'), @v.base
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def assert_error(&block)
|
108
|
+
assert_raise(Organization::Error, &block)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# LocalWords: el toc adlseq objectivesGlobalToSystem adlcp imsss
|
115
|
+
# LocalWords: sharedDataGlobalToSystem completionThreshold
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class OrganizationsTest < ActiveSupport::TestCase
|
6
|
+
include PartialManifest
|
7
|
+
|
8
|
+
context 'an organizations visitor' do
|
9
|
+
setup do
|
10
|
+
@v = Organizations.new
|
11
|
+
@v.stubs(:organization_visitor).returns(stub(:visit))
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'visiting an organizations element' do
|
15
|
+
should 'set the default value as its attribute' do
|
16
|
+
organization_visitor = mock()
|
17
|
+
organization_visitor.expects(:visit).twice
|
18
|
+
@v.expects(:organization_visitor).twice.returns(organization_visitor)
|
19
|
+
el(<<-XML).accept(@v)
|
20
|
+
<organizations default="t41">
|
21
|
+
<organization identifier="t41" />
|
22
|
+
<organization identifier="t42" />
|
23
|
+
</organizations>
|
24
|
+
XML
|
25
|
+
assert_equal 't41', @v.default
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'visiting an organizations element without a default attribute' do
|
30
|
+
should 'raise exceptoin' do
|
31
|
+
assert_error do
|
32
|
+
el('<organizations />').accept(@v)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'visiting an organizations element with its default organization not found' do
|
38
|
+
should 'raise exception' do
|
39
|
+
assert_error do
|
40
|
+
el('<organization default="t41" />').accept(@v)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'an organization visitor with its parent having an XML Base value' do
|
47
|
+
context 'visiting an organizations element' do
|
48
|
+
should 'handle XML Base' do
|
49
|
+
@v = Organizations.new(base: Pathname('a/b/c'))
|
50
|
+
@v.stubs(:organization_visitor).returns(stub(:visit))
|
51
|
+
el(<<-XML).accept(@v)
|
52
|
+
<organizations default="t41" xml:base="x/y/z/">
|
53
|
+
<organization identifier="t41" />
|
54
|
+
</organizations>
|
55
|
+
XML
|
56
|
+
assert_equal Pathname('a/b/c/x/y/z'), @v.base
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def assert_error(&block)
|
64
|
+
assert_raise Organizations::Error, &block
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module PartialManifest
|
4
|
+
def el(fragment = '<dummy />')
|
5
|
+
Nokogiri::XML(<<XML).root.at('./*', Scorm2004::Manifest::NS)
|
6
|
+
<?xml version = "1.0" standalone = "no"?>
|
7
|
+
<manifest identifier = "minimal_manifest" version = "1.0"
|
8
|
+
xmlns = "http://www.imsglobal.org/xsd/imscp_v1p1"
|
9
|
+
xmlns:adlcp = "http://www.adlnet.org/xsd/adlcp_v1p3"
|
10
|
+
xmlns:adlseq = "http://www.adlnet.org/xsd/adlseq_v1p3"
|
11
|
+
xmlns:adlnav = "http://www.adlnet.org/xsd/adlnav_v1p3"
|
12
|
+
xmlns:imsss = "http://www.imsglobal.org/xsd/imsss"
|
13
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
14
|
+
xsi:schemaLocation = "http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1.xsd
|
15
|
+
http://www.adlnet.org/xsd/adlcp_v1p3 adlcp_v1p3.xsd
|
16
|
+
http://www.adlnet.org/xsd/adlseq_v1p3 adlseq_v1p3.xsd
|
17
|
+
http://www.adlnet.org/xsd/adlnav_v1p3 adlnav_v1p3.xsd
|
18
|
+
http://www.imsglobal.org/xsd/imsss imsss_v1p0.xsd">
|
19
|
+
#{fragment}
|
20
|
+
</manifest>
|
21
|
+
XML
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../helper'
|
2
|
+
|
3
|
+
module Scorm2004
|
4
|
+
module Manifest
|
5
|
+
class PartialManifestTest < ActiveSupport::TestCase
|
6
|
+
class DummyVisitor
|
7
|
+
include PartialManifest
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'Partial manifest of a dummy element' do
|
11
|
+
setup do
|
12
|
+
@el = DummyVisitor.new.el('<dummy />')
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'be named dummy' do
|
16
|
+
assert_equal 'dummy', @el.name
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'be a Nokogiri node' do
|
20
|
+
assert_kind_of Nokogiri::XML::Node, @el
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'Partial manifest of nil' do
|
25
|
+
setup do
|
26
|
+
@el = DummyVisitor.new.el(nil)
|
27
|
+
end
|
28
|
+
|
29
|
+
should 'be nil' do
|
30
|
+
assert_nil @el
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'default partial manifest' do
|
35
|
+
should 'return an empty element' do
|
36
|
+
el = DummyVisitor.new.el
|
37
|
+
assert_kind_of Nokogiri::XML::Node, el
|
38
|
+
assert_equal 'dummy', el.name
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|