engrade 1.0.1 → 1.1.1
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.
- data/README.md +5 -2
- data/lib/engrade.rb +30 -17
- data/lib/engrade/version.rb +1 -1
- data/spec/engrade_spec.rb +184 -234
- data/spec/integration_spec.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -21,15 +21,18 @@ Engrade.login('username', 'password')
|
|
21
21
|
# Grabbing classes
|
22
22
|
|
23
23
|
classes = Engrade.classes
|
24
|
-
classes = Engrade.classes("Sem1")
|
24
|
+
classes = Engrade.classes(:only => "Sem1")
|
25
|
+
classes = Engrade.classes(:except => "Biology")
|
25
26
|
|
26
27
|
# Getting assignments from classes
|
27
28
|
|
28
29
|
assignments = Engrade.assignments(classes)
|
30
|
+
assignments = Engrade.assignments(classes, :only => "Final")
|
31
|
+
assignments = Engrade.assignments(classes, :except => "Quiz")
|
29
32
|
|
30
33
|
# Deleting assignments
|
31
34
|
|
32
|
-
Engrade.delete(assignments)
|
35
|
+
Engrade.delete!(assignments)
|
33
36
|
|
34
37
|
# Posting directly to Engrade
|
35
38
|
# (make sure to set apikey and login first)
|
data/lib/engrade.rb
CHANGED
@@ -73,35 +73,30 @@ module Engrade
|
|
73
73
|
|
74
74
|
|
75
75
|
# .classes returns an array of Classroom objects(data structure to represent
|
76
|
-
# classes).
|
77
|
-
#
|
78
|
-
|
79
|
-
|
80
|
-
classes = teacher_classes
|
81
|
-
classes.select! { |cl| cl['name'].match regexp } if regexp
|
82
|
-
classes.map { |cl| Classroom.new(cl) }
|
76
|
+
# classes). when no argument is given, all classes are returned. the classes
|
77
|
+
# can be filtered by calling with the :only or :except option.
|
78
|
+
def self.classes(options={})
|
79
|
+
filter teacher_classes, options
|
83
80
|
end
|
84
81
|
|
85
82
|
|
86
83
|
# .assignments returns an array(of Assignment objects) of every assignment
|
87
84
|
# from the input classes. the classes parameter can be the class id, a
|
88
85
|
# Classroom object, an array of class ids, or an array of Classroom objects.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
map { |assn| assignments << Assignment.new(assn) }
|
94
|
-
end
|
95
|
-
assignments
|
86
|
+
# assignments can be filtered by calling with the additional :only or :except
|
87
|
+
# option.
|
88
|
+
def self.assignments(classes, options={})
|
89
|
+
filter all_assignments(classes), options
|
96
90
|
end
|
97
91
|
|
98
92
|
|
99
|
-
|
93
|
+
|
94
|
+
# .delete! takes in an array of Assignment object, or a single Assignment
|
100
95
|
# object and deletes those assignments from the Engrade webpage. it also
|
101
96
|
# removes the comments from those assignments before deleting, because of
|
102
97
|
# a bug in the Engrade system where comments from deleted assignments
|
103
98
|
# reappear when assignment ids are recycled.
|
104
|
-
def self.delete(assignments)
|
99
|
+
def self.delete!(assignments)
|
105
100
|
assignments = array(assignments)
|
106
101
|
assignments.each do |assn|
|
107
102
|
@browser.remove_comments assn.clid, assn.assnid
|
@@ -113,8 +108,26 @@ module Engrade
|
|
113
108
|
# HELPER METHODS #
|
114
109
|
##################
|
115
110
|
|
111
|
+
def self.filter(array=[], options={})
|
112
|
+
var = :name if array.first.instance_of? Classroom
|
113
|
+
var = :title if array.first.instance_of? Assignment
|
114
|
+
array.select! { |item| item.send(var).match options[:only]} if options[:only]
|
115
|
+
array.reject! { |item| item.send(var).match options[:except]} if options[:except]
|
116
|
+
array
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.all_assignments(classes)
|
120
|
+
assignments = []
|
121
|
+
clid_array(classes).each do |clid|
|
122
|
+
(Engrade.gradebook :clid => clid).
|
123
|
+
map { |assn| assignments << Assignment.new(assn) }
|
124
|
+
end
|
125
|
+
assignments
|
126
|
+
end
|
127
|
+
|
116
128
|
def self.teacher_classes(query={})
|
117
|
-
JSON(post :apitask => 'teacher-classes')['classes']
|
129
|
+
class_hash = JSON(post :apitask => 'teacher-classes')['classes']
|
130
|
+
class_hash.map { |cl| Classroom.new(cl) }
|
118
131
|
end
|
119
132
|
|
120
133
|
|
data/lib/engrade/version.rb
CHANGED
data/spec/engrade_spec.rb
CHANGED
@@ -10,350 +10,300 @@ describe Engrade do
|
|
10
10
|
Engrade.base_uri.should eql 'https://api.engrade.com/api/'
|
11
11
|
end
|
12
12
|
|
13
|
-
describe "public method" do
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
it "should have :api set to json" do
|
22
|
-
Engrade.default_params[:api].should eql 'json'
|
23
|
-
end
|
14
|
+
describe ".default_params" do
|
15
|
+
|
16
|
+
it "should be a Hash" do
|
17
|
+
Engrade.default_params.should be_an_instance_of Hash
|
18
|
+
end
|
24
19
|
|
20
|
+
it "should have :api set to json" do
|
21
|
+
Engrade.default_params[:api].should eql 'json'
|
25
22
|
end
|
26
23
|
|
27
|
-
|
24
|
+
end
|
28
25
|
|
29
|
-
|
30
|
-
Engrade.set_apikey 'test'
|
31
|
-
Engrade.default_params[:apikey].should eql 'test'
|
32
|
-
end
|
26
|
+
describe ".set_apikey" do
|
33
27
|
|
28
|
+
it "should set :apikey in default_params" do
|
29
|
+
Engrade.set_apikey 'test'
|
30
|
+
Engrade.default_params[:apikey].should eql 'test'
|
34
31
|
end
|
35
32
|
|
36
|
-
|
33
|
+
end
|
37
34
|
|
38
|
-
|
39
|
-
Engrade.set_ses 'test'
|
40
|
-
Engrade.default_params[:ses].should eql 'test'
|
41
|
-
end
|
35
|
+
describe ".set_ses" do
|
42
36
|
|
37
|
+
it "should set :ses in default_params" do
|
38
|
+
Engrade.set_ses 'test'
|
39
|
+
Engrade.default_params[:ses].should eql 'test'
|
43
40
|
end
|
44
41
|
|
45
|
-
|
42
|
+
end
|
46
43
|
|
47
|
-
|
48
|
-
orig = Engrade.default_params.dup
|
49
|
-
Engrade.set_apikey "12345"
|
50
|
-
Engrade.reset!
|
51
|
-
Engrade.default_params.should eql orig
|
52
|
-
end
|
44
|
+
describe ".reset!" do
|
53
45
|
|
46
|
+
it "should reset default_params to original value" do
|
47
|
+
orig = Engrade.default_params.dup
|
48
|
+
Engrade.set_apikey "12345"
|
49
|
+
Engrade.reset!
|
50
|
+
Engrade.default_params.should eql orig
|
54
51
|
end
|
55
52
|
|
56
|
-
|
53
|
+
end
|
57
54
|
|
58
|
-
|
59
|
-
Engrade.set_apikey ENV['ENG_API']
|
60
|
-
end
|
55
|
+
describe ".post" do
|
61
56
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
and_return response[:body]
|
66
|
-
Engrade.post response[:query]
|
67
|
-
end
|
57
|
+
before :each do
|
58
|
+
Engrade.set_apikey ENV['ENG_API']
|
59
|
+
end
|
68
60
|
|
69
|
-
|
61
|
+
it "should call RestClient.post with query and default_params" do
|
62
|
+
response = build :login
|
63
|
+
RestClient.should_receive(:post).with(Engrade.base_uri, response[:payload]).
|
64
|
+
and_return response[:body]
|
65
|
+
Engrade.post response[:query]
|
66
|
+
end
|
70
67
|
|
71
|
-
|
72
|
-
response = build :login
|
73
|
-
RestClient.stub(:post).and_return response[:body]
|
74
|
-
Engrade.post(response[:query]).should eql response[:body]
|
75
|
-
end
|
68
|
+
context "with valid call" do
|
76
69
|
|
70
|
+
it "should return the result of RestClient.post" do
|
71
|
+
response = build :login
|
72
|
+
RestClient.stub(:post).and_return response[:body]
|
73
|
+
Engrade.post(response[:query]).should eql response[:body]
|
77
74
|
end
|
78
75
|
|
79
|
-
|
76
|
+
end
|
80
77
|
|
81
|
-
|
82
|
-
RestClient.stub(:post).and_return build(:bad_ses)[:body]
|
83
|
-
expect { Engrade.post :apitask => 'teacher-classes' }.
|
84
|
-
to raise_error Engrade::InvalidSession
|
85
|
-
end
|
78
|
+
context "when not logged in" do
|
86
79
|
|
80
|
+
it "should raise an InvalidSession error" do
|
81
|
+
RestClient.stub(:post).and_return build(:bad_ses)[:body]
|
82
|
+
expect { Engrade.post :apitask => 'teacher-classes' }.
|
83
|
+
to raise_error Engrade::InvalidSession
|
87
84
|
end
|
88
85
|
|
89
|
-
|
86
|
+
end
|
90
87
|
|
91
|
-
|
92
|
-
Engrade.set_apikey 'badapi'
|
93
|
-
RestClient.stub(:post).and_return build(:bad_api)[:body]
|
94
|
-
expect { Engrade.post }.to raise_error Engrade::InvalidKey
|
95
|
-
end
|
88
|
+
context "with bad apikey" do
|
96
89
|
|
90
|
+
it "should raise an InvalidKey error" do
|
91
|
+
Engrade.set_apikey 'badapi'
|
92
|
+
RestClient.stub(:post).and_return build(:bad_api)[:body]
|
93
|
+
expect { Engrade.post }.to raise_error Engrade::InvalidKey
|
97
94
|
end
|
98
95
|
|
99
|
-
|
100
|
-
|
101
|
-
it "should raise a MissingTask error" do
|
102
|
-
RestClient.stub(:post).and_return build(:no_task)[:body]
|
103
|
-
expect { Engrade.post }.to raise_error Engrade::MissingTask
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
96
|
+
end
|
107
97
|
|
108
|
-
|
98
|
+
context "with no apitask specified" do
|
109
99
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
to raise_error Engrade::InvalidTask
|
114
|
-
end
|
115
|
-
|
100
|
+
it "should raise a MissingTask error" do
|
101
|
+
RestClient.stub(:post).and_return build(:no_task)[:body]
|
102
|
+
expect { Engrade.post }.to raise_error Engrade::MissingTask
|
116
103
|
end
|
117
104
|
|
118
105
|
end
|
119
106
|
|
120
|
-
|
107
|
+
context "with invalid apitask specified" do
|
121
108
|
|
122
|
-
|
123
|
-
|
109
|
+
it "should raise an InvalidTask error" do
|
110
|
+
RestClient.stub(:post).and_return build(:bad_task)[:body]
|
111
|
+
expect { Engrade.post :apitask => 'badtask' }.
|
112
|
+
to raise_error Engrade::InvalidTask
|
124
113
|
end
|
114
|
+
|
115
|
+
end
|
125
116
|
|
126
|
-
|
127
|
-
response = build :login
|
128
|
-
Engrade.should_receive(:post).with(response[:query]).
|
129
|
-
and_return response[:body]
|
130
|
-
Engrade.login ENV['ENG_USER'], ENV['ENG_PASS']
|
131
|
-
end
|
117
|
+
end
|
132
118
|
|
133
|
-
|
119
|
+
describe ".login" do
|
134
120
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
121
|
+
before :each do
|
122
|
+
Engrade.browser.stub :login
|
123
|
+
end
|
139
124
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
125
|
+
it "should call .post with query Hash" do
|
126
|
+
response = build :login
|
127
|
+
Engrade.should_receive(:post).with(response[:query]).
|
128
|
+
and_return response[:body]
|
129
|
+
Engrade.login ENV['ENG_USER'], ENV['ENG_PASS']
|
130
|
+
end
|
144
131
|
|
145
|
-
|
146
|
-
ses = Engrade.login ENV['ENG_USER'], ENV['ENG_PASS']
|
147
|
-
Engrade.default_params[:ses].should eql ses
|
148
|
-
end
|
132
|
+
context "with valid credentials" do
|
149
133
|
|
134
|
+
before :each do
|
135
|
+
@response = build(:login)
|
136
|
+
Engrade.stub(:post).and_return @response[:body]
|
150
137
|
end
|
151
138
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
Engrade.stub(:post).and_return build(:login_baduser)[:body]
|
156
|
-
expect { Engrade.login 'baduser', 'anypass' }.to raise_error Engrade::InvalidLogin
|
157
|
-
end
|
158
|
-
|
139
|
+
it "should return the session id" do
|
140
|
+
Engrade.login(ENV['ENG_USER'], ENV['ENG_PASS']).
|
141
|
+
should eql @response[:json]['values']['ses']
|
159
142
|
end
|
160
143
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
Engrade.stub(:post).and_return build(:login_badpass)[:body]
|
165
|
-
expect { Engrade.login ENV['ENG_USER'], 'badpass' }.to raise_error Engrade::InvalidLogin
|
166
|
-
end
|
167
|
-
|
144
|
+
it "should set :ses in the default params" do
|
145
|
+
ses = Engrade.login ENV['ENG_USER'], ENV['ENG_PASS']
|
146
|
+
Engrade.default_params[:ses].should eql ses
|
168
147
|
end
|
169
148
|
|
170
149
|
end
|
171
150
|
|
172
|
-
|
151
|
+
context "with invalid username" do
|
173
152
|
|
174
|
-
|
175
|
-
|
176
|
-
Engrade.
|
153
|
+
it "should raise InvalidLogin error" do
|
154
|
+
Engrade.stub(:post).and_return build(:login_baduser)[:body]
|
155
|
+
expect { Engrade.login 'baduser', 'anypass' }.to raise_error Engrade::InvalidLogin
|
177
156
|
end
|
178
157
|
|
158
|
+
end
|
179
159
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
Engrade.
|
160
|
+
context "with invalid password" do
|
161
|
+
|
162
|
+
it "should raise InvalidLogin error" do
|
163
|
+
Engrade.stub(:post).and_return build(:login_badpass)[:body]
|
164
|
+
expect { Engrade.login ENV['ENG_USER'], 'badpass' }.to raise_error Engrade::InvalidLogin
|
184
165
|
end
|
185
166
|
|
167
|
+
end
|
186
168
|
|
187
|
-
|
188
|
-
|
189
|
-
it "should be an Array" do
|
190
|
-
Engrade.classes.should be_an_instance_of Array
|
191
|
-
end
|
192
|
-
|
193
|
-
it "should contain Classroom objects" do
|
194
|
-
Engrade.classes.first.should be_an_instance_of Engrade::Classroom
|
195
|
-
end
|
196
|
-
|
197
|
-
it "should be filtered when given a string argument" do
|
198
|
-
Engrade.classes.size.should be > Engrade.classes("Sem1").size
|
199
|
-
end
|
200
|
-
|
201
|
-
it "should contain classes that match the string argument" do
|
202
|
-
Engrade.classes("Sem1").first.name.should match "Sem1"
|
203
|
-
end
|
169
|
+
end
|
204
170
|
|
205
|
-
|
171
|
+
describe ".classes" do
|
206
172
|
|
173
|
+
before :each do
|
174
|
+
Engrade.stub(:post).and_return build(:teacher_classes)[:body]
|
207
175
|
end
|
208
176
|
|
209
|
-
describe "
|
177
|
+
describe "return value" do
|
210
178
|
|
211
|
-
|
212
|
-
|
213
|
-
Engrade.stub(:gradebook).and_return @response[:assignments]
|
179
|
+
it "should be an Array" do
|
180
|
+
Engrade.classes.should be_an_instance_of Array
|
214
181
|
end
|
215
182
|
|
216
|
-
it "should
|
217
|
-
|
183
|
+
it "should contain Classroom objects" do
|
184
|
+
Engrade.classes.first.should be_an_instance_of Engrade::Classroom
|
218
185
|
end
|
219
186
|
|
220
|
-
it "should
|
221
|
-
|
187
|
+
it "should only include classes that match the :only parameter" do
|
188
|
+
Engrade.classes(:only => "Sem1").each do |cl|
|
189
|
+
cl.name.should match "Sem1"
|
190
|
+
end
|
222
191
|
end
|
223
192
|
|
224
|
-
it "should
|
225
|
-
|
226
|
-
|
193
|
+
it "should not include classes that match the :except paramter" do
|
194
|
+
Engrade.classes(:except => "Sem1").each do |cl|
|
195
|
+
cl.name.should_not match "Sem1"
|
196
|
+
end
|
227
197
|
end
|
228
198
|
|
229
|
-
|
230
|
-
expect { Engrade.assignments [(build :classroom).clid, (build :classroom).clid] }.
|
231
|
-
to_not raise_error
|
232
|
-
end
|
199
|
+
end
|
233
200
|
|
234
|
-
|
235
|
-
classes = [build(:classroom), build(:classroom)]
|
236
|
-
Engrade.should_receive(:gradebook).exactly(2).times
|
237
|
-
Engrade.assignments classes
|
238
|
-
end
|
201
|
+
end
|
239
202
|
|
203
|
+
describe ".assignments" do
|
240
204
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
205
|
+
before :each do
|
206
|
+
@response = build :gradebook
|
207
|
+
Engrade.stub(:gradebook).and_return @response[:assignments]
|
208
|
+
end
|
245
209
|
|
210
|
+
it "should take a class id as input" do
|
211
|
+
expect { Engrade.assignments((build :classroom).clid) }.to_not raise_error
|
212
|
+
end
|
246
213
|
|
247
|
-
|
214
|
+
it "should take a classroom object as input" do
|
215
|
+
expect { Engrade.assignments(build :classroom) }.to_not raise_error
|
216
|
+
end
|
248
217
|
|
249
|
-
|
250
|
-
|
251
|
-
|
218
|
+
it "should take an array of classroom objects as input" do
|
219
|
+
expect { Engrade.assignments [build(:classroom), build(:classroom)] }.
|
220
|
+
to_not raise_error
|
221
|
+
end
|
252
222
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
223
|
+
it "should take an array of clids as input" do
|
224
|
+
expect { Engrade.assignments [(build :classroom).clid, (build :classroom).clid] }.
|
225
|
+
to_not raise_error
|
226
|
+
end
|
257
227
|
|
258
|
-
|
259
|
-
|
260
|
-
|
228
|
+
it "should call .gradebook for each class from input array" do
|
229
|
+
classes = [build(:classroom), build(:classroom)]
|
230
|
+
Engrade.should_receive(:gradebook).exactly(2).times
|
231
|
+
Engrade.assignments classes
|
232
|
+
end
|
261
233
|
|
262
|
-
end
|
263
234
|
|
235
|
+
it "should call .gradebook with the appropriate query" do
|
236
|
+
Engrade.should_receive(:gradebook).with @response[:public_query]
|
237
|
+
Engrade.assignments build(:classroom)
|
264
238
|
end
|
265
239
|
|
266
|
-
|
240
|
+
|
241
|
+
describe "return value" do
|
267
242
|
|
268
243
|
before :each do
|
269
|
-
|
270
|
-
Engrade.stub :post
|
271
|
-
Engrade.browser.stub :remove_comments
|
244
|
+
@class = build :classroom
|
272
245
|
end
|
273
246
|
|
274
|
-
it "should
|
275
|
-
assignments
|
276
|
-
expect { Engrade.delete assignments }.to_not raise_error
|
247
|
+
it "should be an Array" do
|
248
|
+
Engrade.assignments(@class).should be_an_instance_of Array
|
277
249
|
end
|
278
250
|
|
279
|
-
it "should
|
280
|
-
|
281
|
-
|
251
|
+
it "should contain Assignment objects" do
|
252
|
+
Engrade.assignments(@class).first.
|
253
|
+
should be_an_instance_of Engrade::Assignment
|
282
254
|
end
|
283
255
|
|
284
|
-
it "should
|
285
|
-
assignments
|
286
|
-
|
287
|
-
|
256
|
+
it "should contain assigments from all input classes" do
|
257
|
+
Engrade.assignments(@class).size.
|
258
|
+
should be < Engrade.assignments([@class, @class]).size
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should only include assignments that match the :only parameter" do
|
262
|
+
Engrade.assignments(@class, :only => "Pop Quiz").each do |assn|
|
263
|
+
assn.title.should match "Pop Quiz"
|
264
|
+
end
|
288
265
|
end
|
289
266
|
|
290
|
-
it "should
|
291
|
-
Engrade.
|
292
|
-
|
267
|
+
it "should not include assignments that match the :except paramter" do
|
268
|
+
Engrade.assignments(@class, :except => "Pop Quiz").each do |assn|
|
269
|
+
assn.title.should_not match "Pop Quiz"
|
270
|
+
end
|
293
271
|
end
|
294
|
-
|
272
|
+
|
295
273
|
end
|
296
274
|
|
297
275
|
end
|
298
276
|
|
299
|
-
describe "
|
300
|
-
|
301
|
-
|
302
|
-
describe ".teacher_classes" do
|
277
|
+
describe ".delete!" do
|
303
278
|
|
304
279
|
before :each do
|
305
|
-
Engrade.set_apikey ENV['ENG_API']
|
306
280
|
Engrade.set_ses ENV['ENG_SES']
|
307
|
-
|
308
|
-
Engrade.stub :
|
281
|
+
Engrade.stub :post
|
282
|
+
Engrade.browser.stub :remove_comments
|
309
283
|
end
|
310
284
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
Engrade.teacher_classes
|
315
|
-
end
|
316
|
-
|
317
|
-
it "should return an array of classes" do
|
318
|
-
Engrade.stub(:post).and_return @response[:body]
|
319
|
-
Engrade.teacher_classes.should eql @response[:classes]
|
320
|
-
end
|
321
|
-
|
285
|
+
it "should accept an array of Assignments as input" do
|
286
|
+
assignments = [build(:assignment), build(:assignment)]
|
287
|
+
expect { Engrade.delete! assignments }.to_not raise_error
|
322
288
|
end
|
323
289
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
Engrade.set_ses ENV['ENG_SES']
|
329
|
-
@response = build :gradebook
|
330
|
-
Engrade.stub :assignments
|
331
|
-
end
|
332
|
-
|
333
|
-
it "should call .post with appropriate query" do
|
334
|
-
Engrade.should_receive(:post).with(@response[:helper_query]).
|
335
|
-
and_return @response[:body]
|
336
|
-
Engrade.gradebook :clid => build(:classroom).clid
|
337
|
-
end
|
338
|
-
|
339
|
-
it "should return an array of assignments" do
|
340
|
-
Engrade.stub(:post).and_return @response[:body]
|
341
|
-
Engrade.gradebook(:clid => build(:classroom).clid).
|
342
|
-
should eql @response[:assignments]
|
343
|
-
end
|
344
|
-
|
345
|
-
context "with bad class id" do
|
346
|
-
|
347
|
-
it "should raise a InvalidClassId error" do
|
348
|
-
Engrade.stub(:post).and_return build(:bad_class)[:body]
|
349
|
-
expect { Engrade.gradebook(:clid => build(:bad_classroom).clid) }.
|
350
|
-
to raise_error Engrade::InvalidClassId
|
351
|
-
end
|
290
|
+
it "should accept a single Assignment as input" do
|
291
|
+
assignment = build :assignment
|
292
|
+
expect { Engrade.delete! assignment }.to_not raise_error
|
293
|
+
end
|
352
294
|
|
353
|
-
|
295
|
+
it "should remove comments of every assignment" do
|
296
|
+
assignments = [build(:assignment), build(:assignment)]
|
297
|
+
Engrade.browser.should_receive(:remove_comments).exactly(2).times
|
298
|
+
Engrade.delete! assignments
|
299
|
+
end
|
354
300
|
|
301
|
+
it "should call .post with proper query" do
|
302
|
+
Engrade.should_receive(:post).with build(:delete)[:query]
|
303
|
+
Engrade.delete! [build(:assignment)]
|
355
304
|
end
|
356
|
-
|
305
|
+
|
306
|
+
|
357
307
|
end
|
358
308
|
|
359
309
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe Engrade do
|
|
11
11
|
|
12
12
|
VCR.use_cassette('assignments') { @assignments = Engrade.assignments @classes }
|
13
13
|
|
14
|
-
VCR.use_cassette('delete') { Engrade.delete @assignments }
|
14
|
+
VCR.use_cassette('delete') { Engrade.delete! @assignments }
|
15
15
|
|
16
16
|
VCR.use_cassette('result') { @result = Engrade.assignments @classes }
|
17
17
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engrade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -212,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
segments:
|
214
214
|
- 0
|
215
|
-
hash: -
|
215
|
+
hash: -299844275
|
216
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
217
|
none: false
|
218
218
|
requirements:
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
segments:
|
223
223
|
- 0
|
224
|
-
hash: -
|
224
|
+
hash: -299844275
|
225
225
|
requirements: []
|
226
226
|
rubyforge_project:
|
227
227
|
rubygems_version: 1.8.25
|