views:

231

answers:

4

When i run cucumber it displays the possible steps that i should define, an example from the RSpec book:

1 scenario (1 undefined)
4 steps (4 undefined)
0m0.001s
You can implement step definitions for undefined steps with these snippets:
Given /^I am not yet playing$/ do
  pending
end
When /^I start a new game$/ do
  pending
end
Then /^the game should say “Welcome to CodeBreaker”$/ do
  pending
end
Then /^the game should say “Enter guess:”$/ do
  pending
end

Is there a way that it will automaticly create the step definitions file, so i don't have to rewrite or copy paste by hand but i can just to customize them to be more generic?

+1  A: 

Cucumber doesn't offer this feature. Probably because you would have to tell it where to put the step definitions file, and what to name it.

kevinrutherford
Thanks ;) but there could be some defaults.
j t
There is also convention to have features in features directory and steps in features/step_definitions
j t
+1  A: 

There is a possibility this kind of feature could be useful, but as Kevin says, it doesn't exist at present. But it could also get quite messy, quite quickly.

Maybe you already do this, but there's nothing stopping you cut and pasting the output direct into your text editor, or even piping the output direct to your text editor if you're so inclined. Then at least you're getting pretty much most of the way there, bar creating the file and naming.

Sam Murray-Sutton
+2  A: 

Like Kevin said, Cucumber would have to know the name of the file to put it in, and there are no good defaults to go with, other than using the same file name as the feature file. And that is something I consider an antipattern: http://wiki.github.com/aslakhellesoy/cucumber/feature-coupled-steps-antipattern

A: 

Intellij Idea or RubyIDE does exactly what you are asking for:

  • Detects missing step definitions
  • Creates missing step definitions in a new file (you choose the name of the file) or in one of the existing step definition files
  • Highlights matched step parameters

see http://i48.tinypic.com/10r63o4.gif for a step by step picture

Enjoy

dAni
Downvoted: Please add details at how this would be useful in relation to the question
Jesper Rønn-Jensen
more details added.
dAni