Skip to content

Commit 41ca41d

Browse files
authored
Added I.say method (#367)
* added I.say method * added say to actor test
1 parent e51cc75 commit 41ca41d

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

examples/github_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Scenario('search', (I) => {
1414

1515
Scenario('signin', (I) => {
1616
I.click('Sign in');
17+
I.say('it should not enter');
1718
I.see('Sign in to GitHub');
1819
I.fillField('Username or email address', 'something@totest.com');
1920
I.fillField('Password', '123456');

lib/actor.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ let container = require('./container');
44
let methodsOfObject = require('./utils').methodsOfObject;
55
let recorder = require('./recorder');
66
let event = require('./event');
7+
let output = require('./output');
78

89
/**
910
* Fetches all methods from all enabled helpers,
@@ -14,10 +15,10 @@ module.exports = function (obj) {
1415
obj = obj || {};
1516

1617
let helpers = container.helpers();
18+
19+
// add methods from enabled helpers
1720
Object.keys(helpers)
18-
.map(function (key) {
19-
return helpers[key];
20-
})
21+
.map((key) => helpers[key])
2122
.forEach((helper) => {
2223
methodsOfObject(helper, 'Helper')
2324
.filter((method) => {
@@ -32,11 +33,15 @@ module.exports = function (obj) {
3233
step.name = actionAlias;
3334
step.actor = container.translation().I;
3435
}
36+
// add methods to promise chain
3537
return recordStep(step, Array.prototype.slice.call(arguments));
3638
};
3739
});
3840
});
3941

42+
// add print comment method
43+
obj.say = (msg) => recorder.add(`say ${msg}`, () => output.say(msg));
44+
4045
return obj;
4146
};
4247

test/unit/actor_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ describe('Actor', () => {
2323
I = actor();
2424
});
2525

26-
it('should take all methods of helpers', () => {
27-
I.should.have.keys(['hello', 'bye', 'greeting']);
26+
it('should take all methods from helpers and built in', () => {
27+
I.should.have.keys(['hello', 'bye', 'greeting', 'say']);
2828
});
2929

3030
it('should return promise', () => {

0 commit comments

Comments
 (0)