diff --git a/features/multiple_formatters.feature b/features/multiple_formatters.feature new file mode 100644 index 000000000..8096f9789 --- /dev/null +++ b/features/multiple_formatters.feature @@ -0,0 +1,47 @@ +Feature: Multiple Formatters + + Background: + Given a file named "features/a.feature" with: + """ + Feature: some feature + + Scenario: I've declared one step which passes + Given This step is passing + """ + And a file named "features/step_definitions/cucumber_steps.js" with: + """ + var cucumberSteps = function() { + this.Given(/^This step is passing$/, function(callback) { callback(); }); + }; + module.exports = cucumberSteps; + """ + + Scenario: Ability to specify multiple formatters + When I run cucumber.js with `-f progress -f pretty:pretty.txt` + Then it outputs this text: + """ + . + + 1 scenario (1 passed) + 1 step (1 passed) + + """ + And the file "pretty.txt" has the text: + """ + Feature: some feature + + Scenario: I've declared one step which passes # features/a.feature:3 + Given This step is passing # features/a.feature:4 + + 1 scenario (1 passed) + 1 step (1 passed) + + """ + + Scenario: Invalid path + When I run cucumber.js with `-f progress -f pretty:invalid/pretty.txt` + Then the error output contains the text: + """ + ENOENT + """ + And the exit status should be non-zero diff --git a/features/step_definitions/cli_steps.js b/features/step_definitions/cli_steps.js index 71256ec1a..55b0f811f 100644 --- a/features/step_definitions/cli_steps.js +++ b/features/step_definitions/cli_steps.js @@ -89,12 +89,13 @@ var cliSteps = function cliSteps() { } }); - this.Then(/^the exit status should be ([0-9]+)$/, function (code, callback) { + this.Then(/^the exit status should be ([0-9]+|non-zero)$/, function (code, callback) { var world = this; - var actualCode = world.lastRun.error ? world.lastRun.error.code : "0"; + var actualCode = world.lastRun.error ? world.lastRun.error.code : 0; + var ok = (code === 'non-zero' && actualCode !== 0) || actualCode === parseInt(code); - if (actualCode != code) { + if (!ok) { throw new Error("Exit code expected: \"" + code + "\"\n" + "Got: \"" + actualCode + "\"\n" + "Output:\n" + normalizeText(world.lastRun.stdout) + "\n" + @@ -145,10 +146,10 @@ var cliSteps = function cliSteps() { callback(); }); - this.Then(/^the output contains the text:$/, function(expectedOutput, callback) { + this.Then(/^the (error )?output contains the text:$/, function(error, expectedOutput, callback) { var world = this; - var actualOutput = world.lastRun['stdout']; + var actualOutput = error ? world.lastRun['stderr'] : world.lastRun['stdout']; actualOutput = normalizeText(actualOutput); expectedOutput = normalizeText(expectedOutput); @@ -160,6 +161,21 @@ var cliSteps = function cliSteps() { callback(); }); + this.Then(/^the file "([^"]*)" has the text:$/, function (filePath, expectedContent, callback) { + var absoluteFilePath = tmpPath(filePath); + fs.readFile(absoluteFilePath, 'utf8', function (err, content){ + if (err) { return callback(err); } + + actualContent = normalizeText(content); + expectedContent = normalizeText(expectedContent); + + if (actualContent != expectedContent) + throw new Error("Expected " + filePath + " to have content matching:\n'" + expectedContent + "'\n" + + "Got:\n'" + actualContent + "'.\n"); + callback(); + }) + }); + this.Then(/^I see the version of Cucumber$/, function(callback) { var world = this; diff --git a/lib/cucumber/cli.js b/lib/cucumber/cli.js index 8df4d4c29..2afb80963 100644 --- a/lib/cucumber/cli.js +++ b/lib/cucumber/cli.js @@ -13,9 +13,11 @@ function Cli(argv) { }, runSuiteWithConfiguration: function runSuiteWithConfiguration(configuration, callback) { - var runtime = Cucumber.Runtime(configuration); - var formatter = configuration.getFormatter(); - runtime.attachListener(formatter); + var runtime = Cucumber.Runtime(configuration); + var formatters = configuration.getFormatters(); + formatters.forEach(function (formatter) { + runtime.attachListener(formatter); + }); runtime.start(callback); }, @@ -58,7 +60,8 @@ function Cli(argv) { tags to exclude several tags you have to use\n\ logical AND: --tags ~@fixme --tags ~@buggy.\n\ \n\ --f, --format FORMAT How to format features (default: progress).\n\ +-f, --format FORMAT[:PATH] How to format features (default: progress).\n\ + Supply PATH to redirect that formatters output.\n\ Available formats:\n\ pretty : prints the feature as is\n\ progress: prints one character per scenario\n\ diff --git a/lib/cucumber/cli/argument_parser.js b/lib/cucumber/cli/argument_parser.js index 6e6268187..0593e2a24 100644 --- a/lib/cucumber/cli/argument_parser.js +++ b/lib/cucumber/cli/argument_parser.js @@ -4,6 +4,7 @@ function ArgumentParser(argv) { var nopt = require('nopt'); var path = require('path'); var _ = require('underscore'); + var fs = require('fs'); var options; var self = { @@ -106,9 +107,23 @@ function ArgumentParser(argv) { return modules; }, - getFormat: function getFormat() { - var format = self.getOptionOrDefault(ArgumentParser.FORMAT_OPTION_NAME, ArgumentParser.DEFAULT_FORMAT_VALUE); - return format; + getFormats: function getFormats() { + var formats = self.getOptionOrDefault(ArgumentParser.FORMAT_OPTION_NAME, [ArgumentParser.DEFAULT_FORMAT_VALUE]); + var outputMapping = {}; + formats.forEach(function (format) { + var parts = format.split(':'); + var type = parts[0]; + var outputTo = parts[1] || ''; + outputMapping[outputTo] = type; + }); + return _.map(outputMapping, function (type, outputTo) { + var stream = process.stdout; + if (outputTo) { + var fd = fs.openSync(outputTo, 'w'); + stream = fs.createWriteStream(null, {fd: fd}); + } + return {stream: stream, type: type}; + }); }, getKnownOptionDefinitions: function getKnownOptionDefinitions() { @@ -117,7 +132,7 @@ function ArgumentParser(argv) { definitions[ArgumentParser.TAGS_OPTION_NAME] = [String, Array]; definitions[ArgumentParser.COMPILER_OPTION_NAME] = [String, Array]; definitions[ArgumentParser.PROFILE_OPTION_NAME] = [String, Array]; - definitions[ArgumentParser.FORMAT_OPTION_NAME] = String; + definitions[ArgumentParser.FORMAT_OPTION_NAME] = [String, Array]; definitions[ArgumentParser.HELP_FLAG_NAME] = Boolean; definitions[ArgumentParser.VERSION_FLAG_NAME] = Boolean; definitions[ArgumentParser.COFFEE_SCRIPT_SNIPPETS_FLAG_NAME] = Boolean; diff --git a/lib/cucumber/cli/configuration.js b/lib/cucumber/cli/configuration.js index 2b4ac4c23..bee7d5f24 100644 --- a/lib/cucumber/cli/configuration.js +++ b/lib/cucumber/cli/configuration.js @@ -5,31 +5,30 @@ function Configuration(argv) { argumentParser.parse(); var self = { - getFormatter: function getFormatter() { - var formatter; - var format = argumentParser.getFormat(); - var options = { - coffeeScriptSnippets: self.shouldSnippetsBeInCoffeeScript(), - snippets: self.shouldSnippetsBeShown(), - showSource: self.shouldShowSource() - }; - switch(format) { - case Configuration.JSON_FORMAT_NAME: - formatter = Cucumber.Listener.JsonFormatter(options); - break; - case Configuration.PROGRESS_FORMAT_NAME: - formatter = Cucumber.Listener.ProgressFormatter(options); - break; - case Configuration.PRETTY_FORMAT_NAME: - formatter = Cucumber.Listener.PrettyFormatter(options); - break; - case Configuration.SUMMARY_FORMAT_NAME: - formatter = Cucumber.Listener.SummaryFormatter(options); - break; - default: - throw new Error('Unknown formatter name "' + format + '".'); - } - return formatter; + getFormatters: function getFormatters() { + var formats = argumentParser.getFormats(); + var formatters = formats.map(function (format) { + var options = { + coffeeScriptSnippets: self.shouldSnippetsBeInCoffeeScript(), + snippets: self.shouldSnippetsBeShown(), + showSource: self.shouldShowSource(), + stream: format.stream + }; + + switch(format.type) { + case Configuration.JSON_FORMAT_NAME: + return Cucumber.Listener.JsonFormatter(options); + case Configuration.PROGRESS_FORMAT_NAME: + return Cucumber.Listener.ProgressFormatter(options); + case Configuration.PRETTY_FORMAT_NAME: + return Cucumber.Listener.PrettyFormatter(options); + case Configuration.SUMMARY_FORMAT_NAME: + return Cucumber.Listener.SummaryFormatter(options); + default: + throw new Error('Unknown formatter name "' + format + '".'); + } + }); + return formatters; }, getFeatureSources: function getFeatureSources() { diff --git a/lib/cucumber/listener/formatter.js b/lib/cucumber/listener/formatter.js index 6c192ed0c..e2405eb59 100644 --- a/lib/cucumber/listener/formatter.js +++ b/lib/cucumber/listener/formatter.js @@ -12,12 +12,19 @@ function Formatter(options) { self.log = function log(string) { logs += string; - if (options.logToConsole) - process.stdout.write(string); + if (options.stream) + options.stream.write(string); if (typeof(options.logToFunction) === 'function') options.logToFunction(string); }; + self.finish = function finish(callback) { + if (options.stream && options.stream !== process.stdout) + options.stream.end(callback); + else + callback(); + }; + self.getLogs = function getLogs() { return logs; }; diff --git a/lib/cucumber/listener/json_formatter.js b/lib/cucumber/listener/json_formatter.js index faa4981c6..0774d178b 100644 --- a/lib/cucumber/listener/json_formatter.js +++ b/lib/cucumber/listener/json_formatter.js @@ -175,7 +175,7 @@ function JsonFormatter(options) { self.handleAfterFeaturesEvent = function handleAfterFeaturesEvent(event, callback) { gherkinJsonFormatter.eof(); gherkinJsonFormatter.done(); - callback(); + self.finish(callback); }; return self; diff --git a/lib/cucumber/listener/pretty_formatter.js b/lib/cucumber/listener/pretty_formatter.js index 2c6af129f..e8eaf8a4f 100644 --- a/lib/cucumber/listener/pretty_formatter.js +++ b/lib/cucumber/listener/pretty_formatter.js @@ -139,7 +139,7 @@ function PrettyFormatter(options) { self.handleAfterFeaturesEvent = function handleAfterFeaturesEvent(event, callback) { var summaryLogs = summaryFormatter.getLogs(); self.log(summaryLogs); - callback(); + self.finish(callback); }; self.formatDataTable = function formatDataTable(stepResult, dataTable) { diff --git a/lib/cucumber/listener/progress_formatter.js b/lib/cucumber/listener/progress_formatter.js index 7d39aed31..e40fbd2fc 100644 --- a/lib/cucumber/listener/progress_formatter.js +++ b/lib/cucumber/listener/progress_formatter.js @@ -58,7 +58,7 @@ function ProgressFormatter(options) { var summaryLogs = summaryFormatter.getLogs(); self.log('\n\n'); self.log(summaryLogs); - callback(); + self.finish(callback); }; return self; diff --git a/lib/cucumber/listener/summary_formatter.js b/lib/cucumber/listener/summary_formatter.js index 27cc3a24f..7c5d92045 100644 --- a/lib/cucumber/listener/summary_formatter.js +++ b/lib/cucumber/listener/summary_formatter.js @@ -48,7 +48,7 @@ function SummaryFormatter(options) { self.handleAfterFeaturesEvent = function handleAfterFeaturesEvent(event, callback) { self.logSummary(); - callback(); + self.finish(callback); }; self.storeFailedStepResult = function storeFailedStepResult(failedStepResult) { diff --git a/spec/cucumber/cli/argument_parser_spec.js b/spec/cucumber/cli/argument_parser_spec.js index 812fdc049..653778209 100644 --- a/spec/cucumber/cli/argument_parser_spec.js +++ b/spec/cucumber/cli/argument_parser_spec.js @@ -3,6 +3,7 @@ require('../../support/spec_helper'); describe("Cucumber.Cli.ArgumentParser", function () { var Cucumber = requireLib('cucumber'); var path = require('path'); + var fs = require('fs'); var nopt; var argumentParser, argv, slicedArgv; @@ -196,8 +197,8 @@ describe("Cucumber.Cli.ArgumentParser", function () { expect(knownOptionDefinitions['compiler']).toEqual([String, Array]); }); - it("defines a --format option", function () { - expect(knownOptionDefinitions['format']).toEqual(String); + it("defines a repeatable --format option", function () { + expect(knownOptionDefinitions['format']).toEqual([String, Array]); }); it("defines a --strict flag", function () { @@ -451,21 +452,25 @@ describe("Cucumber.Cli.ArgumentParser", function () { }); }); - describe("getFormat()", function () { - var format; + describe("getFormats()", function () { + var formats, fd, stream; beforeEach(function () { - format = createSpy("format"); - spyOn(argumentParser, 'getOptionOrDefault').and.returnValue(format); - }); - - it("gets the format option value", function () { - argumentParser.getFormat(); - expect(argumentParser.getOptionOrDefault).toHaveBeenCalledWith(Cucumber.Cli.ArgumentParser.FORMAT_OPTION_NAME, 'pretty'); - }); - - it("returns the format", function () { - expect(argumentParser.getFormat()).toBe(format); + formats = ['progress', 'summary', 'pretty:path/to/file']; + fd = createSpy('fd'); + stream = createSpy('stream'); + spyOn(argumentParser, 'getOptionOrDefault').and.returnValue(formats); + spyOn(fs, 'openSync').and.returnValue(fd); + spyOn(fs, 'createWriteStream').and.returnValue(stream); + }); + + it("returns the formats", function () { + expect(argumentParser.getFormats()).toEqual([ + {stream: process.stdout, type: 'summary'}, + {stream: stream, type: 'pretty'}, + ]); + expect(fs.openSync).toHaveBeenCalledWith('path/to/file', 'w'); + expect(fs.createWriteStream).toHaveBeenCalledWith(null, {fd: fd}); }); }); diff --git a/spec/cucumber/cli/configuration_spec.js b/spec/cucumber/cli/configuration_spec.js index d6d471b5c..2d1c429a3 100644 --- a/spec/cucumber/cli/configuration_spec.js +++ b/spec/cucumber/cli/configuration_spec.js @@ -28,15 +28,16 @@ describe("Cucumber.Cli.Configuration", function () { }); }); - describe("getFormatter()", function () { - var shouldSnippetsBeInCoffeeScript, formatterOptions, shouldSnippetsBeShown, shouldShowSource; + describe("getFormatters()", function () { + var shouldSnippetsBeInCoffeeScript, formatterOptions, shouldSnippetsBeShown, shouldShowSource, stream; beforeEach(function () { + stream = createSpy('stream'); shouldSnippetsBeInCoffeeScript = createSpy("should snippets be in CS?"); shouldSnippetsBeShown = createSpy("should snippets be shown?"); shouldShowSource = createSpy("should source uris be visible?"); - formatterOptions = {coffeeScriptSnippets: shouldSnippetsBeInCoffeeScript, snippets: shouldSnippetsBeShown, showSource: shouldShowSource}; - spyOnStub(argumentParser, 'getFormat').and.returnValue("progress"); + formatterOptions = {coffeeScriptSnippets: shouldSnippetsBeInCoffeeScript, snippets: shouldSnippetsBeShown, showSource: shouldShowSource, stream: stream}; + spyOnStub(argumentParser, 'getFormats').and.returnValue([]); spyOnStub(argumentParser, 'shouldSnippetsBeInCoffeeScript').and.returnValue(shouldSnippetsBeInCoffeeScript); spyOnStub(argumentParser, 'shouldSnippetsBeShown').and.returnValue(shouldSnippetsBeShown); spyOnStub(argumentParser, 'shouldShowSource').and.returnValue(shouldShowSource); @@ -46,42 +47,22 @@ describe("Cucumber.Cli.Configuration", function () { spyOn(Cucumber.Listener, 'SummaryFormatter'); }); - it("gets the formatter name from the argument parser", function () { - configuration.getFormatter(); - expect(argumentParser.getFormat).toHaveBeenCalled(); - }); - - it("checks whether the step definition snippets should be in CoffeeScript", function () { - configuration.getFormatter(); - expect(argumentParser.shouldSnippetsBeInCoffeeScript).toHaveBeenCalled(); - }); - - it("checks whether the source uris should be shown", function () { - configuration.getFormatter(); - expect(argumentParser.shouldShowSource).toHaveBeenCalled(); - }); - - it("checks whether the step definition snippets should be shown", function () { - configuration.getFormatter(); - expect(argumentParser.shouldSnippetsBeShown).toHaveBeenCalledTimes(1); - }); - describe("when the formatter name is \"json\"", function () { var formatter; beforeEach(function () { - argumentParser.getFormat.and.returnValue("json"); + argumentParser.getFormats.and.returnValue([{type: "json", stream: stream}]); formatter = createSpy("formatter"); Cucumber.Listener.JsonFormatter.and.returnValue(formatter); }); - it("creates a new progress formatter", function () { - configuration.getFormatter(); + it("creates a new json formatter", function () { + configuration.getFormatters(); expect(Cucumber.Listener.JsonFormatter).toHaveBeenCalledWith(formatterOptions); }); - it("returns the progress formatter", function () { - expect(configuration.getFormatter()).toBe(formatter); + it("returns the json formatter", function () { + expect(configuration.getFormatters()).toEqual([formatter]); }); }); @@ -89,18 +70,18 @@ describe("Cucumber.Cli.Configuration", function () { var formatter; beforeEach(function () { - argumentParser.getFormat.and.returnValue("progress"); + argumentParser.getFormats.and.returnValue([{type: "progress", stream: stream}]); formatter = createSpy("formatter"); Cucumber.Listener.ProgressFormatter.and.returnValue(formatter); }); it("creates a new progress formatter", function () { - configuration.getFormatter(); + configuration.getFormatters(); expect(Cucumber.Listener.ProgressFormatter).toHaveBeenCalledWith(formatterOptions); }); it("returns the progress formatter", function () { - expect(configuration.getFormatter()).toBe(formatter); + expect(configuration.getFormatters()).toEqual([formatter]); }); }); @@ -108,18 +89,18 @@ describe("Cucumber.Cli.Configuration", function () { var formatter; beforeEach(function () { - argumentParser.getFormat.and.returnValue("pretty"); + argumentParser.getFormats.and.returnValue([{type: "pretty", stream: stream}]); formatter = createSpy("formatter"); Cucumber.Listener.PrettyFormatter.and.returnValue(formatter); }); it("creates a new pretty formatter", function () { - configuration.getFormatter(); + configuration.getFormatters(); expect(Cucumber.Listener.PrettyFormatter).toHaveBeenCalledWith(formatterOptions); }); it("returns the pretty formatter", function () { - expect(configuration.getFormatter()).toBe(formatter); + expect(configuration.getFormatters()).toEqual([formatter]); }); }); @@ -127,28 +108,28 @@ describe("Cucumber.Cli.Configuration", function () { var formatter; beforeEach(function () { - argumentParser.getFormat.and.returnValue("summary"); + argumentParser.getFormats.and.returnValue([{type: "summary", stream: stream}]); formatter = createSpy("formatter"); Cucumber.Listener.SummaryFormatter.and.returnValue(formatter); }); it("creates a new summary formatter", function () { - configuration.getFormatter(); + configuration.getFormatters(); expect(Cucumber.Listener.SummaryFormatter).toHaveBeenCalledWith(formatterOptions); }); it("returns the summary formatter", function () { - expect(configuration.getFormatter()).toBe(formatter); + expect(configuration.getFormatters()).toEqual([formatter]); }); }); describe("when the formatter name is unknown", function () { beforeEach(function () { - argumentParser.getFormat.and.returnValue("blah"); + argumentParser.getFormats.and.returnValue([{type: "blah", stream: stream}]); }); it("throws an exceptions", function () { - expect(configuration.getFormatter).toThrow(); + expect(configuration.getFormatters).toThrow(); }); }); }); diff --git a/spec/cucumber/cli_spec.js b/spec/cucumber/cli_spec.js index a454754e4..f7c7ffe55 100644 --- a/spec/cucumber/cli_spec.js +++ b/spec/cucumber/cli_spec.js @@ -113,7 +113,7 @@ describe("Cucumber.Cli", function () { beforeEach(function () { formatter = createSpy("formatter"); - configuration = createSpyWithStubs("CLI configuration", {getFormatter: formatter}); + configuration = createSpyWithStubs("CLI configuration", {getFormatters: [formatter]}); runtime = createSpyWithStubs("runtime", {start: null, attachListener: null}); callback = createSpy("callback"); spyOn(Cucumber, 'Runtime').and.returnValue(runtime); @@ -124,11 +124,6 @@ describe("Cucumber.Cli", function () { expect(Cucumber.Runtime).toHaveBeenCalledWith(configuration); }); - it("gets the formatter from the configuration", function () { - cli.runSuiteWithConfiguration(configuration, callback); - expect(configuration.getFormatter).toHaveBeenCalled(); - }); - it("attaches the formatter to the runtime", function () { cli.runSuiteWithConfiguration(configuration, callback); expect(runtime.attachListener).toHaveBeenCalledWith(formatter); diff --git a/spec/cucumber/listener/formatter_spec.js b/spec/cucumber/listener/formatter_spec.js index 4b08f6b69..1caf1b226 100644 --- a/spec/cucumber/listener/formatter_spec.js +++ b/spec/cucumber/listener/formatter_spec.js @@ -38,30 +38,17 @@ describe("Cucumber.Listener.Formatter", function () { expect(formatter.getLogs()).toBe(loggedBuffer); }); - it("outputs the logged string to STDOUT by default", function () { - formatter.log(logged); - expect(process.stdout.write).toHaveBeenCalledWith(logged); - }); - - describe("when asked to output to STDOUT", function () { - beforeEach(function () { - formatter = Cucumber.Listener.Formatter({logToConsole: true}); - }); - - it("outputs the logged string to STDOUT", function () { - formatter.log(logged); - expect(process.stdout.write).toHaveBeenCalledWith(logged); - }); - }); + describe("when asked to output to a stream", function () { + var stream; - describe("when asked to not output to STDOUT", function () { beforeEach(function () { - formatter = Cucumber.Listener.Formatter({logToConsole: false}); + stream = createSpyWithStubs('stream', {write: null}); + formatter = Cucumber.Listener.Formatter({stream: stream}); }); - it("does not output anything to STDOUT", function () { + it("outputs the logged string to the stream", function () { formatter.log(logged); - expect(process.stdout.write).not.toHaveBeenCalledWith(logged); + expect(stream.write).toHaveBeenCalledWith(logged); }); }); diff --git a/spec/cucumber/listener/pretty_formatter_spec.js b/spec/cucumber/listener/pretty_formatter_spec.js index 9a1375b34..a07cbe72e 100644 --- a/spec/cucumber/listener/pretty_formatter_spec.js +++ b/spec/cucumber/listener/pretty_formatter_spec.js @@ -7,7 +7,7 @@ describe("Cucumber.Listener.PrettyFormatter", function () { beforeEach(function () { options = createSpy("options"); - formatter = createSpyWithStubs("formatter"); + formatter = createSpyWithStubs("formatter", {finish: null}); logged = ''; spyOnStub(formatter, 'log').and.callFake(function (text) { logged += text; }); formatterHearMethod = spyOnStub(formatter, 'hear'); @@ -442,9 +442,9 @@ describe("Cucumber.Listener.PrettyFormatter", function () { expect(prettyFormatter.log).toHaveBeenCalledWith(summary); }); - it("calls back", function () { + it("calls finish with the callback", function () { prettyFormatter.handleAfterFeaturesEvent(event, callback); - expect(callback).toHaveBeenCalled(); + expect(prettyFormatter.finish).toHaveBeenCalledWith(callback); }); }); diff --git a/spec/cucumber/listener/progress_formatter_spec.js b/spec/cucumber/listener/progress_formatter_spec.js index bc2e06d7b..182cd01f2 100644 --- a/spec/cucumber/listener/progress_formatter_spec.js +++ b/spec/cucumber/listener/progress_formatter_spec.js @@ -6,7 +6,7 @@ describe("Cucumber.Listener.ProgressFormatter", function () { beforeEach(function () { options = createSpy("options"); - formatter = createSpyWithStubs("formatter", {log: null}); + formatter = createSpyWithStubs("formatter", {finish: null, log: null}); formatterHearMethod = spyOnStub(formatter, 'hear'); summaryFormatter = createSpy("summaryFormatter"); spyOn(Cucumber.Listener, 'Formatter').and.returnValue(formatter); @@ -279,9 +279,9 @@ describe("Cucumber.Listener.ProgressFormatter", function () { expect(progressFormatter.log).toHaveBeenCalledWith(summaryLogs); }); - it("calls back", function () { + it("calls finish with the callback", function () { progressFormatter.handleAfterFeaturesEvent(event, callback); - expect(callback).toHaveBeenCalled(); + expect(progressFormatter.finish).toHaveBeenCalledWith(callback); }); }); }); diff --git a/spec/cucumber/listener/summary_formatter_spec.js b/spec/cucumber/listener/summary_formatter_spec.js index 1cb17253d..b26c2ca96 100644 --- a/spec/cucumber/listener/summary_formatter_spec.js +++ b/spec/cucumber/listener/summary_formatter_spec.js @@ -6,7 +6,7 @@ describe("Cucumber.Listener.SummaryFormatter", function () { beforeEach(function () { options = {}; - formatter = createSpyWithStubs("formatter", {log: null}); + formatter = createSpyWithStubs("formatter", {finish: null, log: null}); formatterHearMethod = spyOnStub(formatter, 'hear'); statsJournal = createSpy("stats journal"); failedStepResults = createSpy("failed steps"); @@ -252,9 +252,9 @@ describe("Cucumber.Listener.SummaryFormatter", function () { expect(summaryFormatter.logSummary).toHaveBeenCalled(); }); - it("calls back", function () { + it("calls finish with the callback", function () { summaryFormatter.handleAfterFeaturesEvent(event, callback); - expect(callback).toHaveBeenCalled(); + expect(summaryFormatter.finish).toHaveBeenCalledWith(callback); }); });