/** * @param Resource $resource * @param string $filepath * * @return string */ protected function renderTemplate(Resource $resource, $filepath) { $values = array('%filepath%' => $filepath, '%name%' => $resource->getSpecName(), '%namespace%' => $resource->getSpecNamespace(), '%subject%' => $resource->getSrcClassname(), '%subject_class%' => $resource->getName()); if (!($content = $this->getTemplateRenderer()->render('specification', $values))) { $content = $this->getTemplateRenderer()->renderString($this->getTemplate(), $values); } return $content; }
function it_asks_confirmation_if_spec_already_exists($io, $tpl, $fs, Resource $resource) { $resource->getSpecName()->willReturn('AppSpec'); $resource->getSpecFilename()->willReturn('/project/spec/Acme/AppSpec.php'); $resource->getSpecNamespace()->willReturn('spec\\Acme'); $resource->getSrcClassname()->willReturn('Acme\\App'); $fs->pathExists('/project/spec/Acme/AppSpec.php')->willReturn(true); $io->askConfirmation(Argument::type('string'), false)->willReturn(false); $fs->putFileContents(Argument::cetera())->shouldNotBeCalled(); $this->generate($resource); }