Permalink
Browse files

Merge pull request #69 from jdewit/feature/run-src-path

Add src-path option to run command
  • Loading branch information...
2 parents 4eb7539 + c632ad1 commit c6140c098d79a4ed10eba2411817a32f72d4a367 @MarcelloDuarte MarcelloDuarte committed Feb 8, 2013
Showing with 12 additions and 5 deletions.
  1. +4 −3 src/PHPSpec2/Console/Command/RunCommand.php
  2. +8 −2 src/PHPSpec2/Listener/ClassNotFoundListener.php
@@ -36,6 +36,7 @@ public function __construct(EventDispatcher $dispatcher)
$this->setDefinition(array(
new InputArgument('spec', InputArgument::OPTIONAL, 'Specs to run', 'spec'),
new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Formatter', 'progress'),
+ new InputOption('src-path', null, InputOption::VALUE_REQUIRED, 'Source path', 'src'),
));
}
@@ -57,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$specifications = $this->createLocator()->getSpecifications($input->getArgument('spec'));
$runner = $this->createRunner($matchers, $mocker, $unwrapper);
- $this->configureAdditionalListeners();
+ $this->configureAdditionalListeners($input->getOption('src-path'));
$this->dispatcher->dispatch('beforeSuite', new Event\SuiteEvent($collector));
$result = 0;
@@ -143,9 +144,9 @@ protected function createFormatter($format, Presenter\PresenterInterface $presen
return $formatter;
}
- protected function configureAdditionalListeners()
+ protected function configureAdditionalListeners($srcPath)
{
- $this->dispatcher->addSubscriber(new Listener\ClassNotFoundListener($this->io));
+ $this->dispatcher->addSubscriber(new Listener\ClassNotFoundListener($this->io, $srcPath));
$this->dispatcher->addSubscriber(new Listener\MethodNotFoundListener($this->io));
}
}
@@ -15,10 +15,16 @@ class ClassNotFoundListener implements EventSubscriberInterface
private $path;
private $proposedClasses = array();
- public function __construct(IO $io, $path = 'src')
+ public function __construct(IO $io, $path)
{
$this->io = $io;
- $this->path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
+
+ if ($path == '') {
+ $this->path = $path;
+ } else {
+ $this->path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
+ }
+
}
public static function getSubscribedEvents()

0 comments on commit c6140c0

Please sign in to comment.