verso 0.0.2 → 0.0.3

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.
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,75 +1,106 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::CredentialList do
4
- context "complete list" do
5
- before do
6
- Net::HTTP.
7
- should_receive(:get).
8
- with('api.cteresource.org', "/credentials", 80).
9
- and_return(
10
- JSON.pretty_generate(
11
- :credentials => [ { :type => "Certification",
12
- :source => { :title => "NOCTI" },
13
- :title => "Business Financial Management",
14
- :id => 845 } ]
15
- )
16
- )
4
+ use_vcr_cassette :record => :new_episodes
5
+ describe 'array-like behavior' do
6
+ before(:each) do
17
7
  @credentials = Verso::CredentialList.new
18
8
  end
19
9
 
20
- it 'responds to #first' do
21
- credential = @credentials.first
22
- credential.title.should eq("Business Financial Management")
23
- credential.id.should eq(845)
10
+ describe '#[]' do
11
+ it 'responds' do
12
+ @credentials.should respond_to(:[])
13
+ end
14
+
15
+ it 'gets a Verso::Credential object' do
16
+ @credentials[10].should be_a(Verso::Credential)
17
+ end
18
+ end
19
+
20
+ describe '#each' do
21
+ it 'responds' do
22
+ @credentials.should respond_to(:each)
23
+ end
24
+
25
+ it 'yields' do
26
+ expect { |b| @credentials.each("foo", &b).to yield_control }
27
+ end
28
+
29
+ it 'yields Verso::Credential objects' do
30
+ @credentials.each { |c| c.should be_a(Verso::Credential) }
31
+ end
32
+ end
33
+
34
+ describe '#empty?' do
35
+ it 'responds' do
36
+ @credentials.should respond_to(:empty?)
37
+ end
38
+
39
+ it 'is not empty' do
40
+ @credentials.should_not be_empty
41
+ end
42
+ end
43
+
44
+ describe '#last' do
45
+ it 'responds' do
46
+ @credentials.should respond_to(:last)
47
+ end
48
+
49
+ it 'is a Verso::Credential object' do
50
+ @credentials.last.should be_a(Verso::Credential)
51
+ end
24
52
  end
25
53
 
26
- it 'responds to #last' do
27
- credential = @credentials.last
28
- credential.title.should eq("Business Financial Management")
29
- credential.id.should eq(845)
54
+ describe '#length' do
55
+ it 'responds' do
56
+ @credentials.should respond_to(:length)
57
+ end
58
+
59
+ it 'is a Fixnum' do
60
+ @credentials.length.should be_a(Fixnum)
61
+ end
30
62
  end
31
63
 
32
- it 'responds to #empty?' do
33
- @credentials.empty?.should eq(false)
64
+ describe '#first' do
65
+ it 'responds' do
66
+ @credentials.should respond_to(:first)
67
+ end
68
+
69
+ it 'is a Verso::Credential object' do
70
+ @credentials.first.should be_a(Verso::Credential)
71
+ end
72
+ end
73
+
74
+ describe '#count' do
75
+ it 'responds' do
76
+ @credentials.should respond_to(:count)
77
+ end
78
+
79
+ it 'is a Fixnum' do
80
+ @credentials.count.should be_a(Fixnum)
81
+ end
34
82
  end
35
83
  end
36
84
 
37
- context "search list" do
38
- before do
39
- Net::HTTP.
40
- should_receive(:get).
41
- with('api.cteresource.org', "/credentials?text=nocti", 80).
42
- and_return(
43
- JSON.pretty_generate(
44
- :credentials => [ { :type => "Certification",
45
- :source => { :title => "NOCTI" },
46
- :title => "Basket weaving",
47
- :id => 855 } ]
48
- )
49
- )
85
+ describe 'search' do
86
+ before(:each) do
50
87
  @credentials = Verso::CredentialList.new(:text => 'nocti')
51
88
  end
52
89
 
53
- it 'searches credentials' do
54
- credential = @credentials.first
55
- credential.title.should eq("Basket weaving")
56
- credential.id.should eq(855)
90
+ it 'is a collection of Verso::Credential objects' do
91
+ @credentials.first.should be_a(Verso::Credential)
57
92
  end
58
- end
59
93
 
60
- context "search list with empty string" do
61
- before do
62
- Net::HTTP.
63
- should_receive(:get).
64
- with('api.cteresource.org', "/credentials", 80).
65
- and_return(
66
- JSON.pretty_generate(:credentials => [])
67
- )
68
- @credentials = Verso::CredentialList.new(:text => '')
94
+ it 'is related to the search term' do
95
+ @credentials.first.source.title.should match (/NOCTI/)
69
96
  end
97
+ end
70
98
 
71
- it 'searches credentials' do
72
- @credentials.empty?
99
+ describe 'empty search' do
100
+ it 'gives you everything' do
101
+ Verso::CredentialList.new(:text => '').count.should eq(
102
+ Verso::CredentialList.new.count
103
+ )
73
104
  end
74
105
  end
75
106
  end
@@ -1,34 +1,373 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::Credential do
4
+ use_vcr_cassette :record => :new_episodes
4
5
  before do
5
- @credential = Verso::Credential.new("id" => 880)
6
- Net::HTTP.stub(:get).and_return(
7
- JSON.pretty_generate(
8
- :credential => { :id => 880, :title => "Computer Programming (NOCTI)",
9
- :source => { :title => "National Occupational" },
10
- :details => nil,
11
- :related_courses => [{ :code => '6641' }] }
12
- )
13
- )
6
+ @credential = Verso::CredentialList.new.last
14
7
  end
15
- it 'responds to #id' do
16
- @credential.id.should eq(880)
8
+
9
+ describe '#admin_notes' do
10
+ it 'responds' do
11
+ @credential.should respond_to(:admin_notes)
12
+ end
13
+
14
+ it 'is a String' do
15
+ @credential.admin_notes.should be_a(String)
16
+ end
17
+
18
+ it 'looks like HTML' do
19
+ @credential.admin_notes.should match(/<\/.+>/)
20
+ end
21
+ end
22
+
23
+ describe '#amt_seal' do
24
+ it 'responds' do
25
+ @credential.should respond_to(:amt_seal)
26
+ end
27
+
28
+ it 'is a Boolean' do
29
+ @credential.amt_seal.to_s.should match(/true|false/)
30
+ end
31
+ end
32
+
33
+ describe '#amt_seal?' do
34
+ it 'responds' do
35
+ @credential.should respond_to(:amt_seal?)
36
+ end
37
+
38
+ it 'is a Boolean' do
39
+ @credential.amt_seal?.to_s.should match(/true|false/)
40
+ end
41
+ end
42
+
43
+ describe '#contact_info' do
44
+ it 'responds' do
45
+ @credential.should respond_to(:contact_info)
46
+ end
47
+
48
+ it 'is a String' do
49
+ @credential.contact_info.should be_a(String)
50
+ end
51
+
52
+ it 'looks like HTML' do
53
+ @credential.contact_info.should match(/<\/.+>/)
54
+ end
55
+ end
56
+
57
+ describe '#contacts' do
58
+ it 'responds' do
59
+ @credential.should respond_to(:contacts)
60
+ end
61
+
62
+ it 'is an Array' do
63
+ @credential.contacts.should be_a(Array)
64
+ end
65
+
66
+ it 'each item is an OpenStruct object' do
67
+ @credential.contacts.first.should be_a(OpenStruct)
68
+ end
69
+
70
+ it 'each contact has a name' do
71
+ @credential.contacts.first.name.should be_a(String)
72
+ end
73
+
74
+ it 'each contact has an email' do
75
+ @credential.contacts.first.email.should match(/.+@doe.virginia.gov/)
76
+ end
77
+
78
+ it 'each contact has a phone' do
79
+ @credential.contacts.first.phone.should match(/804-\d{3}-\d{4}/)
80
+ end
81
+ end
82
+
83
+ describe '#contractor_name' do
84
+ it 'responds' do
85
+ @credential.should respond_to(:contractor_name)
86
+ end
87
+
88
+ it 'is a String' do
89
+ @credential.contractor_name.should be_a(String)
90
+ end
91
+
92
+ it 'is still a String if the API sends nil' do
93
+ cred = Verso::Credential.new(:contractor_name => nil)
94
+ cred.contractor_name.should be_a(String)
95
+ end
96
+ end
97
+
98
+ describe '#cost' do
99
+ it 'responds' do
100
+ @credential.should respond_to(:cost)
101
+ end
102
+
103
+ it 'is a String' do
104
+ @credential.cost.should be_a(String)
105
+ end
106
+ end
107
+
108
+ describe '#cte_seal' do
109
+ it 'responds' do
110
+ @credential.should respond_to(:cte_seal)
111
+ end
112
+
113
+ it 'is a Boolean' do
114
+ @credential.cte_seal.to_s.should match(/true|false/)
115
+ end
116
+ end
117
+
118
+ describe '#cte_seal?' do
119
+ it 'responds' do
120
+ @credential.should respond_to(:cte_seal?)
121
+ end
122
+
123
+ it 'is a Boolean' do
124
+ @credential.cte_seal?.to_s.should match(/true|false/)
125
+ end
126
+ end
127
+
128
+ describe '#description' do
129
+ it 'responds' do
130
+ @credential.should respond_to(:description)
131
+ end
132
+
133
+ it 'is a String' do
134
+ @credential.description.should be_a(String)
135
+ end
136
+ end
137
+
138
+ describe '#details' do
139
+ it 'responds' do
140
+ @credential.should respond_to(:details)
141
+ end
142
+
143
+ it 'is a String' do
144
+ @credential.details.should be_a(String)
145
+ end
146
+
147
+ it 'looks like HTML' do
148
+ @credential.details.should match(/<\/.+>/)
149
+ end
150
+ end
151
+
152
+ describe '#has_ancestor' do
153
+ it 'responds' do
154
+ @credential.should respond_to(:has_ancestor)
155
+ end
156
+
157
+ it 'is a Boolean' do
158
+ @credential.has_ancestor.to_s.should match(/true|false/)
159
+ end
160
+ end
161
+
162
+ describe '#has_ancestor?' do
163
+ it 'responds' do
164
+ @credential.should respond_to(:has_ancestor?)
165
+ end
166
+
167
+ it 'is a Boolean' do
168
+ @credential.has_ancestor?.to_s.should match(/true|false/)
169
+ end
170
+ end
171
+
172
+ describe '#how_to_earn_it' do
173
+ it 'responds' do
174
+ @credential.should respond_to(:how_to_earn_it)
175
+ end
176
+
177
+ it 'is a String' do
178
+ @credential.how_to_earn_it.should be_a(String)
179
+ end
180
+ end
181
+
182
+ describe '#id' do
183
+ it 'responds' do
184
+ @credential.should respond_to(:id)
185
+ end
186
+
187
+ it 'is a Fixnum' do
188
+ @credential.id.should be_a(Fixnum)
189
+ end
190
+
191
+ it 'is not the same as #object_id' do
192
+ @credential.id.should_not == @credential.object_id
193
+ end
194
+ end
195
+
196
+ describe '#items' do
197
+ it 'responds' do
198
+ @credential.should respond_to(:items)
199
+ end
200
+
201
+ it 'is a String' do
202
+ @credential.items.should be_a(String)
203
+ end
204
+ end
205
+
206
+ describe '#passing_score' do
207
+ it 'responds' do
208
+ @credential.should respond_to(:passing_score)
209
+ end
210
+
211
+ it 'is a String' do
212
+ @credential.passing_score.should be_a(String)
213
+ end
214
+ end
215
+
216
+ describe '#pretest' do
217
+ it 'responds' do
218
+ @credential.should respond_to(:pretest)
219
+ end
220
+
221
+ it 'is a Boolean or nil' do
222
+ @credential.pretest.should_not be_a(String)
223
+ @credential.pretest.to_s.should match(/^$|true|false/)
224
+ end
225
+
226
+ it 'no really it might be nil' do
227
+ cred = Verso::Credential.new(:pretest => nil)
228
+ cred.pretest.to_s.should match(/^$|true|false/)
229
+ cred = Verso::Credential.new(:pretest => "foo")
230
+ cred.pretest.to_s.should_not match(/^$|true|false/)
231
+ end
232
+ end
233
+
234
+ describe '#proctor' do
235
+ it 'responds' do
236
+ @credential.should respond_to(:proctor)
237
+ end
238
+
239
+ it 'is a String' do
240
+ @credential.proctor.should be_a(String)
241
+ end
242
+ end
243
+
244
+ describe '#program_area' do
245
+ it 'responds' do
246
+ @credential.should respond_to(:program_area)
247
+ end
248
+
249
+ it 'is a String' do
250
+ @credential.program_area.should be_a(String)
251
+ end
252
+ end
253
+
254
+ describe '#related_courses' do
255
+ it 'responds' do
256
+ @credential.should respond_to(:related_courses)
257
+ end
258
+
259
+ it 'is an Array' do
260
+ @credential.related_courses.should be_a(Array)
261
+ end
262
+
263
+ it 'is an Array of Verso::Course objects' do
264
+ @credential.related_courses.first.should be_a(Verso::Course)
265
+ end
266
+ end
267
+
268
+ describe '#retired' do
269
+ it 'responds' do
270
+ @credential.should respond_to(:retired)
271
+ end
272
+
273
+ it 'is a Boolean' do
274
+ @credential.retired.to_s.should match(/true|false/)
275
+ end
276
+ end
277
+
278
+ describe '#retired?' do
279
+ it 'responds' do
280
+ @credential.should respond_to(:retired?)
281
+ end
282
+
283
+ it 'is a Boolean' do
284
+ @credential.retired?.to_s.should match(/true|false/)
285
+ end
286
+ end
287
+
288
+ describe '#site' do
289
+ it 'responds' do
290
+ @credential.should respond_to(:site)
291
+ end
292
+
293
+ it 'is a String' do
294
+ @credential.site.should be_a(String)
295
+ end
296
+ end
297
+
298
+ describe '#source' do
299
+ it 'responds' do
300
+ @credential.should respond_to(:source)
301
+ end
302
+
303
+ it 'is an OpenStruct object' do
304
+ @credential.source.should be_a(OpenStruct)
305
+ end
306
+
307
+ it 'has a title' do
308
+ @credential.source.title.should be_a(String)
309
+ end
310
+
311
+ it 'has a url' do
312
+ @credential.source.url.should match(/http:\/\/.+/)
313
+ end
314
+
315
+ it 'has HTML-formatted contact_info' do
316
+ @credential.source.contact_info.should match(/<\/.+>/)
317
+ end
318
+ end
319
+
320
+ describe '#time' do
321
+ it 'responds' do
322
+ @credential.should respond_to(:time)
323
+ end
324
+
325
+ it 'is a String' do
326
+ @credential.time.should be_a(String)
327
+ end
17
328
  end
18
329
 
19
- it 'responds to #title' do
20
- @credential.title.should eq("Computer Programming (NOCTI)")
330
+ describe '#type' do
331
+ it 'responds' do
332
+ @credential.should respond_to(:type)
333
+ end
334
+
335
+ it 'is a String' do
336
+ @credential.type.should be_a(String)
337
+ end
338
+
339
+ it "is either 'Certification' or 'License'" do
340
+ @credential.type.should match(/Certification|License/)
341
+ end
21
342
  end
22
343
 
23
- it 'responds to #source' do
24
- @credential.source.title.should eq("National Occupational")
344
+ describe '#title' do
345
+ it 'responds' do
346
+ @credential.should respond_to(:title)
347
+ end
348
+
349
+ it 'is a String' do
350
+ @credential.title.should be_a(String)
351
+ end
25
352
  end
26
353
 
27
- it 'responds to #details' do
28
- @credential.details.should eq('')
354
+ describe '#verified_credit' do
355
+ it 'responds' do
356
+ @credential.should respond_to(:verified_credit)
357
+ end
358
+
359
+ it 'is a Boolean' do
360
+ @credential.verified_credit.to_s.should match(/true|false/)
361
+ end
29
362
  end
30
363
 
31
- it 'responds to #related_courses' do
32
- @credential.related_courses.first.code.should eq('6641')
364
+ describe '#verified_credit?' do
365
+ it 'responds' do
366
+ @credential.should respond_to(:verified_credit?)
367
+ end
368
+
369
+ it 'is a Boolean' do
370
+ @credential.verified_credit?.to_s.should match(/true|false/)
371
+ end
33
372
  end
34
373
  end