Jim Drannbauer home resume

Cucumber, Spork, Textmate, DRb::DRbUnknown

22 Feb 2011

I like using ⌘r and ⌘^r for running my features within Textmate. I also like using Spork. The problem is, they don’t play nice together out of the box. Here’s how I fixed that.

There are basically two problems.


The first one is this runtime error:

<runtimeerror: all but one formatter must use --out, only can print to each stream (or stdout)>

I noticed it in the output displayed in the “Run Feature” window. It was obscured because the angle brackets made it look like markup so all I saw was this:

  Exception encountered: # backtrace

When I inspected the output, I saw the runtime error.

It has to do with the std_opts in the generated cucumber.yml file. Textmate wants html format but the default profile uses another format. So, Textmate tries to use both. I fixed it by adding this textmate-specific profile to cucumber.yml:

textmate: --drb --format html

Then I went to Preferences > Advanced > Shell Variables and added: “TM_CUCUMBER_OPTS –profile textmate”.

That done, ⌘r and ⌘^r worked again. But there was still one more problem.

Given #, When #, Then #

Even though it worked, the output was wrong. It looked like this:

  Given #
  When #
  Then #

When I inspected the output in the “Run Feature” window, I saw this:


Once again, the angle brackets made it look like markup so the problem was obscured.

I found a fix here.

That was reported in September but never fixed (as far as I can tell). No biggie, monkey-patch to the rescue. Following the suggestion behind the link, I wrapped the patch in a Before block and placed it in features/support/textmate_spork_fix.rb:

Before do
  class Cucumber::Formatter::Html
    def h(s)
      s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }

Works like a charm.

blog comments powered by Disqus