Skip to content

Commit

Permalink
Merge pull request #10 from malukenho/bugfix/#3-use-default-unit-line…
Browse files Browse the repository at this point in the history
…-end

Fix 2 new line when feature has no description
  • Loading branch information
Jefersson Nathan committed Mar 31, 2016
2 parents 1ce8598 + e07de2d commit eb70f7b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/Command/FixGherkinCodeStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$directory = $input->getArgument('directory');
$finder = (new FeatureResolve($directory))->__invoke();

$output->writeln('');
$output->writeln('Finding files on <info>' . $directory . '</info>');
$output->writeln('');
$output->writeln("\nFinding files on <info>" . $directory . "</info>\n");

$tagFormatter = new Tags();
$featureDescription = new FeatureDescription();
Expand All @@ -111,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$filePointer = $file->openFile('w');
$filePointer->fwrite($formatted);

$output->writeln('<info>' . $file->getRealpath() . '</info>');
$output->writeln('<info>' . $file->getRealPath() . '</info>');
}
}
}
9 changes: 7 additions & 2 deletions src/Formatter/FeatureDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ final class FeatureDescription extends AbstractFormatter
*/
public function format(FeatureNode $feature)
{
$shortDesc = $feature->getKeyword() . ': ' . $feature->getTitle() . "\n";
$longDesc = implode(
$shortDesc = $feature->getKeyword() . ': ' . $feature->getTitle() . "\n";

if (! $feature->hasDescription()) {
return rtrim($shortDesc);
}

$longDesc = implode(
array_map(
function ($descriptionLine) {
return $this->indent() . trim($descriptionLine) . "\n";
Expand Down
8 changes: 8 additions & 0 deletions tests/Command/CheckGherkinCodeStyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public function testShouldReturnErrorIfThereIsFilesWithWrongStyle()
->method('hasTags')
->willReturn(true);

$feature->expects(self::once())
->method('getKeyword')
->willReturn('Feature');

$feature->expects(self::once())
->method('getTags')
->willReturn(
Expand All @@ -92,6 +96,10 @@ public function testShouldReturnErrorIfThereIsFilesWithWrongStyle()
'User registration'
);

$feature->expects(self::once())
->method('hasDescription')
->willReturn(true);

$feature->expects(self::once())
->method('getDescription')
->willReturn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Wrong style: %A/tests/assets/issue-3.feature
- | de | Herzlich Willkommen %USERNAME%. |
- | ar | مرحبا %USERNAME% |
- | ja | ようこそ %USERNAME% |
+
+ Scenario Outline:
+ When I navigate in <locale> language
+ Then I should see "<message>"
Expand Down

0 comments on commit eb70f7b

Please sign in to comment.