Cucumber Quick Fix doesn't extract variables

I am using the Quick Fix feature (Alt-Enter) on a Step in a Scenario Outline in a Cucumber feature file to auto-create the Ruby step definition. The Step looks something like:

Given a driver: <name>, <address>, <phone_number>

When I use Quick Fix I get the following code:

Given /^a driver: <name>, <address>, <phone_number>$/ do
  pending
end

What I expected to see was:

Given /^a driver: (.*), (.*), (.*)$/ do | name, address, phone_number |
  pending
end

Is there a reason why Quick Fix doesn't audiomagically extract the variables? Am I missing a configuration setting somewhere?

Thanks!
Paul

4 comments
Comment actions Permalink

Hello Paul,

Good suggestion. At the moment our snippets generator behaves like cucumber gem. Although "<" and ">" looks like scenario outline and probably better to generate sections in "Examples" table. By the way
{code}
  Given a driver: "name", "address", "phone_number"
{code}
will generate step definition almost the same as you expect.

0
Comment actions Permalink

Thanks for the quick reply... your code snippet *almost* works... I changed it to:

    Given a driver: "<name>", "<address>", "<phone_number>"

Note the addition of the angle brackets. Without them, RubyMine correctly grays out the Examples section of the Scenario Outline as there are no valid parameters.

Thanks again. That works like a charm!

0
Comment actions Permalink

I hadn't thought of working in the other direction (start with a step definition and let Quick Fix generate the Step in the feature file

Oh, no. It seems we haven't understood each other. I don't suggest such direction =) I meant that angle brackets are usually used as parameters in scenarious outlines. Thus more reasonable implement a quickfix which generates a new column in Exmaples group for text in angle brackets or smth like this.

So Cucumber gets me closer, though it would be nice if it had used the feature parameter names as the argument names and not just generic arg1, arg2 and arg3.
If you used the same code that cucumber uses to provide code snippets it seems like Quick Fix should provide the same functionality, no?

Our quickfix is expected to generate the same snippet because at the moment we reuse snippet text generator provided by cucumber. As for more friendly args names - sound reasonable, please submit an issue. It seems we also do some redundant escaping for double quote and it is a bug.

Note the addition of the angle brackets. Without them, RubyMine correctly grays out the Examples section of the Scenario Outline as there are no valid parameters.


Yes, the are necessary according to Cucumber feature syntax

There are so many great features in RubyMine that are making it an excellent tool for QA to use with Cucumber!

Nice to hear it, thanks!

P.S: It seems that I accidentally deleted your previous post or may be you edited it.

0
Comment actions Permalink

Yes, I severely edited my post as I had gone off in an entirely wrong direction. Sorry about that! Once I actually followed the Cucumber directions things worked as expected.

Thanks again, for creating such an excellent Ruby/Rails/Cucumber/etc. IDE! :-D

0

Please sign in to leave a comment.