stellar 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Stellar::Courses do
4
+ let(:courses) { test_client.courses }
5
+
6
+ describe '#mine' do
7
+ let(:mine) { courses.mine }
8
+
9
+ it 'should have at least one course' do
10
+ mine.should have_at_least(1).course
11
+ end
12
+
13
+ it 'should have a dot in each course number' do
14
+ mine.each do |c|
15
+ c.number.should match('.')
16
+ end
17
+ end
18
+
19
+ it 'should have the course number in each URL' do
20
+ mine.each do |c|
21
+ c.url.should match(c.number)
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ describe Stellar::Course do
28
+ let(:six) { test_client.course("6.006", 2011, :fall) }
29
+
30
+ describe '#navigation' do
31
+ let(:nav) { six.navigation }
32
+
33
+ it 'should have a Gradebook link' do
34
+ nav['Gradebook'].should be_kind_of(URI)
35
+ end
36
+
37
+ it 'should have a Homework link' do
38
+ nav['Homework'].should be_kind_of(URI)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Stellar::HomeworkList do
4
+ let(:six) { test_client.course("6.006", 2011, :fall) }
5
+ let(:homework) { six.homework }
6
+
7
+ describe 'all' do
8
+ let(:all) { homework.all }
9
+
10
+ it 'should have at least one assignment' do
11
+ all.should have_at_least(1).assignment
12
+ end
13
+
14
+ it 'should have a Stellar::Homework in each assignment' do
15
+ all.each do |c|
16
+ c.should be_kind_of(Stellar::Homework)
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ describe Stellar::Homework do
23
+ let(:six) { test_client.course("6.006", 2011, :fall) }
24
+ let(:ps1) { six.homework.named('Problem Set 1') }
25
+
26
+ it 'should have a name' do
27
+ ps1.name.should == 'Problem Set 1'
28
+ end
29
+ it 'should have a course' do
30
+ ps1.course.should == six
31
+ end
32
+ end
@@ -0,0 +1,124 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Stellar::Homework::Submission do
4
+ before(:all) do
5
+ @submissions = test_client.course('6.006', 2011, :fall).homework.
6
+ named('Problem Set 1').submissions
7
+ end
8
+
9
+ let(:one) { @submissions.find { |s| s.name == 'Christianne B. Swartz' } }
10
+
11
+ it "should have the author's name" do
12
+ one.name.should == 'Christianne B. Swartz'
13
+ end
14
+ it "should have the author's email" do
15
+ one.email.reverse.should == 'ude.tim@ytsirhc'
16
+ end
17
+ it 'should have a submission URL' do
18
+ one.file_url.should be_kind_of(URI)
19
+ end
20
+ it 'should have the right bits in the submission' do
21
+ one.file_data.should match(/\% 6\.006/)
22
+ end
23
+
24
+ it 'should have at least one feedback comment' do
25
+ one.comments.should have_at_least(1).comment
26
+ end
27
+
28
+ describe Stellar::Homework::Submission::Comment do
29
+ let(:comment) { one.comments.first }
30
+
31
+ it 'should have an author' do
32
+ comment.author.should == 'Sarah Charmian Eisenstat'
33
+ end
34
+ it 'should have some text' do
35
+ comment.text.should match(/see attached/i)
36
+ end
37
+ it 'should have an attachment' do
38
+ comment.attachment_url.should be_kind_of(URI)
39
+ end
40
+
41
+ it 'should have the right bits in the attachment' do
42
+ comment.attachment_data.should match(/^\%PDF\-.*\%\%EOF/m)
43
+ end
44
+ end
45
+
46
+ describe '#add_comment with no file' do
47
+ before :all do
48
+ @text = 'Testing... please ignore this.'
49
+ @old_comments = one.comments
50
+ @result = one.add_comment @text
51
+ one.reload_comments!
52
+ end
53
+ after :all do
54
+ one.comments.last.delete!
55
+ end
56
+
57
+ it 'should create a new comment' do
58
+ one.comments.length.should == @old_comments.length + 1
59
+ end
60
+
61
+ it 'should have the right text in the new comment' do
62
+ one.comments.last.text.should == @text
63
+ end
64
+
65
+ it 'should not have an attachment in the new comment' do
66
+ one.comments.last.attachment_url.should be_nil
67
+ end
68
+ end
69
+
70
+ describe '#add_comment with file' do
71
+ before :all do
72
+ @text = 'Testing... please ignore the attachment.'
73
+ @file_data = 'Please ignore this testing file.'
74
+
75
+ @old_comments = one.comments
76
+ @result = one.add_comment @text, @file_data
77
+ one.reload_comments!
78
+ end
79
+ after :all do
80
+ one.comments.last.delete!
81
+ end
82
+
83
+ it 'should create a new comment' do
84
+ one.comments.length.should == @old_comments.length + 1
85
+ end
86
+
87
+ it 'should have the right text in the new comment' do
88
+ one.comments.last.text.should == @text
89
+ end
90
+
91
+ it 'should have an attachment in the new comment' do
92
+ one.comments.last.attachment_url.should_not be_nil
93
+ end
94
+
95
+ it 'should have the right attachment bits' do
96
+ one.comments.last.attachment_data.should == @file_data
97
+ end
98
+ end
99
+
100
+ describe '#delete_comment' do
101
+ before :all do
102
+ @old_comments = one.comments
103
+ @result = one.add_comment @text
104
+ one.reload_comments!
105
+ @comment = one.comments.last
106
+ @comment.delete!
107
+ one.reload_comments!
108
+ end
109
+
110
+ it 'should remove that last comment' do
111
+ one.comments.reject(&:deleted?).length.should ==
112
+ @old_comments.reject(&:deleted?).length
113
+ end
114
+
115
+ it 'should keep the right comments' do
116
+ one.comments.reject(&:deleted?).map(&:text).should ==
117
+ @old_comments.reject(&:deleted?).map(&:text)
118
+ end
119
+
120
+ it 'should mark the comment as deleted' do
121
+ @comment.should be_deleted
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,24 @@
1
+ require 'yaml'
2
+
3
+ # The MIT kerberos used to run tests.
4
+ def test_mit_kerberos
5
+ path = File.expand_path '../fixtures/kerberos.b64', File.dirname(__FILE__)
6
+ YAML.load File.read(path).unpack('m').first
7
+ end
8
+
9
+ # The MIT certificate used to run tests.
10
+ def test_mit_cert
11
+ path = File.expand_path '../fixtures/mit_cert.yml', File.dirname(__FILE__)
12
+ YAML.load File.read(path)
13
+ end
14
+
15
+ # Cached client authenticated through some means.
16
+ def test_client
17
+ TestCredentialsCache.test_client
18
+ end
19
+
20
+ class TestCredentialsCache
21
+ def self.test_client
22
+ @__test_client ||= Stellar::Client.new.auth :kerberos => test_mit_kerberos
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,205 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stellar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Victor Costan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mechanize
16
+ requirement: &26061560 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *26061560
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ requirement: &26060720 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.5.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *26060720
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &26060120 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 3.9.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *26060120
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &26059400 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.6.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *26059400
58
+ - !ruby/object:Gem::Dependency
59
+ name: yard
60
+ requirement: &26058440 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 0.7.2
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *26058440
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard-rspec
71
+ requirement: &26054100 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0.1'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *26054100
80
+ - !ruby/object:Gem::Dependency
81
+ name: bundler
82
+ requirement: &26053420 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 1.0.21
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *26053420
91
+ - !ruby/object:Gem::Dependency
92
+ name: jeweler
93
+ requirement: &26052760 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 1.6.4
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *26052760
102
+ - !ruby/object:Gem::Dependency
103
+ name: rcov
104
+ requirement: &26051820 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *26051820
113
+ - !ruby/object:Gem::Dependency
114
+ name: ruby-debug
115
+ requirement: &26050900 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *26050900
124
+ - !ruby/object:Gem::Dependency
125
+ name: ruby-debug19
126
+ requirement: &26050140 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *26050140
135
+ - !ruby/object:Gem::Dependency
136
+ name: highline
137
+ requirement: &26049520 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: 1.6.2
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *26049520
146
+ description: So we don't have to put up with Stellar's craptastic ui
147
+ email: victor@costan.us
148
+ executables: []
149
+ extensions: []
150
+ extra_rdoc_files:
151
+ - LICENSE.txt
152
+ - README.rdoc
153
+ files:
154
+ - .document
155
+ - .project
156
+ - .rspec
157
+ - Gemfile
158
+ - Gemfile.lock
159
+ - LICENSE.txt
160
+ - README.rdoc
161
+ - Rakefile
162
+ - VERSION
163
+ - lib/stellar.rb
164
+ - lib/stellar/auth.rb
165
+ - lib/stellar/client.rb
166
+ - lib/stellar/courses.rb
167
+ - lib/stellar/homework.rb
168
+ - lib/stellar/mitca.crt
169
+ - spec/fixtures/.gitkeep
170
+ - spec/spec_helper.rb
171
+ - spec/stellar/auth_spec.rb
172
+ - spec/stellar/client_spec.rb
173
+ - spec/stellar/courses_spec.rb
174
+ - spec/stellar/homework_spec.rb
175
+ - spec/stellar/homework_submissions_spec.rb
176
+ - spec/support/test-credentials.rb
177
+ homepage: http://github.com/pwnall/stellar
178
+ licenses:
179
+ - MIT
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ segments:
191
+ - 0
192
+ hash: -1218153484388710196
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ none: false
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ requirements: []
200
+ rubyforge_project:
201
+ rubygems_version: 1.8.11
202
+ signing_key:
203
+ specification_version: 3
204
+ summary: Automated access to MIT's Stellar data
205
+ test_files: []