Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Add src-path option to run command
  • Loading branch information...
commit c6140c098d79a4ed10eba2411817a32f72d4a367 2 parents 4eb7539 + c632ad1
@MarcelloDuarte MarcelloDuarte authored
View
7 src/PHPSpec2/Console/Command/RunCommand.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));
}
}
View
10 src/PHPSpec2/Listener/ClassNotFoundListener.php
@@ -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()
Please sign in to comment.
Something went wrong with that request. Please try again.