SimonRice / middleman-rspec

A very simple example of using RSpec & Capybara with Middleman
Other
26 stars 3 forks source link

Disable external_pipeline during tests? #7

Closed joshukraine closed 8 years ago

joshukraine commented 8 years ago

I'm using Gulp in conjunction with Middleman 4's external_pipeline feature. I've set up my spec_helper file as shown in the middleman-rspec example. However, when I run my tests, npm (Gulp) blows up, presumably because it's trying to run a server at the same time as Capybara. Here is my output:

~/Sites/cmoproject.org 95af916 [master]
% bin/rspec spec
== Preferring use of LibSass
== Executing: `npm run gulp`
WARN: tilt autoloading 'less' in a non thread-safe way; explicit require 'less' suggested.
WARN: tilt autoloading 'csv' in a non thread-safe way; explicit require 'csv' suggested.
WARN: tilt autoloading 'builder' in a non thread-safe way; explicit require 'builder' suggested.
WARN: tilt autoloading 'markaby' in a non thread-safe way; explicit require 'markaby' suggested.
WARN: tilt autoloading 'liquid' in a non thread-safe way; explicit require 'liquid' suggested.
WARN: tilt autoloading 'radius' in a non thread-safe way; explicit require 'radius' suggested.
WARN: tilt autoloading 'redcarpet' in a non thread-safe way; explicit require 'redcarpet' suggested.
WARN: tilt autoloading 'rdiscount' in a non thread-safe way; explicit require 'rdiscount' suggested.
WARN: tilt autoloading 'rdiscount' in a non thread-safe way; explicit require 'rdiscount' suggested.
WARN: tilt autoloading 'bluecloth' in a non thread-safe way; explicit require 'bluecloth' suggested.
WARN: tilt autoloading 'kramdown' in a non thread-safe way; explicit require 'kramdown' suggested.
WARN: tilt autoloading 'redcloth' in a non thread-safe way; explicit require 'redcloth' suggested.
WARN: tilt autoloading 'rdoc' in a non thread-safe way; explicit require 'rdoc' suggested.
WARN: tilt autoloading 'rdoc/markup' in a non thread-safe way; explicit require 'rdoc/markup' suggested.
WARN: tilt autoloading 'rdoc/markup/to_html' in a non thread-safe way; explicit require 'rdoc/markup/to_html' suggested.
WARN: tilt autoloading 'wikicloth' in a non thread-safe way; explicit require 'wikicloth' suggested.
WARN: tilt autoloading 'creole' in a non thread-safe way; explicit require 'creole' suggested.
WARN: tilt autoloading 'creole' in a non thread-safe way; explicit require 'creole' suggested.
WARN: tilt autoloading 'wikicloth' in a non thread-safe way; explicit require 'wikicloth' suggested.
WARN: tilt autoloading 'wikicloth' in a non thread-safe way; explicit require 'wikicloth' suggested.
WARN: tilt autoloading 'yajl' in a non thread-safe way; explicit require 'yajl' suggested.
WARN: tilt autoloading 'asciidoctor' in a non thread-safe way; explicit require 'asciidoctor' suggested.
WARN: tilt autoloading 'asciidoctor' in a non thread-safe way; explicit require 'asciidoctor' suggested.
WARN: tilt autoloading 'asciidoctor' in a non thread-safe way; explicit require 'asciidoctor' suggested.
== External: > cmoproject.org@1.1.0 gulp /Users/joshukraine/Sites/cmoproject.org
== External: > gulp
........

Finished in 0.11784 seconds (files took 2.91 seconds to load)
8 examples, 0 failures

~/Sites/cmoproject.org 95af916 [master]
% events.js:154                                                                              ruby 2.3.0p0
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at exports._errnoException (util.js:890:11)
    at WriteWrap.afterWrite (net.js:769:14)

npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node/5.10.0/bin/node" "/usr/local/bin/npm" "run" "gulp"
npm ERR! node v5.10.0
npm ERR! npm  v3.8.5
npm ERR! code ELIFECYCLE
npm ERR! cmoproject.org@1.1.0 gulp: `gulp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cmoproject.org@1.1.0 gulp script 'gulp'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the cmoproject.org package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gulp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs cmoproject.org
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls cmoproject.org
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/joshukraine/Sites/cmoproject.org/npm-debug.log

This is problematic, for example, when deploying via Travis CI as these errors will cause the build to fail. So my question: is there a way to tell Middleman not to run the external_pipeline during tests?

For reference, here is the repo for the site I'm deploying: https://github.com/joshukraine/cmoproject.org/blob/master/spec/spec_helper.rb

Also, in case it will help, the contents of the npm-debug log can be viewed here: https://gist.github.com/joshukraine/62a9e5a358c9ee73bf9728105342fe78

Thanks in advance for any assistance!

joshukraine commented 8 years ago

This issue can be resolved by limiting the external pipeline to run only in certain environments. Solution here: https://github.com/joshukraine/middleman-gulp/commit/4919e5295753a175c8551c3bf55b5137ebd621a0