<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,11 +11,23 @@ module JRSplenda
       end
     end
     
+    def splenda_mock_attr(arg, options = {})
+       store_mock_in_attr(arg, options) do |class_to_mock|
+         splenda_mock(class_to_mock)
+       end
+     end
+
     def splenda_partial_mock(arg)
       internal_mock(arg) do |class_name|
         partial_mock(class_name)
       end
     end
+
+    def splenda_partial_mock_attr(arg, options = {})
+      store_mock_in_attr(arg, options) do |class_to_mock|
+        splenda_partial_mock(class_to_mock)
+      end
+    end
         
     private
       def internal_mock(class_name, &amp;block)
@@ -63,6 +75,16 @@ module JRSplenda
         end
         mock
       end      
+
+      def store_mock_in_attr(class_to_mock, options, &amp;block)
+        default_field_name = stringify_class(class_to_mock).split('.').last.underscore
+        attr_name = &quot;@&quot; + options.fetch(:store_in, default_field_name).to_s
+        should_preserve_attr = options[:preserve_existing_attr]
+        current_attr_val = instance_variable_get(attr_name)
+        unless current_attr_val &amp;&amp; should_preserve_attr
+          instance_variable_set(attr_name, yield(class_to_mock))
+        end
+      end
             
       def stringify_class(klass)
         name = nil</diff>
      <filename>lib/jrsplenda/jrsplenda_mock_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,12 @@
 require File.dirname(__FILE__) + '/spec_helper.rb'
-
+ 
 describe &quot;A mock helper&quot; do
   include JRSplenda::MockHelper
   
   it &quot;should create a mock of a Java class when give a Java class name when the Java class has not been imported&quot; do
     splenda_mock('fixtures.PrivateField').should be_a_kind_of(PrivateField)
   end
-
+ 
   it &quot;should create a mock of a Java class when give a Java class name when the Java class has been imported&quot; do
     splenda_mock('fixtures.PrivateField').should be_a_kind_of(PrivateField)
   end
@@ -15,7 +15,7 @@ describe &quot;A mock helper&quot; do
     import 'fixtures.PrivateField'
     splenda_mock(PrivateField).should be_a_kind_of(PrivateField)
   end
-  
+
   it &quot;should receive calls delegated by Java objects&quot; do
     import 'fixtures.DelegateToPublicInstanceMethod'
     delegatingObj = DelegateToPublicInstanceMethod.new
@@ -24,4 +24,23 @@ describe &quot;A mock helper&quot; do
     delegatingObj.publicInstanceMethod = mock
     delegatingObj.delegateDoSomething().should == &quot;55&quot;
   end
+    
+  describe &quot;when creating a mock object&quot; do
+    it &quot;should optionally store the created mock in a Ruby member variable by convention&quot; do
+      splenda_mock_attr('fixtures.PrivateField')
+      @private_field.should_not be_nil
+    end
+    
+    it &quot;should optionally store the created mock in a Ruby member variable specified by the caller&quot; do
+      splenda_mock_attr('fixtures.PrivateField', :store_in =&gt; :another_field)
+      @another_field.should_not be_nil
+    end
+    
+    it &quot;should optionally not overwrite existing member variables&quot; do
+      splenda_mock_attr('fixtures.PrivateField')
+      p1 = @private_field
+      splenda_mock_attr('fixtures.PrivateField', :preserve_existing_attr =&gt; true)
+      p1.should equal(@private_field)
+    end
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/mock_helper_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7a22429211a4c6116b5ef236acf69eadc2606250</id>
    </parent>
  </parents>
  <author>
    <name>Evan David Light</name>
    <email>evan@tiggerpalace.com</email>
  </author>
  <url>http://github.com/elight/jrsplenda/commit/7c0ff080b51e1aa79d7181d1e13a640d00a5b756</url>
  <id>7c0ff080b51e1aa79d7181d1e13a640d00a5b756</id>
  <committed-date>2008-08-15T22:44:38-07:00</committed-date>
  <authored-date>2008-08-15T22:44:38-07:00</authored-date>
  <message>Restored splenda_mock_attr -- actually useful for creating mocks while iterating over an array of class name.  Should leave it in</message>
  <tree>0a6b940b4ba3fe5a1beac4998b06524868867bf4</tree>
  <committer>
    <name>Evan David Light</name>
    <email>evan@tiggerpalace.com</email>
  </committer>
</commit>
