On 8/7/07, Scott Taylor <[EMAIL PROTECTED]> wrote: > > Is there any reason why a stub couldn't both yield and return?
Yes. Nobody ever asked for it :) > I'm > looking for a way to mock out a class I've made named "AnonymousClass": > > class AnonymousClass > > def initialize(&blk) > @klass = Class.new > @klass.instance_eval(&blk) if block_given? > end > > def new > @klass.new > end > > def evaluate(&blk) > @klass.instance_eval(&blk) > end > > attr_reader :klass > alias_method :class, :klass > end > > One of the behaviours of the AnonymousClass is that new can take a > block, and eval the block in the anonymous class, represented by the > @klass instance_variable: > > ac = AnonymousClass.new do > include Enumerable > end > > So is there a way to stub AnonymousClass.new such that it yield an > AnonymousClass mock, as well as yielding to the block given? What > are the technical challenges involved in implementing this in the > mocking framework? Or is it a matter of clean syntax? Again - this simply hasn't come up. Please add an RFE and feel free to submit a patch. Cheers, David > > Regards, > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users