I have this in my presenter:
private void init() {
view.subscribeOnButtonClick(new Clickable() {
@Override
public void clickPerformed() { sortArray(); }
});
}
And I want to remember this clickable object in my test to trigger it in 'when' part (to simulate button click)
I tried like this:
def view = Mock(ArraySorterView)
def clickable
view.subscribeOnButtonClick(_) >> { x -> clickable = x }
when:
clickable.clickPerformed()
But it is not working. What am I doing wrong?