WatirMelon Spinach

Hello Spinach!

“Spinach is a new awesome BDD framework that features encapsulation and modularity of your step definitions.”

Seems like a good idea, so I thought I’d give it a try, and convert my existing simple Watirmelon Cucumber tests to use Spinach instead (link to my source code). It was very easy to do, here’s some observations:

  • It’s easy to get existing Cukes running using Spinach, but I imagine if you were starting out using Spinach you’d design things a lot differently
  • Steps belong in their own class, but you can include mixins to reuse steps – the ruby way
  • Steps are in a steps directory under features – shorter than step_definitions
  • Goodbye regular expressions in step definitions, which is a bit of a shame, as you can no longer capture values from the step name
  • As you can’t have regular expressions in step names, I find myself repeating steps that are similar but slightly different, this means my example steps have gone from 41 to 57 lines of code
  • Scenario Outlines aren’t supported at the moment, but I have raised this as a feature request
  • Hooks are dramatically improved, so I found them very easy to use and understand
  • There is no cucumber world, so you do a normal include instead, and env.rb is still supported
  • It displays really cool ticks on the command line when you’re running your spins

Well done to Codegram for releasing Spinach. If anything, it creates some great innovations that I imagine may find their way into Cucumber in the future.

Author: Alister Scott

Alister is an Excellence Wrangler for Automattic.

8 thoughts on “WatirMelon Spinach”

  1. Have you checked out CukeSalad? http://cukesalad.info

    It gives much of the benefits of step modularity, but still allows a good amount of flexibility in how your definitions are named. It’s also designed so that you can have multiple implementations for the way a feature is tested (for example, through the web interface, through the rich client, through the api)


  2. The inabiity to extract parameters from steps would seem to be a total non-starter to me.. For example how would you do a simple step like

    Given I have an account with a $50 balance

    and then not have to have tons of duplicate steps if you had other scenarios that wanted a different balance in the account to start with?


  3. Yep guys, agree. I also do not like the absence of step parametrization. Something strange as for me. I met the explanation of the spinach dev which explains why it absence but I do not agree with him


  4. Yep guys, I agree about step parametrization. Do not like the absence of this feature. I found the explanation of one of devs why it is absent but I do not agree with him


  5. I know I’m late to this article but, yeah, Spinach has so many little good things that put it above Cucumber in some ways, at least from a structural point of view. But the lack of choice, in terms of scenario outlines, tables, and even placeholders (if not regular expressions), makes Spinach a waste of time. I get why the developers have the opinions they do about the features, but any tool that removes so many choices from users is, to my way of thinking, shooting itself in the foot.


Comments are closed.