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,27 +1,57 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::DutyArea do
4
+ use_vcr_cassette :record => :new_episodes
5
+
4
6
  before do
5
- context = double("context", :code => "6320", :edition => "2012")
6
- @duty_area = Verso::DutyArea.new({
7
- "title" => "A Duty Area",
8
- "tasks" => [{ "statement" => "Do this.",
9
- "id" => "12345",
10
- "sensitive" => false,
11
- "essential" => true } ]},
12
- context
13
- )
14
- @task = double("Task", :statement => "Do this.", :id => "12345",
15
- :sensitive => false, :essential => true,
16
- :code => "6320", :edition => "2012")
7
+ @da = Verso::CourseList.new(:code => "6320").last.duty_areas.last
17
8
  end
18
9
 
19
- it "responds to #title" do
20
- @duty_area.title.should eq("A Duty Area")
10
+ describe '#code' do
11
+ it "responds" do
12
+ @da.should respond_to(:code)
13
+ end
14
+
15
+ it 'is a String' do
16
+ @da.code.should be_a(String)
17
+ end
18
+
19
+ it 'is the code of our course' do
20
+ @da.code.should == '6320'
21
+ end
21
22
  end
22
23
 
23
- it "responds to #tasks" do
24
- Verso::Task.should_receive(:new).and_return(@task)
25
- @duty_area.tasks.first.statement.should eq("Do this.")
24
+ describe '#edition' do
25
+ it "responds" do
26
+ @da.should respond_to(:edition)
27
+ end
28
+
29
+ it 'is a String' do
30
+ @da.edition.should be_a(String)
31
+ end
32
+
33
+ it 'looks like a year' do
34
+ @da.edition.should match(/2\d{3}/)
35
+ end
36
+ end
37
+
38
+ describe '#title' do
39
+ it "responds" do
40
+ @da.should respond_to(:title)
41
+ end
42
+
43
+ it 'is a String' do
44
+ @da.title.should be_a(String)
45
+ end
46
+ end
47
+
48
+ describe '#tasks' do
49
+ it "responds" do
50
+ @da.should respond_to(:tasks)
51
+ end
52
+
53
+ it 'is a collection of Verso::Task objects' do
54
+ @da.tasks.first.should be_a(Verso::Task)
55
+ end
26
56
  end
27
57
  end
@@ -3,9 +3,95 @@ require 'spec_helper'
3
3
  describe Verso::EditionList do
4
4
  use_vcr_cassette :record => :new_episodes
5
5
 
6
- it "responds to #first, #last" do
7
- list = Verso::EditionList.new
8
- list.first.year.should match(/20\d\d/)
9
- list.last.year.should match(/20\d\d/)
6
+ before(:each) do
7
+ @editions = Verso::EditionList.new
8
+ end
9
+
10
+ describe 'array-like behavior' do
11
+ describe '#[]' do
12
+ it 'responds' do
13
+ @editions.should respond_to(:[])
14
+ end
15
+
16
+ it 'gets a OpenStruct object' do
17
+ @editions[0].should be_a(OpenStruct)
18
+ end
19
+ end
20
+
21
+ describe '#each' do
22
+ it 'responds' do
23
+ @editions.should respond_to(:each)
24
+ end
25
+
26
+ it 'yields' do
27
+ expect { |b| @editions.each("foo", &b).to yield_control }
28
+ end
29
+
30
+ it 'yields OpenStruct objects' do
31
+ @editions.each { |c| c.should be_a(OpenStruct) }
32
+ end
33
+ end
34
+
35
+ describe '#empty?' do
36
+ it 'responds' do
37
+ @editions.should respond_to(:empty?)
38
+ end
39
+
40
+ it 'is not empty' do
41
+ @editions.should_not be_empty
42
+ end
43
+ end
44
+
45
+ describe '#last' do
46
+ it 'responds' do
47
+ @editions.should respond_to(:last)
48
+ end
49
+
50
+ it 'is a OpenStruct object' do
51
+ @editions.last.should be_a(OpenStruct)
52
+ end
53
+ end
54
+
55
+ describe '#length' do
56
+ it 'responds' do
57
+ @editions.should respond_to(:length)
58
+ end
59
+
60
+ it 'is a Fixnum' do
61
+ @editions.length.should be_a(Fixnum)
62
+ end
63
+ end
64
+
65
+ describe '#first' do
66
+ it 'responds' do
67
+ @editions.should respond_to(:first)
68
+ end
69
+
70
+ it 'is a OpenStruct object' do
71
+ @editions.first.should be_a(OpenStruct)
72
+ end
73
+ end
74
+
75
+ describe '#count' do
76
+ it 'responds' do
77
+ @editions.should respond_to(:count)
78
+ end
79
+
80
+ it 'is a Fixnum' do
81
+ @editions.count.should be_a(Fixnum)
82
+ end
83
+ end
84
+ end
85
+
86
+ describe 'OpenStruct edition proxy' do
87
+ describe '#year' do
88
+ it 'responds' do
89
+ @editions.last.should respond_to(:year)
90
+ end
91
+
92
+ it 'looks like a year' do
93
+ @editions.first.year.should match(/2\d{3}/)
94
+ end
95
+ end
10
96
  end
11
97
  end
@@ -1,21 +1,85 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::EmphasisList do
4
+ use_vcr_cassette :record => :new_episodes
5
+
4
6
  before do
5
- @raw_edition_list = {
6
- "emphases" => [ { "title" => "Earth Science", "id" => 7 } ]
7
- }
8
- Net::HTTP.
9
- should_receive(:get).
10
- and_return(JSON.pretty_generate(@raw_edition_list))
11
7
  @emphases = Verso::EmphasisList.new
12
8
  end
13
9
 
14
- it 'should respond to #first' do
15
- @emphases.first.title.should eq("Earth Science")
16
- end
10
+ describe 'array-like behavior' do
11
+ describe '#[]' do
12
+ it 'responds' do
13
+ @emphases.should respond_to(:[])
14
+ end
15
+
16
+ it 'gets a Verso::Emphasis object' do
17
+ @emphases[10].should be_a(Verso::Emphasis)
18
+ end
19
+ end
20
+
21
+ describe '#each' do
22
+ it 'responds' do
23
+ @emphases.should respond_to(:each)
24
+ end
25
+
26
+ it 'yields' do
27
+ expect { |b| @emphases.each("foo", &b).to yield_control }
28
+ end
29
+
30
+ it 'yields Verso::Emphasis objects' do
31
+ @emphases.each { |c| c.should be_a(Verso::Emphasis) }
32
+ end
33
+ end
34
+
35
+ describe '#empty?' do
36
+ it 'responds' do
37
+ @emphases.should respond_to(:empty?)
38
+ end
39
+
40
+ it 'is not empty' do
41
+ @emphases.should_not be_empty
42
+ end
43
+ end
44
+
45
+ describe '#last' do
46
+ it 'responds' do
47
+ @emphases.should respond_to(:last)
48
+ end
49
+
50
+ it 'is a Verso::Emphasis object' do
51
+ @emphases.last.should be_a(Verso::Emphasis)
52
+ end
53
+ end
54
+
55
+ describe '#length' do
56
+ it 'responds' do
57
+ @emphases.should respond_to(:length)
58
+ end
59
+
60
+ it 'is a Fixnum' do
61
+ @emphases.length.should be_a(Fixnum)
62
+ end
63
+ end
64
+
65
+ describe '#first' do
66
+ it 'responds' do
67
+ @emphases.should respond_to(:first)
68
+ end
69
+
70
+ it 'is a Verso::Emphasis object' do
71
+ @emphases.first.should be_a(Verso::Emphasis)
72
+ end
73
+ end
74
+
75
+ describe '#count' do
76
+ it 'responds' do
77
+ @emphases.should respond_to(:count)
78
+ end
17
79
 
18
- it 'should responds to #last' do
19
- @emphases.last.title.should eq("Earth Science")
80
+ it 'is a Fixnum' do
81
+ @emphases.count.should be_a(Fixnum)
82
+ end
83
+ end
20
84
  end
21
85
  end
@@ -1,31 +1,47 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::Emphasis do
4
+ use_vcr_cassette :record => :new_episodes
5
+
4
6
  before do
5
- @emphasis = Verso::Emphasis.new("id" => 7, "title" => "Earth Science")
7
+ @emphasis = Verso::EmphasisList.new.last
8
+ end
9
+
10
+ describe '#title' do
11
+ it 'responds' do
12
+ @emphasis.should respond_to(:title)
13
+ end
14
+
15
+ it 'is a string' do
16
+ @emphasis.title.should be_a(String)
17
+ end
6
18
  end
7
19
 
8
- it 'responds to #title' do
9
- @emphasis.title.should eq("Earth Science")
20
+ describe '#id' do
21
+ it 'responds' do
22
+ @emphasis.should respond_to(:id)
23
+ end
24
+
25
+ it 'is a Fixnum' do
26
+ @emphasis.id.should be_a(Fixnum)
27
+ end
28
+
29
+ it 'is not the same as #object_id' do
30
+ @emphasis.id.should_not == @emphasis.object_id
31
+ end
10
32
  end
11
33
 
12
- it 'responds to #occupation_data' do
13
- occupation_data = [{
14
- "cluster" => { "title" => "Information Technology", "id" => 1 },
15
- "pathway" => { "title" => "Information and Support Services", "id" => 2 },
16
- "occupations" => [{ "title" => "Database Analyst", "id" => 3 }]
17
- }]
18
- Net::HTTP.should_receive(:get).
19
- with('api.cteresource.org', "/academics/7", 80).
20
- and_return(
21
- JSON.pretty_generate(
22
- :emphasis => {
23
- :id => 7, :title => "Earth Science",
24
- :occupation_data => occupation_data }
25
- )
26
- )
27
- @emphasis.occupation_data.first.cluster.title.should eq(
28
- "Information Technology"
29
- )
34
+ describe '#occupation_data' do
35
+ it 'responds' do
36
+ @emphasis.should respond_to(:occupation_data)
37
+ end
38
+
39
+ it 'is an Array' do
40
+ @emphasis.occupation_data.should be_a(Array)
41
+ end
42
+
43
+ it 'is an Array of Verso::ObjectData objects' do
44
+ @emphasis.occupation_data.first.should be_a(Verso::OccupationData)
45
+ end
30
46
  end
31
47
  end
@@ -1,29 +1,155 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::ExaminationList do
4
- before do
5
- Net::HTTP.
6
- should_receive(:get).
7
- with('api.cteresource.org', "/examinations/", 80).
8
- and_return(
9
- JSON.pretty_generate(
10
- :examinations => [ { :passing_score => "3",
11
- :source => "NOCTI",
12
- :title => "AP Computer Science",
13
- :retired => false,
14
- :amt_seal => true } ]
15
- )
16
- )
17
- @examinations = Verso::ExaminationList.new
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ before(:each) do
7
+ @exams = Verso::ExaminationList.new
18
8
  end
19
9
 
20
- it 'responds to #first' do
21
- exam = @examinations.first
22
- exam.title.should eq("AP Computer Science")
10
+ describe 'array-like behavior' do
11
+ describe '#[]' do
12
+ it 'responds' do
13
+ @exams.should respond_to(:[])
14
+ end
15
+
16
+ it 'gets a OpenStruct object' do
17
+ @exams[3].should be_a(OpenStruct)
18
+ end
19
+ end
20
+
21
+ describe '#each' do
22
+ it 'responds' do
23
+ @exams.should respond_to(:each)
24
+ end
25
+
26
+ it 'yields' do
27
+ expect { |b| @exams.each("foo", &b).to yield_control }
28
+ end
29
+
30
+ it 'yields OpenStruct objects' do
31
+ @exams.each { |c| c.should be_a(OpenStruct) }
32
+ end
33
+ end
34
+
35
+ describe '#empty?' do
36
+ it 'responds' do
37
+ @exams.should respond_to(:empty?)
38
+ end
39
+
40
+ it 'is not empty' do
41
+ @exams.should_not be_empty
42
+ end
43
+ end
44
+
45
+ describe '#last' do
46
+ it 'responds' do
47
+ @exams.should respond_to(:last)
48
+ end
49
+
50
+ it 'is a OpenStruct object' do
51
+ @exams.last.should be_a(OpenStruct)
52
+ end
53
+ end
54
+
55
+ describe '#length' do
56
+ it 'responds' do
57
+ @exams.should respond_to(:length)
58
+ end
59
+
60
+ it 'is a Fixnum' do
61
+ @exams.length.should be_a(Fixnum)
62
+ end
63
+ end
64
+
65
+ describe '#first' do
66
+ it 'responds' do
67
+ @exams.should respond_to(:first)
68
+ end
69
+
70
+ it 'is a OpenStruct object' do
71
+ @exams.first.should be_a(OpenStruct)
72
+ end
73
+ end
74
+
75
+ describe '#count' do
76
+ it 'responds' do
77
+ @exams.should respond_to(:count)
78
+ end
79
+
80
+ it 'is a Fixnum' do
81
+ @exams.count.should be_a(Fixnum)
82
+ end
83
+ end
23
84
  end
24
85
 
25
- it 'responds to #last' do
26
- exam = @examinations.last
27
- exam.title.should eq("AP Computer Science")
86
+ describe 'OpenStruct Examination stand-in' do
87
+ before(:each) do
88
+ @exam = Verso::ExaminationList.new.first
89
+ end
90
+
91
+ describe '#amt_seal' do
92
+ it 'responds' do
93
+ @exam.should respond_to(:amt_seal)
94
+ end
95
+
96
+ it 'is a Boolean' do
97
+ @exam.amt_seal.to_s.should match(/true|false/)
98
+ end
99
+ end
100
+
101
+ describe '#passing_score' do
102
+ it 'responds' do
103
+ @exam.should respond_to(:passing_score)
104
+ end
105
+
106
+ it 'is a String' do
107
+ @exam.passing_score.should be_a(String)
108
+ end
109
+
110
+ it 'looks like a number' do
111
+ @exam.passing_score.should match(/\d+/)
112
+ end
113
+ end
114
+
115
+ describe '#retired' do
116
+ it 'responds' do
117
+ @exam.should respond_to(:retired)
118
+ end
119
+
120
+ it 'is a Boolean' do
121
+ @exam.retired.to_s.should match(/true|false/)
122
+ end
123
+ end
124
+
125
+ describe '#source' do
126
+ it 'responds' do
127
+ @exam.should respond_to(:source)
128
+ end
129
+
130
+ it 'is a String' do
131
+ @exam.source.should be_a(String)
132
+ end
133
+ end
134
+
135
+ describe '#title' do
136
+ it 'responds' do
137
+ @exam.should respond_to(:title)
138
+ end
139
+
140
+ it 'is a String' do
141
+ @exam.title.should be_a(String)
142
+ end
143
+ end
144
+
145
+ describe '#verified_credit' do
146
+ it 'responds' do
147
+ @exam.should respond_to(:verified_credit)
148
+ end
149
+
150
+ it 'is a Boolean' do
151
+ @exam.verified_credit.to_s.should match(/true|false/)
152
+ end
153
+ end
28
154
  end
29
155
  end