On Dec 29, 3:29 ¨Âí¬ Òïâåòô Ëìåííå ¼óèïòôãõô®®®Àçïïçìåíáéì®ãïí¾ ÷òïôåº
> 2009/12/29 Intransition <transf... / gmail.com>:
>
>
>
> > I would like to use #include at an instance level, such that it
> > behaves just as it does at a class level. After a number of
> > experiments I thought for sure it would work if I ran the include
> > through the object's singleton. Alas, submodules remain inaccessible,
> > eg.
>
> >  ¨Âïäõì> >  ¨Âåæ í±¢í±¢åî> >  ¨Âïäõì> >  ¨Âåæ óåìæ®î±» ¢î±¢åî> >  ¨Âîä
> >  ¨Âîä
>
> >  ¨Âìáóó > >  ¨Âåæ éîéôéáìéú娪íïäó> > class << self; self; end).class_eval do
> >  ¨Âîãìõäå ªíïä> >  ¨Âîä
> >  ¨Âîä
> >  ¨Âåæ í± åî> >  ¨Âåæ Î®î± åî>
> Hm, this method above won't work as scope resolution rules for
> constants are different.
>
> >  ¨Âîä
>
> >  ¨Â Ø®îå÷¨Í©
> >  ¨Â ø®> >  ¨Â ø®½¾ õîéîéôéáìéúåãïîóôáîô غºÎ ¨ÎáíåÅòòïò>
> > Is there any way to achieve this?
>
> Did you consider using #extend?
>
>  ¨Âìáóó >  ¨Âåæ éîéôéáìéú娪íïäó>  ¨Âøôåîªíïä>  ¨Âîä
> end
>
> What do you really want to achieve?  ¨Âùïèáöå íïòå ôåììéîåøáíðìå¿

It's for encapsulating test cases. Eg.

  TestCase.new(SomeClass) do
    ...
  end

Within the test case block it would help to handle #include, to make
tests less verbose.

Instead of making an instance of TestCase for each case, at this point
it looks like I'll have to create a new subclass of it.