From 55bde5b55b13f868c08651472e560bd89d041782 Mon Sep 17 00:00:00 2001 From: Davert Date: Sat, 14 Jan 2017 00:50:08 +0200 Subject: [PATCH 1/2] added I.say method --- examples/github_test.js | 1 + lib/actor.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/github_test.js b/examples/github_test.js index 209437cde..060ca3bfb 100644 --- a/examples/github_test.js +++ b/examples/github_test.js @@ -14,6 +14,7 @@ Scenario('search', (I) => { Scenario('signin', (I) => { I.click('Sign in'); + I.say('it should not enter'); I.see('Sign in to GitHub'); I.fillField('Username or email address', 'something@totest.com'); I.fillField('Password', '123456'); diff --git a/lib/actor.js b/lib/actor.js index e963f852e..03eb8ce72 100644 --- a/lib/actor.js +++ b/lib/actor.js @@ -4,6 +4,7 @@ let container = require('./container'); let methodsOfObject = require('./utils').methodsOfObject; let recorder = require('./recorder'); let event = require('./event'); +let output = require('./output'); /** * Fetches all methods from all enabled helpers, @@ -14,10 +15,10 @@ module.exports = function (obj) { obj = obj || {}; let helpers = container.helpers(); + + // add methods from enabled helpers Object.keys(helpers) - .map(function (key) { - return helpers[key]; - }) + .map((key) => helpers[key]) .forEach((helper) => { methodsOfObject(helper, 'Helper') .filter((method) => { @@ -32,11 +33,15 @@ module.exports = function (obj) { step.name = actionAlias; step.actor = container.translation().I; } + // add methods to promise chain return recordStep(step, Array.prototype.slice.call(arguments)); }; }); }); + // add print comment method + obj.say = (msg) => recorder.add(`say ${msg}`, () => output.say(msg)); + return obj; }; From 90112ff390dcc6edc295134229525ec9704ef993 Mon Sep 17 00:00:00 2001 From: Davert Date: Sat, 14 Jan 2017 01:07:13 +0200 Subject: [PATCH 2/2] added say to actor test --- test/unit/actor_test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/actor_test.js b/test/unit/actor_test.js index d21bdf842..0b2338473 100644 --- a/test/unit/actor_test.js +++ b/test/unit/actor_test.js @@ -23,8 +23,8 @@ describe('Actor', () => { I = actor(); }); - it('should take all methods of helpers', () => { - I.should.have.keys(['hello', 'bye', 'greeting']); + it('should take all methods from helpers and built in', () => { + I.should.have.keys(['hello', 'bye', 'greeting', 'say']); }); it('should return promise', () => {