Variables and Feature classes

34 views
Skip to first unread message

iain

unread,
Feb 25, 2012, 5:24:24 PM2/25/12
to spina...@googlegroups.com
Hi,

I like what Spinach is trying to do but I have some minor requests to implement. I like to implement them for you, but I'd like to ask if you guys like it before I go ahead and waste time on it :)

My first feature would be to implement capturable values in steps, much like Jonas Nicklas' Turnip.

A step definition would look like:

Then "the apple should reach the ground after :count seconds" do |count|
  # ....
end

Jonas does some awesome things, like "there is/are :count monster(s)"

This would mean that instead of using define_method to make the steps, you'd need to store the steps inside a hash/lookup table.


The second feature I propose is a shortcut:

Instead of doing this:

class GravitySteps < Spinach::FeatureSteps
  feature 'Gravity' # I had to rename the class because it conflicts with a module in my application
end

I'd do this:

Spinach.feature "Gravity" do
end

It'd still be a class, but without a real name, similar to how RSpec works.


What's your opinion on these features?

Josep Jaume

unread,
Feb 29, 2012, 10:07:33 AM2/29/12
to spina...@googlegroups.com
Hi Iain,

Sorry for coming back to you so late!

Here are my thoughts:

Regarding the arguments in the steps, I think that if you find yourself in the need of using them, you should think twice wether this test should be in a lower abstraction layer (unit, for example). So if you have "with 1 element", "with 2 elements", "with 0 elements", you should probably try to test that in another place and write you integration tests with "with some elements" and "with no elements" - always in the happy path. It's quite more legible than using numbers. The goal is to have as little integration tests as possible while maximizing the value of each of them.

What do you think about that?

The syntax sugar improvement you propose was actually in spinach's codebase a long time ago but we decided to remove it:


We believe that while it's kinda more verbose, it exposes a more comprehensible ruby object - and that encourages you to use the constructs you would normally use like composition, including modules, inheritance maybe... The feature name isn't something that's gonna change often and mantaining two lines of code shouldn't be such a burden :)

What is your position in all this? Makes sense?

Thanks!

Iain Hecker

unread,
Feb 29, 2012, 2:38:10 PM2/29/12
to spina...@googlegroups.com
Hi Josep,

Those arguments are totally convincing. Thanks for clarifying them. I think that not having variables in step definitions makes sense, at least for most application. I am currently writing a physics library, in which passing in some numbers might make more sense, but I can live with this.

I have been rewriting some Cucumber features into Spinach for a pet project and it takes a moment to get out of the Cucumber mindset.

Thanks again for the great work!


-- iain
Reply all
Reply to author
Forward
0 new messages