From 992c790f0786fa45c1cc3710f29bf49c7c322ba7 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 29 Nov 2011 21:51:59 -0800 Subject: refactor(scope): separate controller from scope Controller is standalone object, created using "new" operator, not messed up with scope anymore. Instead, related scope is injected as $scope. See design proposal: https://docs.google.com/document/pub?id=1SsgVj17ec6tnZEX3ugsvg0rVVR11wTso5Md-RdEmC0k Closes #321 Closes #425 Breaks controller methods are not exported to scope automatically Breaks Scope#$new() does not take controller as argument anymore--- src/scenario/Runner.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/scenario') diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js index cfde1f64..06ad3aa1 100644 --- a/src/scenario/Runner.js +++ b/src/scenario/Runner.js @@ -152,7 +152,16 @@ angular.scenario.Runner.prototype.afterEach = function(body) { * @param {Object} scope parent scope */ angular.scenario.Runner.prototype.createSpecRunner_ = function(scope) { - return scope.$new(angular.scenario.SpecRunner); + var child = scope.$new(); + var Cls = angular.scenario.SpecRunner; + + // Export all the methods to child scope manually as now we don't mess controllers with scopes + // TODO(vojta): refactor scenario runner so that these objects are not tightly coupled as current + for (var name in Cls.prototype) + child[name] = angular.bind(child, Cls.prototype[name]); + + Cls.call(child); + return child; }; /** -- cgit v1.2.3