I'm struggling a bit with `expect` and `allow`. Looking at the docs, I'd say `expect` is for mocking and `allow` is for stubbing, however I don't seem to get them to work as I expect.
For instance: I've got the following:
[Before]
public function setup():void{
allow( mockLoaderFactory.createURLLoader( arg( anything( ) ) ) )
.returns( mockLoader );
stub( mockLoader ).asEventDispatcher();
instance = new BaseLoaderServiceImpl();
instance.urlLoaderFactory = mockLoaderFactory;
}
There are tests that will be calling
mockLoaderFactory.createURLLoader and others will not, so I'd think I have to use `allow` here and not `expect`, otherwise the tests that don't call that method will complain.However [Test]
public function test_loadRequest_setsIsBusyToTrue() : void{
instance.loadRequest( new URLRequest( 'http://mock' ) ); assertTrue( instance.isBusy );
}
instance.loadRequest does call mockLoaderFactory.createURLLoader but it doesn't appear to return anything. So, if I assume correctly, `allow` just literally allows the call on the method, but it doesn't _do_ anything?
How would I be able to do this then? I just want to replace a stub, so I don't have to use the methodname as string approach.