Skip to content

Commit

Permalink
Add Hook spec example for single-arg function (close #143)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbpros committed Nov 29, 2013
1 parent 217edde commit ae4a29a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion spec/cucumber/support_code/hook_spec.js
Expand Up @@ -30,12 +30,28 @@ describe("Cucumber.SupportCode.Hook", function() {
hook.appliesToScenario.andReturn(true);
});

it("calls the code with the world instance as this", function() {
it("calls the code with the world instance as this and pass it the current scenario", function() {
hook.invokeBesideScenario(scenario, world, callback);
expect(code).toHaveBeenCalledWith(scenario, callback);
expect(code.mostRecentCall.object).toBe(world);
});

describe("when the hook function only accepts one parameter", function () {
beforeEach(function () {
var codeObservingWrapper = function (callback) {
code.apply(this, arguments);
};
hook = Cucumber.SupportCode.Hook(codeObservingWrapper, options);
});

it("doesn't pass the current scenario to the hook function", function() {
hook.invokeBesideScenario(scenario, world, callback);
expect(code).not.toHaveBeenCalledWith(scenario, callback);
expect(code).toHaveBeenCalledWith(callback);
expect(code.mostRecentCall.object).toBe(world);
});
});

it("does not call back", function() {
hook.invokeBesideScenario(scenario, world, callback);
expect(callback).not.toHaveBeenCalled();
Expand Down

0 comments on commit ae4a29a

Please sign in to comment.