Permalink
Browse files

Add Hook spec example for single-arg function (close #143)

  • Loading branch information...
1 parent 217edde commit ae4a29a49fac153baf145a812742e083f2b3eda2 @jbpros jbpros committed Nov 29, 2013
Showing with 17 additions and 1 deletion.
  1. +17 −1 spec/cucumber/support_code/hook_spec.js
@@ -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();

0 comments on commit ae4a29a

Please sign in to comment.