rubyuw 0.99.5 → 0.99.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rubyuw/curriculum.rb +1 -1
- data/rubyuw.gemspec +2 -1
- data/test/mocked/curriculum_test.rb +31 -0
- data/test/mocked/fixture_pages/curric_edge_win2010_engl.html +2069 -0
- metadata +2 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.99.
|
1
|
+
0.99.6
|
data/lib/rubyuw/curriculum.rb
CHANGED
@@ -121,7 +121,7 @@ module RubyUW
|
|
121
121
|
|
122
122
|
# Ugly regex to match the <pre> text to extract the proper information for the
|
123
123
|
# course.
|
124
|
-
raise Errors::CourseListingMatchError.new(pre_text) unless pre_text =~ /^((IS\s+)|(Restr\s+))?>?([0-9]+)\s([A-
|
124
|
+
raise Errors::CourseListingMatchError.new(pre_text) unless pre_text =~ /^((IS\s+)|(Restr\s+))?>?([0-9]+)\s([A-Z0-9]{1,2})\s(.+?)\s(.+)/i #\s(([A-Z]+)\s(.+?))\s(([A-Z]+)\s([0-9]+))/i
|
125
125
|
|
126
126
|
{
|
127
127
|
:sln => $4.to_s,
|
data/rubyuw.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rubyuw}
|
8
|
-
s.version = "0.99.
|
8
|
+
s.version = "0.99.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mitchell Hashimoto"]
|
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"test/mocked/errors_test.rb",
|
41
41
|
"test/mocked/fixture_pages/bad_request.html",
|
42
42
|
"test/mocked/fixture_pages/curric_courses.html",
|
43
|
+
"test/mocked/fixture_pages/curric_edge_win2010_engl.html",
|
43
44
|
"test/mocked/fixture_pages/curric_no_courses.html",
|
44
45
|
"test/mocked/fixture_pages/curric_no_curric_found.html",
|
45
46
|
"test/mocked/fixture_pages/logged_in_relay.html",
|
@@ -260,5 +260,36 @@ class CurriculumTest < Test::Unit::TestCase
|
|
260
260
|
}
|
261
261
|
end
|
262
262
|
end
|
263
|
+
|
264
|
+
# Basically the "edge cases" are added to whenever a CourseListingMatchError is
|
265
|
+
# experienced in the real world
|
266
|
+
context "extracting a course listing edge cases" do
|
267
|
+
context "WIN2010 13066" do
|
268
|
+
setup do
|
269
|
+
@page = RubyUW::Base.connection.get(path_to_html("curric_edge_win2010_engl"))
|
270
|
+
|
271
|
+
@listing = {
|
272
|
+
:sln => "13066",
|
273
|
+
:section => "A2"
|
274
|
+
}
|
275
|
+
end
|
276
|
+
|
277
|
+
should "properly parse the entire curriculum" do
|
278
|
+
assert_nothing_raised {
|
279
|
+
RubyUW::Curriculum.extract_courses(@page)
|
280
|
+
}
|
281
|
+
end
|
282
|
+
|
283
|
+
should "properly parse the edge listing" do
|
284
|
+
related = RubyUW::Curriculum.extract_courses(@page)
|
285
|
+
sln_obj = related.values.flatten.detect { |course| course[:sln] == @listing[:sln] }
|
286
|
+
|
287
|
+
assert sln_obj
|
288
|
+
@listing.each do |k,v|
|
289
|
+
assert_equal v, sln_obj[k]
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
263
294
|
end
|
264
295
|
end
|