Note that there are some explanatory texts on larger screens.

plurals
  1. PORspec cannot find examples, when wrapped in PHP exec() call
    text
    copied!<p>The goal here is to execute a ruby script (with rake.invoke), within a PHP 'exec' command.</p> <p>I have a working rspec configuration, that executes cleanly (here is the headless rake task eg, but note that it works both headless and 'headed' for the below example)</p> <pre><code>FILE=./../tools/wr_audit_dom.rb WR_DEBUG=1 bundle exec rake local:headless </code></pre> <p>I invoke this rake target and other logic in a ruby file, like this:</p> <pre><code>Rake.application.init Rake.application.load_rakefile Rake.application['local:headless'].reenable Rake.application['local:headless'].invoke &gt; ruby dom_audit_parser.rb (this runs as expected) </code></pre> <p>Everything above executes fine, my tests run and i get my results.</p> <p>HOWEVER, I'd like to execute the ruby script through PHP, so i have the following code to 'exec' the command:</p> <pre><code>$cmd = 'cd &lt;_projectdirectory_snipped_&gt;; ruby dom_audit_parser.rb'; exec($cmd, $results); </code></pre> <p>PROBLEM: It returns no examples run, as if it cannot find them.</p> <p>BUT, I can run the same command (copied from the exec cmd in php) directly in the terminal with all examples being run. Can anyone tell me what could be wrong? </p> <p>The command below shows that the file is being specified and found, no examples are skipped, but nothing is found.</p> <p><strong>output from PHP 'exec' command</strong></p> <pre><code>/usr/bin/ruby1.9.1 -S rspec dom_audit_webdriver_spec.rb -f documentation --color Run options: include {:local=&gt;true} Finished in 0.00017 seconds 0 examples, 0 failures </code></pre> <p><strong>output from running the ruby command directly in a terminal</strong></p> <pre><code>/usr/bin/ruby1.9.1 -S rspec dom_audit_webdriver_spec.rb -f documentation --color Run options: include {:local=&gt;true} Inspect the webpage to scrape the DOM object -- [LOCAL] Starting firefox : [2013-10-09 16:19:10 -0400] Logging in [2013-10-09 16:19:10 -0400] Opening webpage ..... SNIP -- [LOCAL] quit firefox should find the dom object for the html node Finished in 2 minutes 0.2 seconds 1 example, 0 failures </code></pre> <p>Note that I've tried adding the code to a spec directory and not specifiying the file directly. It finds the file the 'rspec spec' way, but the same issue is observed.</p> <pre><code>├── config.yaml ├── dom_audit_parser.rb ├── dom_audit_portal.php ├── dom_audit_webdriver.rb ├── Rakefile </code></pre> <p>Thank you in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload