Skip to content

Instantly share code, notes, and snippets.

@chobie
Created February 11, 2014 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chobie/8936124 to your computer and use it in GitHub Desktop.
Save chobie/8936124 to your computer and use it in GitHub Desktop.
add ability to specify bootstrap file
diff --git a/src/PhpSpec/Console/Command/RunCommand.php b/src/PhpSpec/Console/Command/RunCommand.php
index ca4a61e..64319d3 100644
--- a/src/PhpSpec/Console/Command/RunCommand.php
+++ b/src/PhpSpec/Console/Command/RunCommand.php
@@ -33,6 +33,7 @@ class RunCommand extends Command
new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Formatter'),
new InputOption('stop-on-failure', null , InputOption::VALUE_NONE, 'Stop on failure'),
new InputOption('no-code-generation', null , InputOption::VALUE_NONE, 'Do not prompt for missing method/class generation'),
+ new InputOption('bootstrap', "b", InputOption::VALUE_OPTIONAL, 'bootstrap file', "SpecHelper.php"),
))
->setDescription('Runs specifications')
->setHelp(<<<EOF
@@ -83,6 +84,11 @@ EOF
protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getApplication()->getContainer();
+ $bootstrap_file = getcwd() . DIRECTORY_SEPARATOR . $input->getOption("bootstrap");
+ if (is_file($bootstrap_file)) {
+ require $bootstrap_file;
+ }
+
$container->setParam('formatter.name',
$input->getOption('format') ?: $container->getParam('formatter.name')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment