This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
scorm_cloud_steps.rb
184 lines (145 loc) · 4.62 KB
/
scorm_cloud_steps.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
##
## Generic
##
Then /^I will get a valid url$/ do
@last_url.should match(/http\:\/\/.+/)
end
##
## Debug Service
##
When /^I ping the server$/ do
@last_response = @c.debug.ping
end
When /^I authping the server$/ do
@last_response = @c.debug.auth_ping
end
When /^I get the current time$/ do
@last_response = @c.debug.get_time
end
Then /^the response should be "([^"]*)"$/ do |arg1| #"
@last_response.should eq(arg1)
end
Then /^the resonse should be the current time$/ do
@last_response.should match(/\d+/)
end
##
## Upload Service
##
When /^I upload a package$/ do
token = @c.upload.get_upload_token
token.should_not be_nil
path = File.join(File.dirname(__FILE__), '..', '..', 'spec', 'small_scorm_package.zip')
@last_upload_path = @c.upload.upload_file(token, path)
@last_uploaded_dir, @last_uploaded_file = @last_upload_path.split('/')
@last_uploaded_file.should include('.zip')
end
Then /^the package files should be available$/ do
list = @c.upload.list_files.map { |f| f[:file] }
list.should include(@last_uploaded_file)
end
Then /^the package files should not be available$/ do
list = @c.upload.list_files.map { |f| f[:file] }
list.should_not include(@last_uploaded_file)
end
When /^I delete the package$/ do
@c.upload.delete_files(@last_uploaded_file)
end
When /^I delete a non\-existant package$/ do
@last_error = nil
begin
@c.upload.delete_files("thiscoursedoesnotexist")
rescue => e
puts e.inspect
@last_error = e
end
end
Then /^I should get an error$/ do
@last_error.should_not be_nil
end
##
## Course Service
##
When /^I import a course$/ do
@last_uploaded_file.should_not be_nil
@last_course_id = "small_scorm_course_#{rand(1000)}"
hash = @c.course.import_course(@last_course_id, @last_uploaded_path)
hash.should_not be_nil
hash[:title].should_not be_nil
end
Given /^a registered course$/ do
When "I import a course"
end
Then /^the course should be in the course list$/ do
@c.course.get_course_list.find { |c| c.id == @last_course_id}.should_not be_nil
end
Then /^there should be (\d+) courses? in the list$/ do |count|
@c.course.get_course_list.size.should eq(count.to_i)
end
When /^I delete the course$/ do
@c.course.delete_course(@last_course_id).should eq(true)
end
Then /^the course should not be in the course list$/ do
@c.course.get_course_list.find { |c| c.id == @last_course_id}.should be_nil
end
Then /^I can get a preview URL for the course$/ do
@c.course.preview(@last_course_id, "http://www.example.com").should match(/http:\/\/.+/)
end
Then /^the course will have a properties url$/ do
@c.course.properties(@last_course_id).should match(/http:\/\/.+/)
end
Then /^the course should exist$/ do
@c.course.exists(@last_course_id).should be_true
end
Then /^I can get the manifest for the course$/ do
xml = @c.course.get_manifest(@last_course_id)
doc = REXML::Document.new(xml)
doc.elements["//manifest"].should_not be_nil
end
Then /^I can get the attributes for the course$/ do
h = @c.course.get_attributes(@last_course_id)
h.should be_kind_of(Hash)
h[:showProgressBar].should eq("false")
h[:showCourseStructure].should eq("false")
end
When /^I update course attributes$/ do
updated = @c.course.update_attributes(@last_course_id,
{:desiredHeight => "700", :commCommitFrequency => "59999" })
updated[:desiredHeight].should eq("700")
updated[:commCommitFrequency].should eq("59999")
end
Then /^the course attributes should be updated$/ do
h = @c.course.get_attributes(@last_course_id)
h.should be_kind_of(Hash)
h[:desiredHeight].should eq("700")
h[:commCommitFrequency].should eq("59999")
end
##
## Registration
##
When /^I register a learner$/ do
@last_reg_id = "small_scorm_course_#{rand(1000)}"
r = @c.registration.create_registration(@last_course_id, @last_reg_id,
"fname", "lname", "lid", :email => "lid@example.com")
r.should be_true
end
Then /^the learner should be in the registration list$/ do
list = @c.registration.get_registration_list
list.find { |r| r.id == @last_reg_id }.should_not be_nil
end
Then /^the learner should not be in the registration list$/ do
list = @c.registration.get_registration_list
list.find { |r| r.id == @last_reg_id }.should be_nil
end
When /^I delete the registration$/ do
@c.registration.delete_registration(@last_reg_id).should be_true
end
When /^I reset the registration$/ do
@c.registration.reset_registration(@last_reg_id).should be_true
end
When /^I launch the course$/ do
@last_url = @c.registration.launch(@last_reg_id, "http://www.example.com/")
end
Then /^I can get the registration results$/ do
@reg_results = @c.registration.get_registration_result(@last_reg_id, "full")
@reg_results.should include('<rsp stat="ok"><registrationreport')
end