On Aug 14, 2007, at 5:17 PM, aslak hellesoy wrote:

> On 8/14/07, Scott Taylor <[EMAIL PROTECTED]> wrote:
>>
>> How would you spec out something like the following:
>>
>
> You're starting with the code, trying to tape on the spec afterwards.
> This is always a difficult task and is exactly what BDD and RSpec is
> trying to get you away from.
>
> Have you tried writing the RSpec examples first? I'd help you with an
> example if I knew what you're trying to achieve from a functional (not
> code) standpoint.


Sounds fair.  The only reason I included the code first and presented  
it in that way was for simplicity.  I'll now go for the complexity:

I already have developed test first, and running specs.  I'd now like  
to refactor, but my specs are preventing me.  The code is here:

http://pastie.caboo.se/87722

Here is the code I'd like to refactor:

       def anonymous_class_with_loaded_modules(*mods)
         klass = Class.new
         mods.each do |mod|
           klass.send(:include, mod)
         end
         return klass
       end

I'd like to change it to this, which is functionally equivalent:

       def anonymous_class_with_loaded_modules(*mods)
         klass = Class.new do
            mods.each do |mod|
              include, mod
            end
         end
         return klass
       end

Sorry for the long code samples, but I'm not exactly sure how to  
simplify them.  I can also give you a high level over-view of what  
this code is doing and what it's purpose is.  Let me know if that  
would better help you help me.

Thanks for listening,

Scott




_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to