verso 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.gitignore +2 -0
  2. data/README.md +10 -22
  3. data/lib/verso.rb +10 -2
  4. data/lib/verso/base.rb +50 -0
  5. data/lib/verso/cluster.rb +55 -25
  6. data/lib/verso/cluster_list.rb +15 -10
  7. data/lib/verso/correlation_list.rb +30 -40
  8. data/lib/verso/course.rb +106 -43
  9. data/lib/verso/course_list.rb +57 -21
  10. data/lib/verso/credential.rb +94 -20
  11. data/lib/verso/credential_list.rb +30 -15
  12. data/lib/verso/duty_area.rb +23 -10
  13. data/lib/verso/edition_list.rb +18 -10
  14. data/lib/verso/emphasis.rb +26 -12
  15. data/lib/verso/emphasis_list.rb +18 -10
  16. data/lib/verso/examination_list.rb +28 -12
  17. data/lib/verso/extra.rb +34 -32
  18. data/lib/verso/extras_list.rb +28 -12
  19. data/lib/verso/frontmatter.rb +43 -11
  20. data/lib/verso/hash.rb +19 -0
  21. data/lib/verso/http_gettable.rb +31 -0
  22. data/lib/verso/occupation.rb +36 -14
  23. data/lib/verso/occupation_data.rb +35 -14
  24. data/lib/verso/occupation_list.rb +23 -20
  25. data/lib/verso/pathway.rb +32 -14
  26. data/lib/verso/program_area.rb +42 -21
  27. data/lib/verso/program_area_list.rb +15 -11
  28. data/lib/verso/standard.rb +45 -23
  29. data/lib/verso/standards_list.rb +41 -30
  30. data/lib/verso/task.rb +52 -17
  31. data/lib/verso/task_list.rb +40 -17
  32. data/lib/verso/version.rb +1 -1
  33. data/spec/cluster_list_spec.rb +78 -5
  34. data/spec/cluster_spec.rb +106 -9
  35. data/spec/correlation_list_spec.rb +108 -50
  36. data/spec/course_list_spec.rb +112 -23
  37. data/spec/course_spec.rb +321 -127
  38. data/spec/credential_list_spec.rb +83 -52
  39. data/spec/credential_spec.rb +358 -19
  40. data/spec/duty_area_spec.rb +47 -17
  41. data/spec/edition_list_spec.rb +90 -4
  42. data/spec/emphasis_list_spec.rb +75 -11
  43. data/spec/emphasis_spec.rb +37 -21
  44. data/spec/examination_list_spec.rb +146 -20
  45. data/spec/extra_spec.rb +61 -22
  46. data/spec/extras_list_spec.rb +80 -17
  47. data/spec/frontmatter_spec.rb +141 -6
  48. data/spec/hash_spec.rb +49 -0
  49. data/spec/occupation_data_spec.rb +31 -13
  50. data/spec/occupation_list_spec.rb +88 -15
  51. data/spec/occupation_spec.rb +72 -28
  52. data/spec/pathway_spec.rb +47 -27
  53. data/spec/program_area_list_spec.rb +78 -4
  54. data/spec/program_area_spec.rb +70 -22
  55. data/spec/standard_spec.rb +94 -36
  56. data/spec/standards_list_spec.rb +130 -36
  57. data/spec/task_list_spec.rb +160 -51
  58. data/spec/task_spec.rb +120 -33
  59. data/verso.gemspec +3 -1
  60. metadata +41 -17
  61. data/lib/verso/http_get.rb +0 -9
  62. data/lib/verso/sol_correlation_list.rb +0 -53
  63. data/spec/sol_correlation_list_spec.rb +0 -74
@@ -1,193 +1,387 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::Course do
4
+ use_vcr_cassette :record => :new_episodes
5
+
4
6
  before do
5
- credentials = [{
6
- "title" => "Certification 1", "type" => "Certification"
7
- },
8
- {"title" => "License 1", "type" => "License" }]
9
- prerequisite_courses = [{
10
- "code" => "2222", "hours" => nil, "duration" => 36,
11
- "title" => "Basketweaving", "co_op" => true
12
- }]
13
- occupation_data = [{
14
- "cluster" => { "title" => "Information Technology" },
15
- "pathway" => { "title" => "Information and Support Services" },
16
- "occupations" => [{ "title" => "Database Analyst" }]
17
- }]
18
- @extra = double("ExtrasList", :title => "Extra Title",
19
- :name => "extra_name")
20
- @course = Verso::Course.new("code" => "6321", "duration" => 36,
21
- "title" => "Accounting, Advanced",
22
- "hours" => nil, "edition" => "2011",
23
- "co_op" => true,
24
- "related_resources" => ["extras"],
25
- "grade_levels" => "8 9 10",
26
- "credentials" => credentials,
27
- "occupation_data" => occupation_data,
28
- "related_courses" => prerequisite_courses,
29
- "prerequisite_courses" => prerequisite_courses)
7
+ @course = Verso::Course.new(:code => "6321",
8
+ :edition => Verso::EditionList.new.last.year)
30
9
  end
31
10
 
32
- it "responds to #extras" do
33
- Verso::ExtrasList.should_receive(:new).and_return([@extra])
34
- @course.extras.first.title.should eq("Extra Title")
11
+ describe '#certifications' do
12
+ it 'responds' do
13
+ @course.should respond_to(:certifications)
14
+ end
15
+
16
+ it 'is an Array' do
17
+ @course.certifications.should be_a(Array)
18
+ end
19
+
20
+ it 'is an Array of Verso::Credential objects' do
21
+ @course.certifications.first.should be_a(Verso::Credential)
22
+ end
23
+
24
+ it "is an Array of Verso::Credential objects with type 'Certification'" do
25
+ @course.certifications.first.type.should == 'Certification'
26
+ end
35
27
  end
36
28
 
37
- it "responds to #related_courses" do
38
- @course.related_courses.first.code.should eq('2222')
29
+ describe '#co_op' do
30
+ it 'responds' do
31
+ @course.should respond_to(:co_op)
32
+ end
33
+
34
+ it 'is Boolean' do
35
+ @course.co_op.should be_true
36
+ end
39
37
  end
40
38
 
41
- it "responds to #is_ms?" do
42
- @course.is_ms?.should eq(true)
39
+ describe '#co_op?' do
40
+ it 'responds' do
41
+ @course.should respond_to(:co_op?)
42
+ end
43
+
44
+ it 'is Boolean' do
45
+ @course.should be_co_op
46
+ end
43
47
  end
44
48
 
45
- it "responds to #is_hs?" do
46
- @course.is_hs?.should eq(true)
49
+ describe '#complement' do
50
+ it 'responds' do
51
+ @course.should respond_to(:complement)
52
+ end
53
+
54
+ it 'is Boolean' do
55
+ @course.complement.should be_false
56
+ end
47
57
  end
48
58
 
49
- it "responds to #code" do
50
- @course.code.should eq("6321")
59
+ describe '#complement?' do
60
+ it 'responds' do
61
+ @course.should respond_to(:complement?)
62
+ end
63
+
64
+ it 'is Boolean' do
65
+ @course.should_not be_complement
66
+ end
51
67
  end
52
68
 
53
- it "responds to #duration" do
54
- @course.duration.should eq(36)
69
+ describe '#code' do
70
+ it 'responds' do
71
+ @course.should respond_to(:code)
72
+ end
73
+
74
+ it 'is a String' do
75
+ @course.code.should be_a(String)
76
+ end
77
+
78
+ it 'looks like a course code' do
79
+ @course.code.should match(/\d{4}/)
80
+ end
55
81
  end
56
82
 
57
- it "responds to #title" do
58
- @course.title.strip.should eq("Accounting, Advanced")
83
+ describe '#credentials' do
84
+ it 'responds' do
85
+ @course.should respond_to(:credentials)
86
+ end
87
+
88
+ it 'is an Array' do
89
+ @course.credentials.should be_a(Array)
90
+ end
91
+
92
+ it 'is an Array of Verso::Credential objects' do
93
+ @course.credentials.first.should be_a(Verso::Credential)
94
+ end
59
95
  end
60
96
 
61
- it "responds to #edition" do
62
- @course.edition.should eq("2011")
97
+ describe '#description' do
98
+ it 'responds' do
99
+ @course.should respond_to(:description)
100
+ end
101
+
102
+ it 'is a String' do
103
+ @course.description.should be_a(String)
104
+ end
105
+
106
+ it 'looks like HTML' do
107
+ @course.description.should match(/<\/.+>/)
108
+ end
63
109
  end
64
110
 
65
- it "responds to #hours" do
66
- dental = Verso::Course.new("hours" => 280)
67
- dental.hours.should eq(280)
111
+ describe '#duration' do
112
+ it 'responds' do
113
+ @course.should respond_to(:duration)
114
+ end
115
+
116
+ it 'is a Fixnum' do
117
+ @course.duration.should be_a(Fixnum)
118
+ end
68
119
  end
69
120
 
70
- it "responds to #co_op" do
71
- @course.co_op.should eq(true)
72
- Verso::Course.new("co_op" => false).co_op.should eq(false)
121
+ describe '#duty_areas' do
122
+ it 'responds' do
123
+ @course.should respond_to(:duty_areas)
124
+ end
125
+
126
+ it 'is a Verso::TaskList' do
127
+ @course.duty_areas.should be_a(Verso::TaskList)
128
+ end
73
129
  end
74
130
 
75
- it "responds to #duty_areas" do
76
- @task = double("Task", :statement => "a task", :id => "999999",
77
- :sensitive => false, :essential => true)
78
- @duty_area = double("DutyArea", :title => "A Duty Area",
79
- :tasks => [@task])
80
- Verso::TaskList.should_receive(:new).
81
- with(:code => "6321", :edition => "2011").
82
- and_return([@duty_area])
83
- @course.duty_areas.first.should eq(@duty_area)
131
+ describe '#extras' do
132
+ it 'responds' do
133
+ @course.should respond_to(:extras)
134
+ end
135
+
136
+ it 'is a Verso::ExtrasList' do
137
+ @course.extras.should be_a(Verso::ExtrasList)
138
+ end
84
139
  end
85
140
 
86
- it "responds to #occupation_data" do
87
- @occupation = double("Occupation", :title => "Database Analyst")
88
- @pathway = double("Pathway", :title => "Information Support and Services")
89
- @cluster = double("Cluster", :title => "Information Technology")
90
- @occlist = double("OccupationData",
91
- :cluster => @cluster,
92
- :occupations => [@occupation],
93
- :pathway => @pathway)
94
- Verso::OccupationData.should_receive(:new).and_return(@occlist)
95
- @course.occupation_data.first.should eq(@occlist)
141
+ describe '#frontmatter' do
142
+ it 'responds' do
143
+ @course.should respond_to(:frontmatter)
144
+ end
145
+
146
+ it 'is a Verso::Frontmatter object' do
147
+ @course.frontmatter.should be_a(Verso::Frontmatter)
148
+ end
96
149
  end
97
150
 
98
- it "responds to prerequisites" do
99
- @course.prerequisites.first.code.should eq('2222')
151
+ describe '#grade_levels' do
152
+ it 'responds' do
153
+ @course.should respond_to(:grade_levels)
154
+ end
155
+
156
+ it 'is a String' do
157
+ @course.grade_levels.should be_a(String)
158
+ end
159
+
160
+ it 'looks like grade levels' do
161
+ @course.grade_levels.should match(/\d{1,2} \d/)
162
+ end
100
163
  end
101
164
 
102
- it "responds to credentials" do
103
- @course.credentials.first.title.should eq("Certification 1")
104
- @course.credentials.last.title.should eq("License 1")
165
+ describe '#hours' do
166
+ it 'responds' do
167
+ @course.should respond_to(:hours)
168
+ end
169
+
170
+ it 'is Fixnum or nil' do
171
+ @course.hours.should == nil
172
+ dental = Verso::Course.new(:code => "8328",
173
+ :edition => Verso::EditionList.new.last.year)
174
+ dental.hours.should be_a(Fixnum)
175
+ end
105
176
  end
106
177
 
107
- it "responds to certifications" do
108
- @course.certifications.first.title.should eq("Certification 1")
109
- @course.certifications.count.should eq(1)
178
+ describe '#hs_credit_in_ms' do
179
+ it 'responds' do
180
+ @course.should respond_to(:hs_credit_in_ms)
181
+ end
182
+
183
+ it 'is Boolean' do
184
+ @course.hs_credit_in_ms.should be_false
185
+ end
110
186
  end
111
187
 
112
- it "responds to licenses" do
113
- @course.licenses.first.title.should eq("License 1")
114
- @course.licenses.count.should eq(1)
188
+ describe '#hs_credit_in_ms?' do
189
+ it 'responds' do
190
+ @course.should respond_to(:hs_credit_in_ms?)
191
+ end
192
+
193
+ it 'is Boolean' do
194
+ @course.should_not be_hs_credit_in_ms
195
+ end
115
196
  end
116
197
 
117
- it "responds to #standards" do
118
- Verso::StandardsList.
119
- should_receive(:from_course).
120
- with(@course).
121
- and_return(["phony"])
122
- @course.stub(:method_missing).and_return(["standards"])
123
- @course.standards.first.should eq("phony")
198
+ describe '#is_ms?' do
199
+ it 'responds' do
200
+ @course.should respond_to(:is_ms?)
201
+ end
202
+
203
+ it 'is Boolean' do
204
+ @course.is_ms?.should be_false
205
+ end
206
+
207
+ it 'is not middle school' do
208
+ @course.should_not be_is_ms
209
+ end
210
+ end
211
+
212
+ describe '#is_hs?' do
213
+ it 'responds' do
214
+ @course.should respond_to(:is_hs?)
215
+ end
216
+
217
+ it 'is Boolean' do
218
+ @course.is_hs?.should be_true
219
+ end
220
+
221
+ it 'is high school' do
222
+ @course.should be_is_hs
223
+ end
224
+ end
225
+
226
+ describe '#licenses' do
227
+ before(:each) do
228
+ @barber = Verso::Course.new(:code => "8740",
229
+ :edition => Verso::EditionList.new.last.year)
230
+ end
231
+
232
+ it 'responds' do
233
+ @barber.should respond_to(:licenses)
234
+ end
235
+
236
+ it 'is an Array' do
237
+ @barber.licenses.should be_a(Array)
238
+ end
239
+
240
+ it 'is an Array of Verso::Credential objects' do
241
+ @barber.licenses.first.should be_a(Verso::Credential)
242
+ end
243
+
244
+ it "is an Array of Verso::Credential objects with type 'License'" do
245
+ @barber.licenses.first.type.should == 'License'
246
+ end
124
247
  end
125
248
 
126
- it "responds to #task" do
127
- t = Verso::Task.new("code" => @course.code, "edition" => @course.edition,
128
- "id" => 99999999)
129
- Verso::Task.should_receive(:new).
130
- with("code" => @course.code,
131
- "edition" => @course.edition,
132
- "id" => 99999999).
133
- and_return(t)
134
- t = @course.task(99999999)
135
- t.code.should eq(@course.code)
249
+ describe '#occupation_data' do
250
+ it 'responds' do
251
+ @course.should respond_to(:occupation_data)
252
+ end
253
+
254
+ it 'is an Array' do
255
+ @course.occupation_data.should be_a(Array)
256
+ end
257
+
258
+ it 'is an Array of Verso::OccupationData objects' do
259
+ @course.occupation_data.first.should be_a(Verso::OccupationData)
260
+ end
136
261
  end
137
262
 
138
- it "responds to #frontmatter" do
139
- Verso::Frontmatter.should_receive(:new).
140
- with("code" => @course.code,
141
- "edition" => @course.edition).
142
- and_return("phony")
143
- @course.stub(:related_resources).and_return(["frontmatter"])
144
- @course.frontmatter.should eq("phony")
263
+ describe '#osha_exempt' do
264
+ it 'responds' do
265
+ @course.should respond_to(:osha_exempt)
266
+ end
267
+
268
+ it 'is Boolean' do
269
+ @course.osha_exempt.should be_false
270
+ end
145
271
  end
146
272
 
147
- it "#frontmatter returns nil if there is no frontmatter" do
148
- @course.stub(:related_resources).and_return([])
149
- @course.frontmatter.should eq(nil)
273
+ describe '#osha_exempt?' do
274
+ it 'responds' do
275
+ @course.should respond_to(:osha_exempt?)
276
+ end
277
+
278
+ it 'is Boolean' do
279
+ @course.osha_exempt?.should be_false
280
+ end
150
281
  end
151
282
 
152
- context "Only code and edition specified" do
153
- use_vcr_cassette :record => :new_episodes
283
+ describe '#prerequisite_courses' do
284
+ it 'responds' do
285
+ @course.should respond_to(:prerequisite_courses)
286
+ end
154
287
 
155
- before do
156
- @course = Verso::Course.new("code" => 6320, "edition" => "2011")
288
+ it 'is an Array' do
289
+ @course.prerequisite_courses.should be_a(Array)
157
290
  end
158
291
 
159
- it "responds to #title" do
160
- @course.title.should eq("Accounting")
292
+ it 'is an Array of Verso::Course objects' do
293
+ @course.prerequisite_courses.first.should be_a(Verso::Course)
161
294
  end
162
295
  end
163
296
 
164
- context "MS-only course" do
165
- before do
166
- @course = Verso::Course.new("code" => "6320", "edition" => "2011",
167
- "grade_levels" => "8")
297
+ describe '#prerequisites' do
298
+ it 'responds' do
299
+ @course.should respond_to(:prerequisites)
168
300
  end
169
301
 
170
- it 'knows it is ms' do
171
- @course.is_ms?.should eq(true)
302
+ it 'is an Array' do
303
+ @course.prerequisites.should be_a(Array)
304
+ end
305
+
306
+ it 'is an Array of Verso::Course objects' do
307
+ @course.prerequisites.first.should be_a(Verso::Course)
308
+ end
309
+ end
310
+
311
+ describe '#related_courses' do
312
+ it 'responds' do
313
+ @course.should respond_to(:related_courses)
314
+ end
315
+
316
+ it 'is an Array' do
317
+ @course.related_courses.should be_a(Array)
318
+ end
319
+
320
+ it 'is an Array of Verso::Course objects' do
321
+ @course.related_courses.first.should be_a(Verso::Course)
322
+ end
323
+ end
324
+
325
+ describe '#related_resources' do
326
+ it 'responds' do
327
+ @course.should respond_to(:related_resources)
328
+ end
329
+
330
+ it 'is an Array' do
331
+ @course.related_resources.should be_a(Array)
332
+ end
333
+
334
+ it 'is an Array of Strings' do
335
+ @course.related_resources.first.should be_a(String)
336
+ end
337
+
338
+ it "includes 'tasks'" do
339
+ @course.related_resources.should include('tasks')
340
+ end
341
+ end
342
+
343
+ describe '#standards' do
344
+ it 'responds' do
345
+ @course.should respond_to(:standards)
346
+ end
347
+
348
+ it 'is a Verso::StandardsList' do
349
+ @course.standards.should be_a(Verso::StandardsList)
350
+ end
351
+ end
352
+
353
+ describe '#task' do
354
+ it 'responds' do
355
+ @course.should respond_to(:task)
356
+ end
357
+
358
+ it 'returns a Verso::Task object' do
359
+ task_id = @course.duty_areas.last.tasks.first.id
360
+ @course.task(task_id).should be_a(Verso::Task)
361
+ end
362
+ end
363
+
364
+ describe '#tasklist' do
365
+ it 'responds' do
366
+ @course.should respond_to(:tasklist)
172
367
  end
173
368
 
174
- it 'knows it is not hs' do
175
- @course.is_hs?.should eq(false)
369
+ it 'is a Verso::TaskList' do
370
+ @course.tasklist.should be_a(Verso::TaskList)
176
371
  end
177
372
  end
178
373
 
179
- context 'HS-only course' do
180
- before do
181
- @course = Verso::Course.new("code" => "6320", "edition" => "2011",
182
- "grade_levels" => "10")
374
+ describe '#title' do
375
+ it 'responds' do
376
+ @course.should respond_to(:title)
183
377
  end
184
378
 
185
- it 'knows it is not ms' do
186
- @course.is_ms?.should eq(false)
379
+ it 'is a String' do
380
+ @course.title.should be_a(String)
187
381
  end
188
382
 
189
- it 'knows it is hs' do
190
- @course.is_hs?.should eq(true)
383
+ it 'is about Accounting' do
384
+ @course.title.should match(/Accounting/)
191
385
  end
192
386
  end
193
387
  end