So you want to stub message to
any instance of class. Right?
Conceptually, in Mocketry/StateSpecs way, it should looks like:
(Instance of: Something) stub askForName willReturn: 'new'.
or:
(Kind of: Something) stub askForName willReturn: 'new'.
But it will not really works. It will work only on instances which are already "stubbed".
Making it really transparent will require crazy magic underhood. And I am not sure that it is really possible.��
Because generally it should cover existing instances and not just newly created during test.��
And for simple case: to automatically stub new instances their classes should be stubbed with special constructors. But system do not know what exact class side messages are constructors.
So now you can just use simple mock which will be returned as simple stub from concrete constructor of your class:
some := Mock new.
some stub askForName: 'new'.
Something stub new willReturn: some.
I think it looks not not bad and no crazy magic is evolved. And of course you can replace mock with real instance if you want:
some := Something new.
some stub askForName: 'new'.
Something stub new willReturn: some.