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,53 +1,111 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::Standard do
4
+ use_vcr_cassette :record => :new_episodes
5
+
4
6
  before do
5
- @goal = { "title" => "goal title",
6
- "description" => "goal description" }
7
- @nested_goal = { "title" => "nested goal title",
8
- "description" => "nested goal description" }
9
- @section = { "title" => "section title",
10
- "description" => "section description",
11
- "goals" => [@nested_goal], "sections" => [] }
12
- @raw_standard = { :aname => { "title" => "standard title",
13
- "description" => "standard description",
14
- "goals" => [@goal],
15
- "sections" => [@section] } }
16
- @standard = Verso::Standard.new(@raw_standard.values.first)
7
+ @standard = Verso::Standard.new(
8
+ :code => "6135",
9
+ :edition => Verso::EditionList.new.last.year,
10
+ :name => "english"
11
+ )
17
12
  end
18
13
 
19
- it "should respond to title" do
20
- @standard.title.should eq("standard title")
21
- end
14
+ describe '#description' do
15
+ it 'responds' do
16
+ @standard.should respond_to(:description)
17
+ end
22
18
 
23
- it "should respond to description" do
24
- @standard.description.should eq("standard description")
19
+ it 'is a string' do
20
+ @standard.description.should be_a(String)
21
+ end
25
22
  end
26
23
 
27
- it "should respond to sections" do
28
- @standard.sections.first.title.should eq(@section["title"])
24
+ describe '#goals' do
25
+ it 'responds' do
26
+ @standard.should respond_to(:goals)
27
+ end
28
+
29
+ it 'is an Array' do
30
+ @standard.goals.should be_a(Array)
31
+ end
32
+
33
+ it 'is an Array of OpenStruct objects' do
34
+ @standard.goals.first.should be_a(OpenStruct)
35
+ end
36
+
37
+ describe 'OpenStruct goal objects' do
38
+ before do
39
+ @goal = @standard.goals.first
40
+ end
41
+
42
+ describe '#title' do
43
+ it 'responds' do
44
+ @goal.should respond_to(:title)
45
+ end
46
+
47
+ it 'is a string' do
48
+ @goal.title.should be_a(String)
49
+ end
50
+ end
51
+
52
+ describe '#description' do
53
+ it 'responds' do
54
+ @goal.should respond_to(:description)
55
+ end
56
+
57
+ it 'is a String' do
58
+ @goal.description.should be_a(String)
59
+ end
60
+
61
+ it 'looks like HTML' do
62
+ @goal.description.should match(/<\/.+>/)
63
+ end
64
+ end
65
+ end
29
66
  end
30
67
 
31
- it "should respond to goals" do
32
- @standard.goals.first.title.should eq("goal title")
68
+ describe '#name' do
69
+ it 'responds' do
70
+ @standard.should respond_to(:name)
71
+ end
72
+
73
+ it 'is a String' do
74
+ @standard.name.should be_a(String)
75
+ end
76
+
77
+ it 'looks like the title' do
78
+ @standard.name.should == 'english'
79
+ end
33
80
  end
34
81
 
35
- it "should respond to nested goals" do
36
- @standard.sections.first.goals.first.title.should eq("nested goal title")
82
+ describe '#sections' do
83
+ it 'responds' do
84
+ @standard.should respond_to(:sections)
85
+ end
86
+
87
+ it 'is an Array' do
88
+ @standard.sections.should be_a(Array)
89
+ end
90
+
91
+ it 'is an Array of Verso::Standard objects' do
92
+ # english doesn't have subsections, so . . .
93
+ std = Verso::Standard.new(
94
+ :code => "8276",
95
+ :edition => Verso::EditionList.new.last.year,
96
+ :name => 'fccla_activities--competitive_events'
97
+ )
98
+ std.sections.first.should be_a(Verso::Standard)
99
+ end
37
100
  end
38
101
 
39
- it "should fetch standard as necessary" do
40
- course = OpenStruct.new(:code => "6320", :edition => "2011")
41
- std = { "name" => "science" }
42
- std = Verso::Standard.new(std, course)
43
- std.name.should eq("science")
44
- std.code.should eq("6320")
45
-
46
- raw_std = { "standard" => { "title" => "Science", "sections" => [],
47
- "goals" => [] } }
48
- Net::HTTP.stub(:get).and_return(nil)
49
- JSON.stub(:parse).and_return(raw_std)
50
- std.title.should eq("Science")
51
- std.name.should eq("science")
102
+ describe '#title' do
103
+ it 'responds' do
104
+ @standard.should respond_to(:title)
105
+ end
106
+
107
+ it 'is a String' do
108
+ @standard.title.should be_a(String)
109
+ end
52
110
  end
53
111
  end
@@ -1,51 +1,145 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::StandardsList do
4
+ use_vcr_cassette :record => :new_episodes
5
+
4
6
  before do
5
- @goal = OpenStruct.new({ "title" => "goal title",
6
- "description" => "goal description" })
7
- @nested_goal = OpenStruct.new(
8
- { "title" => "nested goal title",
9
- "description" => "nested goal description" }
10
- )
11
- @section = OpenStruct.new(
12
- { "title" => "section title", "description" => "section description",
13
- "goals" => [@nested_goal], "sections" => [] }
7
+ @list = Verso::StandardsList.new(
8
+ :code => "6320",
9
+ :edition => Verso::EditionList.new.last.year
14
10
  )
15
- @raw_standard = { :aname => { "title" => "standard title",
16
- "description" => "standard description",
17
- "goals" => [@goal],
18
- "sections" => [@section] } }
19
- sol = { :science => { "title" => "Science",
20
- "description" => "standard description",
21
- "name" => "science",
22
- "goals" => [@goal],
23
- "sections" => [@section] } }
24
- @raw_standard.merge!(sol)
25
- @standards_list = Verso::StandardsList.new(@raw_standard)
26
11
  end
27
12
 
28
- it "responds as Enumerable" do
29
- @standards_list.last.title.should eq("standard title")
30
- @standards_list.first.title.should eq("Science")
13
+ describe 'array-like behavior' do
14
+ describe '#[]' do
15
+ it 'responds' do
16
+ @list.should respond_to(:[])
17
+ end
18
+
19
+ it 'gets a Verso::Standard object' do
20
+ @list[2].should be_a(Verso::Standard)
21
+ end
22
+ end
23
+
24
+ describe '#each' do
25
+ it 'responds' do
26
+ @list.should respond_to(:each)
27
+ end
28
+
29
+ it 'yields' do
30
+ expect { |b| @list.each("foo", &b).to yield_control }
31
+ end
32
+
33
+ it 'yields Verso::Standard objects' do
34
+ @list.each { |c| c.should be_a(Verso::Standard) }
35
+ end
36
+ end
37
+
38
+ describe '#empty?' do
39
+ it 'responds' do
40
+ @list.should respond_to(:empty?)
41
+ end
42
+
43
+ it 'is not empty' do
44
+ @list.should_not be_empty
45
+ end
46
+ end
47
+
48
+ describe '#last' do
49
+ it 'responds' do
50
+ @list.should respond_to(:last)
51
+ end
52
+
53
+ it 'is a Verso::Standard object' do
54
+ @list.last.should be_a(Verso::Standard)
55
+ end
56
+ end
57
+
58
+ describe '#length' do
59
+ it 'responds' do
60
+ @list.should respond_to(:length)
61
+ end
62
+
63
+ it 'is a Fixnum' do
64
+ @list.length.should be_a(Fixnum)
65
+ end
66
+ end
67
+
68
+ describe '#first' do
69
+ it 'responds' do
70
+ @list.should respond_to(:first)
71
+ end
72
+
73
+ it 'is a Verso::Standard object' do
74
+ @list.first.should be_a(Verso::Standard)
75
+ end
76
+ end
77
+
78
+ describe '#count' do
79
+ it 'responds' do
80
+ @list.should respond_to(:count)
81
+ end
82
+
83
+ it 'is a Fixnum' do
84
+ @list.count.should be_a(Fixnum)
85
+ end
86
+ end
31
87
  end
32
88
 
33
- it "should respond to sols" do
34
- @standards_list.sols.first.title.should eq('Science')
89
+ describe '#non_sols' do
90
+ it 'responds' do
91
+ @list.should respond_to(:non_sols)
92
+ end
93
+
94
+ it 'is an Array' do
95
+ @list.non_sols.should be_a(Array)
96
+ end
97
+
98
+ it 'is an Array of Verso::Standard Objects' do
99
+ @list.non_sols.first.should be_a(Verso::Standard)
100
+ end
101
+
102
+ it 'does not include SOLs like English' do
103
+ @list.non_sols.any? { |s| s.title == 'English'}.should be_false
104
+ end
35
105
  end
36
106
 
37
- it "should respond to non_sols" do
38
- @standards_list.non_sols.first.title.should eq("standard title")
107
+ describe '#sols' do
108
+ it 'responds' do
109
+ @list.should respond_to(:sols)
110
+ end
111
+
112
+ it 'is an Array' do
113
+ @list.sols.should be_a(Array)
114
+ end
115
+
116
+ it 'is an Array of Verso::Standard Objects' do
117
+ @list.sols.first.should be_a(Verso::Standard)
118
+ end
119
+
120
+ it 'includes SOLs like English' do
121
+ @list.sols.any? { |s| s.title == 'English' }.should be_true
122
+ end
39
123
  end
40
124
 
41
- it "should create a list from a course" do
42
- course = double("Course", :code => "6320", :edition => "2011")
43
- Net::HTTP.stub(:get).and_return(nil)
44
- raw = { "standards" => @raw_standard.values }
45
- JSON.stub(:parse).and_return(raw)
46
- sl = Verso::StandardsList.new(raw["standards"], course)
47
- Verso::StandardsList.should_receive(:new).with(raw["standards"], course).
48
- and_return(sl)
49
- Verso::StandardsList.from_course(course).last.title.should eq("standard title")
125
+ describe 'self.from_course' do
126
+ before do
127
+ @course = Verso::CourseList.new(:code => "6320").last
128
+ end
129
+
130
+ it 'responds' do
131
+ Verso::StandardsList.should respond_to(:from_course)
132
+ end
133
+
134
+ it 'returns a Verso::StandardsList' do
135
+ Verso::StandardsList.from_course(@course).
136
+ should be_a(Verso::StandardsList)
137
+ end
138
+
139
+ it 'has the correct code and edition' do
140
+ list = Verso::StandardsList.from_course(@course)
141
+ list.code.should == @course.code
142
+ list.edition.should == @course.edition
143
+ end
50
144
  end
51
145
  end
@@ -4,69 +4,178 @@ describe Verso::TaskList do
4
4
  use_vcr_cassette :record => :new_episodes
5
5
 
6
6
  before do
7
- @tl = Verso::TaskList.new(:code => "6320", :edition => "2011")
7
+ @tl = Verso::TaskList.new(
8
+ :code => "6320",
9
+ :edition => Verso::EditionList.new.last.year)
8
10
  end
9
11
 
10
- it "responds to #first" do
11
- @duty_area = double("Verso::DutyArea", :title => "A Verso::Duty Area")
12
- Verso::DutyArea.should_receive(:new).and_return(@duty_area)
13
- @tl.first.title.should eq("A Verso::Duty Area")
14
- end
12
+ describe '#code' do
13
+ it 'responds' do
14
+ @tl.should respond_to(:code)
15
+ end
15
16
 
16
- it "responds to #code, #edition" do
17
- @tl.code.should eq("6320")
18
- @tl.edition.should eq("2011")
17
+ it 'is a String' do
18
+ @tl.code.should be_a(String)
19
+ end
19
20
  end
20
21
 
21
- it "responds to #has_optional_task? when true" do
22
- @tl.stub(:duty_areas).and_return(
23
- [{"title" => "DA Title",
24
- "tasks" => [
25
- { "statement" => "one",
26
- "sensitive" => false,
27
- "essential" => true }
28
- ]}]
29
- )
30
- @tl.has_optional_task?.should eq(false)
22
+ describe '#edition' do
23
+ it 'responds' do
24
+ @tl.should respond_to(:edition)
25
+ end
26
+
27
+ it 'is a String' do
28
+ @tl.edition.should be_a(String)
29
+ end
31
30
  end
32
31
 
33
- it "responds to #has_optional_task? when false" do
34
- @tl.stub(:duty_areas).and_return(
35
- [{"title" => "DA Title",
36
- "tasks" => [
37
- { "statement" => "one",
38
- "sensitive" => false,
39
- "essential" => false }
40
- ]}]
41
- )
42
- @tl.has_optional_task?.should eq(true)
32
+ describe '#has_optional_task?' do
33
+ it 'responds' do
34
+ @tl.should respond_to(:has_optional_task?)
35
+ end
36
+
37
+ it 'is Boolean' do
38
+ @tl.has_optional_task?.to_s.should match(/true|false/)
39
+ end
40
+
41
+ it 'is true if a task is non-essential' do
42
+ tl = Verso::TaskList.new(
43
+ :code => "6320",
44
+ :edition => Verso::EditionList.new.last.year,
45
+ :duty_areas => [
46
+ { :title => "",
47
+ :tasks => [
48
+ { :statement => '', :id => "12",
49
+ :sensitive => false, :essential => false }
50
+ ]
51
+ }]
52
+ )
53
+ tl.has_optional_task?.should be_true
54
+ end
55
+
56
+ it 'is false if all tasks are essential' do
57
+ tl = Verso::TaskList.new(
58
+ :code => "6320",
59
+ :edition => Verso::EditionList.new.last.year,
60
+ :duty_areas => [
61
+ { :title => "",
62
+ :tasks => [
63
+ { :statement => '', :id => "12",
64
+ :sensitive => false, :essential => true }
65
+ ]
66
+ }]
67
+ )
68
+ tl.has_optional_task?.should be_false
69
+ end
43
70
  end
44
71
 
45
- it "responds to #has_sensitive_task? when true" do
46
- @tl.stub(:duty_areas).and_return(
47
- [{"title" => "DA Title",
48
- "tasks" => [
49
- { "statement" => "one",
50
- "sensitive" => true }
51
- ]}]
52
- )
53
- @tl.has_sensitive_task?.should eq(true)
72
+ describe '#has_sensitive_task?' do
73
+ it 'responds' do
74
+ @tl.should respond_to(:has_sensitive_task?)
75
+ end
76
+
77
+ it 'is Boolean' do
78
+ @tl.has_sensitive_task?.to_s.should match(/true|false/)
79
+ end
80
+
81
+ it 'is false if no task is sensitive' do
82
+ @tl.has_sensitive_task?.should be_false
83
+ end
84
+
85
+ it 'is true if a task is sensitive' do
86
+ tl = Verso::TaskList.new(
87
+ :code => "6320",
88
+ :edition => Verso::EditionList.new.last.year,
89
+ :duty_areas => [
90
+ { :title => "",
91
+ :tasks => [
92
+ { :statement => '', :id => "12",
93
+ :sensitive => true, :essential => true }
94
+ ]
95
+ }]
96
+ )
97
+ tl.has_sensitive_task?.should be_true
98
+ end
54
99
  end
55
100
 
56
- it "responds to #has_sensitive_task? when false" do
57
- @tl.stub(:duty_areas).and_return(
58
- [{"title" => "DA Title",
59
- "tasks" => [
60
- { "statement" => "one",
61
- "sensitive" => false }
62
- ]}]
63
- )
64
- @tl.has_sensitive_task?.should eq(false)
101
+ describe 'array-like behavior' do
102
+ describe '#[]' do
103
+ it 'responds' do
104
+ @tl.should respond_to(:[])
105
+ end
106
+
107
+ it 'gets a Verso::DutyArea object' do
108
+ @tl[10].should be_a(Verso::DutyArea)
109
+ end
110
+ end
111
+
112
+ describe '#each' do
113
+ it 'responds' do
114
+ @tl.should respond_to(:each)
115
+ end
116
+
117
+ it 'yields' do
118
+ expect { |b| @tl.each("foo", &b).to yield_control }
119
+ end
120
+
121
+ it 'yields Verso::DutyArea objects' do
122
+ @tl.each { |c| c.should be_a(Verso::DutyArea) }
123
+ end
124
+ end
125
+
126
+ describe '#empty?' do
127
+ it 'responds' do
128
+ @tl.should respond_to(:empty?)
129
+ end
130
+
131
+ it 'is not empty' do
132
+ @tl.should_not be_empty
133
+ end
134
+ end
135
+
136
+ describe '#last' do
137
+ it 'responds' do
138
+ @tl.should respond_to(:last)
139
+ end
140
+
141
+ it 'is a Verso::DutyArea object' do
142
+ @tl.last.should be_a(Verso::DutyArea)
143
+ end
144
+ end
145
+
146
+ describe '#length' do
147
+ it 'responds' do
148
+ @tl.should respond_to(:length)
149
+ end
150
+
151
+ it 'is a Fixnum' do
152
+ @tl.length.should be_a(Fixnum)
153
+ end
154
+ end
155
+
156
+ describe '#first' do
157
+ it 'responds' do
158
+ @tl.should respond_to(:first)
159
+ end
160
+
161
+ it 'is a Verso::DutyArea object' do
162
+ @tl.first.should be_a(Verso::DutyArea)
163
+ end
164
+ end
165
+
166
+ describe '#count' do
167
+ it 'responds' do
168
+ @tl.should respond_to(:count)
169
+ end
170
+
171
+ it 'is a Fixnum' do
172
+ @tl.count.should be_a(Fixnum)
173
+ end
174
+ end
65
175
  end
66
176
 
67
- it "should return an empty task list if none is published" do
68
- @tl = Verso::TaskList.new(:code => "1234", :edition => "1929")
69
- JSON.stub(:parse).and_return({ "errors" => "Not Found" })
70
- @tl.duty_areas.should eq([])
177
+ it "is empty if no task list is published" do
178
+ tl = Verso::TaskList.new(:code => "1234", :edition => "1929")
179
+ tl.should be_empty
71
180
  end
72
181
  end