Commit f1502845 f15028450f23a97cab2133b811f98f53bd520e01 by Nicolas Perriault

added Casper#createStep for easily create step functions with options

1 parent 061a8f8a
Showing 1 changed file with 15 additions and 5 deletions
...@@ -228,6 +228,18 @@ ...@@ -228,6 +228,18 @@
228 }, 228 },
229 229
230 /** 230 /**
231 * Creates a step definition.
232 *
233 * @param Function fn The step function to call
234 * @param Object options Step options
235 * @return Function The final step function
236 */
237 createStep: function(fn, options) {
238 fn.options = isType(options, "object") ? options : {};
239 return fn;
240 },
241
242 /**
231 * Logs the HTML code of the current page. 243 * Logs the HTML code of the current page.
232 * 244 *
233 * @return Casper 245 * @return Casper
...@@ -748,13 +760,11 @@ ...@@ -748,13 +760,11 @@
748 * @see Casper#open 760 * @see Casper#open
749 */ 761 */
750 thenOpen: function(location, then) { 762 thenOpen: function(location, then) {
751 var step = function(self) { 763 this.then(this.createStep(function(self) {
752 self.open(location); 764 self.open(location);
753 }; 765 }, {
754 step.options = {
755 skipLog: true 766 skipLog: true
756 }; 767 }));
757 this.then(step);
758 return isType(then, "function") ? this.then(then) : this; 768 return isType(then, "function") ? this.then(then) : this;
759 }, 769 },
760 770
......