 
 
 #
-# all_expectations
-#
-
+# AllExpectations
+#
 # TODO: note about there not being that many expectations (i.e. typically fewer than 10?)
-all_expectations = []
-
-verify_all_expectations = ->
-  errors = find_all_errors()
-  throw new Error( errors ) unless errors == ""
-
-find_all_errors = ->
-  ( expectation.find_errors() for expectation in all_expectations ).join("")
-
-forget_all_expectations = ->
-  all_expectations.length = 0
+#
+class AllExpectations
+	
+	@register_expectation: (expectation) ->
+		AllExpectations._expectations.push(expectation)
+		
+	@verify_all_expectations: ->
+		errors = AllExpectations._find_all_errors()
+		throw new Error(errors) unless errors == ""
+		
+	@unregister_all_expectations: ->
+		AllExpectations._expectations.length = 0
+		
+	# private
+	
+	@_expectations: []
+	
+	@_find_all_errors: ->
+  	  ( expectation.find_errors() for expectation in AllExpectations._expectations ).join("")
   
   
 #

    install_expects_method()
    convenience_mocks = build_convenience_mock_objects()
    run_test_function(test_function, convenience_mocks)
    verify_all_expectations()
  finally
    uninstall_expects_method()
    uninstall_all_mocked_methods()
    forget_all_expectations()

install_expects_method = ->
  Object.prototype.expects = expects

  delete Object.prototype.expects

# TODO: write comment about uninstalling in reverse
# TODO: move into AllExpectations
uninstall_all_mocked_methods = ->
  expectation.uninstall_mocked_method() for expectation in AllExpectations._expectations by -1

build_convenience_mock_objects = ->
  ( new Object() for i in [1..5] )
