Revision
803
Author
eloy.de.enige@gmail.com
Date
2009-01-20 16:34:04 -0800 (Tue, 20 Jan 2009)

Log Message

Cleaned tests up a bit more.

Modified Paths

Diff

Modified: MacRuby/trunk/test-macruby/cases/hotcocoa/mappings_test.rb (802 => 803)


--- MacRuby/trunk/test-macruby/cases/hotcocoa/mappings_test.rb	2009-01-21 00:29:02 UTC (rev 802)
+++ MacRuby/trunk/test-macruby/cases/hotcocoa/mappings_test.rb	2009-01-21 00:34:04 UTC (rev 803)
@@ -4,10 +4,18 @@
 require 'hotcocoa'
 
 class SampleClass
-  def self.val; @val || false; end
-  def self.val= (v); @val = v; end
 end
 
+class Mock
+  def call!
+    @called = true
+  end
+  
+  def called?
+    @called
+  end
+end
+
 class TestMappings < Test::Unit::TestCase
   
   include HotCocoa
@@ -47,7 +55,7 @@
   end
   
   it "should create a mapping to a class in a framework with #map" do
-    mock = mocked_object
+    mock = Mock.new
     
     Mappings.map(:klass => 'ClassInTheFrameWork', :framework => 'TheFramework') do
       mock.call!
@@ -58,14 +66,14 @@
   end
   
   it "should execute the framework's callbacks when #framework_loaded is called" do
-    mock1, mock2 = mocked_object, mocked_object
+    mocks = Array.new(2) { Mock.new }
     
-    [mock1, mock2].each do |mock|
+    mocks.each do |mock|
       Mappings.on_framework('TheFramework') { mock.call! }
     end
     Mappings.framework_loaded('TheFramework')
     
-    [mock1, mock2].each { |mock| assert mock.called? }
+    mocks.each { |mock| assert mock.called? }
   end
   
   it "should do nothing if the framework passed to #framework_loaded isn't registered" do
@@ -77,17 +85,4 @@
   def test_reload
     flunk 'Pending.'
   end
-  
-  private
-  
-  def mocked_object
-    mock = Object.new
-    def mock.call!
-      @called = true
-    end
-    def mock.called?
-      @called
-    end
-    mock
-  end
 end
\ No newline at end of file