mitchellh-rubyuw 0.6.2 → 0.7.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.7.0
data/lib/myuw.rb CHANGED
@@ -8,6 +8,7 @@ require 'myuw/session'
8
8
  require 'myuw/sln'
9
9
  require 'myuw/schedule'
10
10
  require 'myuw/registration'
11
+ require 'myuw/curriculum_enrollment'
11
12
 
12
13
  class MyUW
13
14
  extend Forwardable
@@ -55,4 +56,12 @@ class MyUW
55
56
  sln_obj.term = term
56
57
  return sln_obj
57
58
  end
59
+
60
+ # Creates a new curriculum enrollment object and returns it
61
+ def curriculum_enrollment(curric, term)
62
+ curric_obj = CurriculumEnrollment.new(self)
63
+ curric_obj.curriculum = curric
64
+ curric_obj.term = term
65
+ return curric_obj
66
+ end
58
67
  end
data/rubyuw.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rubyuw}
5
- s.version = "0.6.2"
5
+ s.version = "0.7.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Mitchell Hashimoto"]
9
- s.date = %q{2009-07-02}
9
+ s.date = %q{2009-07-11}
10
10
  s.description = %q{TODO}
11
11
  s.email = %q{mitchell.hashimoto@gmail.com}
12
12
  s.extra_rdoc_files = [
@@ -71,6 +71,7 @@ Gem::Specification.new do |s|
71
71
  "test/live/session_test.rb",
72
72
  "test/live/sln_test.rb",
73
73
  "test/live/test_helper.rb",
74
+ "test/mocked/curriculum_enrollment_test.rb",
74
75
  "test/mocked/myuw_test.rb",
75
76
  "test/mocked/registration_test.rb",
76
77
  "test/mocked/schedule_test.rb",
@@ -0,0 +1,87 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class MockedCurriculumEnrollmentTest < Test::Unit::TestCase
4
+ context "fetching curriculum enrollment information" do
5
+ setup do
6
+ @myuw = MyUW.new
7
+ @myuw.stubs(:logged_in?).returns(true)
8
+ @browser = @myuw.browser
9
+ @browser.follow_meta_refresh = false
10
+ @curriculum = @myuw.curriculum_enrollment("CSE", "AUT+2009")
11
+ end
12
+
13
+ should "return a MyUW::CurriculumEnrollment object when calling MyUW.curriculum" do
14
+ curric_obj = @myuw.curriculum_enrollment("CSE", "AUT+2009")
15
+ assert curric_obj.kind_of?(MyUW::CurriculumEnrollment)
16
+ assert_equal "CSE", curric_obj.curriculum
17
+ assert_equal "AUT+2009", curric_obj.term
18
+ end
19
+
20
+ should "raise a NotLoggedInError if not logged in and requesting enrollment information" do
21
+ @myuw.stubs(:logged_in?).returns(false)
22
+
23
+ assert_raise MyUW::NotLoggedInError do
24
+ @curriculum.data_by_sln("foo", true)
25
+ end
26
+ end
27
+
28
+ should "raise an ArgumentError if a curriculum is not set" do
29
+ @curriculum.curriculum = nil
30
+ assert !@curriculum.curriculum
31
+
32
+ assert_raise ArgumentError do
33
+ @curriculum.data_by_sln("foo", true)
34
+ end
35
+ end
36
+
37
+ should "raise an ArgumentError if a term is not set" do
38
+ @curriculum.term = nil
39
+ assert !@curriculum.term
40
+
41
+ assert_raise ArgumentError do
42
+ @curriculum.data_by_sln("foo", true)
43
+ end
44
+ end
45
+
46
+ should "raise an InvalidCurriculumError if it can't find the curriculum info" do
47
+ fixture_page = @browser.get(path_to_html("curric_no_curric_found"))
48
+ @browser.expects(:get).returns(fixture_page)
49
+
50
+ assert_raise MyUW::InvalidCurriculumError do
51
+ @curriculum.get_dept_page
52
+ end
53
+ end
54
+ end
55
+
56
+ context "extracting all course data" do
57
+ setup do
58
+ @myuw = MyUW.new
59
+ @browser = @myuw.browser
60
+ @browser.follow_meta_refresh = false
61
+ @curriculum = @myuw.curriculum_enrollment("CSE", "AUT+2009")
62
+ @fixture_page = @browser.get(path_to_html("curric_courses"))
63
+ end
64
+
65
+ should "raise InvalidPageError if no rows are found for extracting information" do
66
+ fixture_page = @browser.get(path_to_html("curric_no_courses"))
67
+
68
+ assert_raise MyUW::InvalidPageError do
69
+ @curriculum.get_all_courses_data(fixture_page)
70
+ end
71
+ end
72
+
73
+ should "call get_course_data on each node" do
74
+ @curriculum.expects(:get_course_data).at_least(1).returns({
75
+ :sln => "123456"
76
+ })
77
+ assert_nothing_raised { @curriculum.get_all_courses_data(@fixture_page) }
78
+ end
79
+
80
+ should "successfully extract and store course data" do
81
+ assert_nothing_raised { @curriculum.get_all_courses_data(@fixture_page) }
82
+
83
+ # Random test
84
+ assert_equal "54", @curriculum.data["11633"][:current_enrollment]
85
+ end
86
+ end
87
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mitchellh-rubyuw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-02 00:00:00 -07:00
12
+ date: 2009-07-11 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -108,6 +108,7 @@ test_files:
108
108
  - test/live/session_test.rb
109
109
  - test/live/sln_test.rb
110
110
  - test/live/test_helper.rb
111
+ - test/mocked/curriculum_enrollment_test.rb
111
112
  - test/mocked/myuw_test.rb
112
113
  - test/mocked/registration_test.rb
113
114
  - test/mocked/schedule_test.rb