Monkey patching with reopen?


#1

Hi everyone !

I am looking at doing something like that to make sure my user event handling is correctly link to actions and to property recalculation. The issue is that one of those actions rely on run.later which screw up the behaviour of the visit, andThen & company.

I thought I would try to use some kind of monkey patching test to have a good enough integration test.

How can I reopen a class for a single test run and not for all the tests in my suite?

Here is a draft of how I see it and my tests runs well but I can’t find out how to restore my old class which in turns screw up other tests.

import MyObject from 'ember-my-addon/.../my-object';
test('blah', function (assert) {
	MyObject.reopen({
		//Do some monkey patching here
	});
	//run my tests
	MyObject.reopen({
		Here is the issue: 
		How could I reset MyObject to its state before the first reopen
	});
});

Thanks!