Skip to content

Commit

Permalink
Fixed bug with pretty formatter output in scenario without a background
Browse files Browse the repository at this point in the history
  • Loading branch information
Johny Jose committed Dec 11, 2012
1 parent 9403fa5 commit 260b595
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/cucumber/listener/pretty_formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ var PrettyFormatter = function(options) {
self.handleBeforeScenarioEvent = function handleBeforeScenarioEvent(event, callback) {
var scenario = event.getPayloadItem('scenario');
var source = scenario.getKeyword() + ": " + scenario.getName();
currentMaxStepLength = scenario.getMaxStepLength() > scenario.getBackground().getMaxStepLength() ? scenario.getMaxStepLength() : scenario.getBackground().getMaxStepLength();
var lineLengths = [source.length, scenario.getMaxStepLength()];
if(scenario.getBackground() !== undefined) {
lineLengths.push(scenario.getBackground().getMaxStepLength());
}
lineLengths.sort(function(a,b) { return b-a; });
currentMaxStepLength = lineLengths[0];

source = self._pad(source, currentMaxStepLength + 3);

if(options['logToConsole'])
Expand Down
3 changes: 2 additions & 1 deletion spec/cucumber/listener/pretty_formatter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ describe("Cucumber.Listener.PrettyFormatter", function () {
beforeEach(function () {
keyword = "scenario-keyword";
name = "scenario-name";
backgroundStepLength = 30;
//Background step assumed to be the longest
backgroundStepLength = 40;
scenarioStepLength = 20;
line = 10
uri = "scenario-uri";
Expand Down

0 comments on commit 260b595

Please sign in to comment.