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,36 +1,75 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::Extra do
4
- before do
5
- Net::HTTP.stub(:get).
6
- with('api.cteresource.org',
7
- "/courses/6320,2011/extras/untitled~6320",
8
- 80).
9
- and_return(JSON.pretty_generate(
10
- :extra => { :title => "Instructional Scenario",
11
- :description => "extra description" }
12
- ))
13
- @extra = Verso::Extra.new("code" => "6320", "edition" => "2011",
14
- "name" => "untitled~6320",
15
- "title" => "Instructional Scenarios")
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ before(:each) do
7
+ @extra = Verso::CourseList.new(:code => "6320").last.extras.first
16
8
  end
17
9
 
18
- it "responds to #title" do
19
- @extra.title.should eq("Instructional Scenarios")
10
+ describe '#code' do
11
+ it 'responds' do
12
+ @extra.should respond_to(:code)
13
+ end
14
+
15
+ it 'is a String' do
16
+ @extra.code.should be_a(String)
17
+ end
18
+
19
+ it 'looks like a code' do
20
+ @extra.code.should match(/\d{4}/)
21
+ end
20
22
  end
21
23
 
22
- it "responds to #description" do
23
- @extra.description.should eq("extra description")
24
+ describe '#description' do
25
+ it 'responds' do
26
+ @extra.should respond_to(:description)
27
+ end
28
+
29
+ it 'is a String' do
30
+ @extra.description.should be_a(String)
31
+ end
32
+
33
+ it 'looks like HTML' do
34
+ @extra.description.should match(/<\/.+>/)
35
+ end
24
36
  end
25
- it "responds to #code" do
26
- @extra.code.should eq("6320")
37
+
38
+ describe '#edition' do
39
+ it 'responds' do
40
+ @extra.should respond_to(:edition)
41
+ end
42
+
43
+ it 'is a String' do
44
+ @extra.edition.should be_a(String)
45
+ end
46
+
47
+ it 'looks like a year' do
48
+ @extra.edition.should match(/2\d{3}/)
49
+ end
27
50
  end
28
51
 
29
- it "resonds to #name" do
30
- @extra.name.should eq("untitled~6320")
52
+ describe '#name' do
53
+ it 'responds' do
54
+ @extra.should respond_to(:name)
55
+ end
56
+
57
+ it 'is a String' do
58
+ @extra.name.should be_a(String)
59
+ end
60
+
61
+ it 'looks like a name (i.e., untitled~6320)' do
62
+ @extra.name.should match(/^[a-z_~\d]+$/)
63
+ end
31
64
  end
32
65
 
33
- it "responds to #edition" do
34
- @extra.edition.should eq("2011")
66
+ describe '#title' do
67
+ it 'responds' do
68
+ @extra.should respond_to(:title)
69
+ end
70
+
71
+ it 'is a String' do
72
+ @extra.title.should be_a(String)
73
+ end
35
74
  end
36
75
  end
@@ -1,25 +1,88 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::ExtrasList do
4
- before do
5
- @extra = double("Verso::Extra", :code => "6320", :edition => "2011",
6
- :name => "untitled~6320",
7
- :title => "Instructional Scenarios")
8
- @extras_list = Verso::ExtrasList.new(:code => "6320", :edition => "2011")
9
- Net::HTTP.stub(:get).and_return(
10
- JSON.pretty_generate(
11
- :extras => [
12
- { :title => "Instructional Scenarios", :name => "untitled~6320" }
13
- ]
14
- )
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ before(:each) do
7
+ @extras = Verso::ExtrasList.new(
8
+ :code => "6320",
9
+ :edition => Verso::EditionList.new.last.year
15
10
  )
16
11
  end
17
12
 
18
- it "responds as Enumerable" do
19
- Verso::Extra.should_receive(:new).
20
- with("code" => "6320", "edition" => "2011", "name" => "untitled~6320",
21
- "title" => "Instructional Scenarios").
22
- and_return(@extra)
23
- @extras_list.first.title.should eq("Instructional Scenarios")
13
+ describe 'array-like behavior' do
14
+ describe '#[]' do
15
+ it 'responds' do
16
+ @extras.should respond_to(:[])
17
+ end
18
+
19
+ it 'gets a Verso::Extra object' do
20
+ @extras[1].should be_a(Verso::Extra)
21
+ end
22
+ end
23
+
24
+ describe '#each' do
25
+ it 'responds' do
26
+ @extras.should respond_to(:each)
27
+ end
28
+
29
+ it 'yields' do
30
+ expect { |b| @extras.each("foo", &b).to yield_control }
31
+ end
32
+
33
+ it 'yields Verso::Extra objects' do
34
+ @extras.each { |c| c.should be_a(Verso::Extra) }
35
+ end
36
+ end
37
+
38
+ describe '#empty?' do
39
+ it 'responds' do
40
+ @extras.should respond_to(:empty?)
41
+ end
42
+
43
+ it 'is not empty' do
44
+ @extras.should_not be_empty
45
+ end
46
+ end
47
+
48
+ describe '#last' do
49
+ it 'responds' do
50
+ @extras.should respond_to(:last)
51
+ end
52
+
53
+ it 'is a Verso::Extra object' do
54
+ @extras.last.should be_a(Verso::Extra)
55
+ end
56
+ end
57
+
58
+ describe '#length' do
59
+ it 'responds' do
60
+ @extras.should respond_to(:length)
61
+ end
62
+
63
+ it 'is a Fixnum' do
64
+ @extras.length.should be_a(Fixnum)
65
+ end
66
+ end
67
+
68
+ describe '#first' do
69
+ it 'responds' do
70
+ @extras.should respond_to(:first)
71
+ end
72
+
73
+ it 'is a Verso::Extra object' do
74
+ @extras.first.should be_a(Verso::Extra)
75
+ end
76
+ end
77
+
78
+ describe '#count' do
79
+ it 'responds' do
80
+ @extras.should respond_to(:count)
81
+ end
82
+
83
+ it 'is a Fixnum' do
84
+ @extras.count.should be_a(Fixnum)
85
+ end
86
+ end
24
87
  end
25
88
  end
@@ -1,11 +1,146 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::Frontmatter do
4
- it 'fetches the remote resource' do
5
- @frontmatter = Verso::Frontmatter.new("code" => "6320", "edition" => "2011")
6
- @frontmatter.should_receive(:http_get).and_return(
7
- JSON.pretty_generate(:frontmatter => { :notice_block => "foobar" })
8
- )
9
- @frontmatter.notice_block
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ before(:each) do
7
+ @fm = Verso::Frontmatter.new(:code => "6321",
8
+ :edition => Verso::EditionList.new.last.year)
9
+ end
10
+
11
+ describe '#acknowledgments_text' do
12
+ it 'responds' do
13
+ @fm.should respond_to(:acknowledgments_text)
14
+ end
15
+
16
+ it 'is a String' do
17
+ @fm.acknowledgments_text.should be_a(String)
18
+ end
19
+
20
+ it 'is HTML' do
21
+ @fm.acknowledgments_text.should match(/<\/.+>/)
22
+ end
23
+ end
24
+
25
+ describe '#attribution_block' do
26
+ it 'responds' do
27
+ @fm.should respond_to(:attribution_block)
28
+ end
29
+
30
+ it 'is a String' do
31
+ @fm.attribution_block.should be_a(String)
32
+ end
33
+
34
+ it 'is HTML' do
35
+ @fm.attribution_block.should match(/<\/.+>/)
36
+ end
37
+ end
38
+
39
+ describe '#code' do
40
+ it 'responds' do
41
+ @fm.should respond_to(:code)
42
+ end
43
+
44
+ it 'is a String' do
45
+ @fm.code.should be_a(String)
46
+ end
47
+
48
+ it 'looks like a code' do
49
+ @fm.code.should match(/\d{4}/)
50
+ end
51
+ end
52
+
53
+ describe '#copyright_year' do
54
+ it 'responds' do
55
+ @fm.should respond_to(:copyright_year)
56
+ end
57
+
58
+ it 'is a String' do
59
+ @fm.copyright_year.should be_a(String)
60
+ end
61
+
62
+ it 'looks like a year' do
63
+ @fm.copyright_year.should match(/^2\d{3}$/)
64
+ end
65
+ end
66
+
67
+ describe 'developed_by' do
68
+ it 'responds' do
69
+ @fm.should respond_to(:developed_by)
70
+ end
71
+
72
+ it 'is a String' do
73
+ @fm.developed_by.should be_a(String)
74
+ end
75
+
76
+ it 'is HTML' do
77
+ @fm.developed_by.should match(/<\/.+>/)
78
+ end
79
+ end
80
+
81
+ describe '#developed_for' do
82
+ it 'responds' do
83
+ @fm.should respond_to(:developed_for)
84
+ end
85
+
86
+ it 'is a String' do
87
+ @fm.developed_for.should be_a(String)
88
+ end
89
+
90
+ it 'is HTML' do
91
+ @fm.developed_for.should match(/<\/.+>/)
92
+ end
93
+ end
94
+
95
+ describe '#edition' do
96
+ it 'responds' do
97
+ @fm.should respond_to(:edition)
98
+ end
99
+
100
+ it 'is a String' do
101
+ @fm.edition.should be_a(String)
102
+ end
103
+
104
+ it 'looks like a year' do
105
+ @fm.edition.should match(/^2\d{3}$/)
106
+ end
107
+ end
108
+
109
+ describe '#foreword_text' do
110
+ it 'responds' do
111
+ @fm.should respond_to(:foreword_text)
112
+ end
113
+
114
+ it 'is a String' do
115
+ @fm.foreword_text.should be_a(String)
116
+ end
117
+
118
+ it 'is HTML' do
119
+ @fm.foreword_text.should match(/<\/.+>/)
120
+ end
121
+ end
122
+
123
+ describe '#introduction_text' do
124
+ it 'responds' do
125
+ @fm.should respond_to(:introduction_text)
126
+ end
127
+
128
+ it 'is a String' do
129
+ @fm.introduction_text.should be_a(String)
130
+ end
131
+ end
132
+
133
+ describe '#notice_block' do
134
+ it 'responds' do
135
+ @fm.should respond_to(:notice_block)
136
+ end
137
+
138
+ it 'is a String' do
139
+ @fm.notice_block.should be_a(String)
140
+ end
141
+
142
+ it 'is HTML' do
143
+ @fm.notice_block.should match(/<\/.+>/)
144
+ end
10
145
  end
11
146
  end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hash do
4
+ context '#symbolize_nested_keys!' do
5
+ context 'for hashes with string keys' do
6
+ before do
7
+ @h = { "foo" => "bar", "baz" => 1 }
8
+ @h.symbolize_nested_keys!
9
+ end
10
+ it 'symbolizes keys' do
11
+ @h[:foo].should eq("bar")
12
+ end
13
+ it 'deletes keys' do
14
+ @h["foo"].should be_nil
15
+ end
16
+ end
17
+
18
+ context "for hashes with keys which are symbols" do
19
+ it 'leaves well enough alone' do
20
+ h = { :rosebud => "sled" }
21
+ h.symbolize_nested_keys!
22
+ h[:rosebud].should eq("sled")
23
+ end
24
+ end
25
+
26
+ context 'for nested hashes with string keys' do
27
+ before do
28
+ @h = { "movie" => { "title" => "Citizen Kane", "sled" => "rosebud" } }
29
+ @h.symbolize_nested_keys!
30
+ end
31
+
32
+ it 'symbolizes keys' do
33
+ @h[:movie][:title].should eq("Citizen Kane")
34
+ end
35
+ end
36
+
37
+ context 'for string keys of hashes nested within arrays' do
38
+ it 'symbolizes keys' do
39
+ h = { "list" => "Movie list",
40
+ "movies" => [
41
+ { "title" => "Citizen Kane" },
42
+ { "title" => "Badlands" }
43
+ ] }
44
+ h.symbolize_nested_keys!
45
+ h[:movies].last[:title].should eq("Badlands")
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,24 +1,42 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Verso::OccupationData do
4
- before do
5
- @occupation_data = [{
6
- "cluster" => { "title" => "Information Technology" },
7
- "pathway" => { "title" => "Information and Support Services" },
8
- "occupations" => [{ "title" => "Database Analyst" }]
9
- }]
10
- @occdata = Verso::OccupationData.new(@occupation_data.first)
4
+ use_vcr_cassette :record => :new_episodes
5
+
6
+ before(:each) do
7
+ @od = Verso::OccupationList.new(:text => "golf").first
11
8
  end
9
+ describe '#cluster' do
10
+ it 'responds' do
11
+ @od.should respond_to(:cluster)
12
+ end
12
13
 
13
- it 'should respond to title' do
14
- @occdata.cluster.title.should eq("Information Technology")
14
+ it 'is a Verso::Cluster' do
15
+ @od.cluster.should be_a(Verso::Cluster)
16
+ end
15
17
  end
16
18
 
17
- it 'should respond to pathway' do
18
- @occdata.pathway.title.should eq("Information and Support Services")
19
+ describe '#pathway' do
20
+ it 'responds' do
21
+ @od.should respond_to(:pathway)
22
+ end
23
+
24
+ it 'is a Verso::Pathway' do
25
+ @od.pathway.should be_a(Verso::Pathway)
26
+ end
19
27
  end
20
28
 
21
- it 'should respond to occupations' do
22
- @occdata.occupations.first.title.should eq("Database Analyst")
29
+ describe '#occupations' do
30
+ it 'responds' do
31
+ @od.should respond_to(:occupations)
32
+ end
33
+
34
+ it 'is an Array' do
35
+ @od.occupations.should be_a(Array)
36
+ end
37
+
38
+ it 'is an Array of Verso::Occupation objects' do
39
+ @od.occupations.first.should be_a(Verso::Occupation)
40
+ end
23
41
  end
24
42
  end