[rspec-users] Cucumber - Adding a step definition

Tim Hart THart at picagroup.com
Sat Mar 14 10:20:24 EDT 2009


On Mar 14, 2009, at 8:49 AM, "Aslak Hellesøy"  
<aslak.hellesoy at gmail.com> wrote:

>
>
> Den 14. mars. 2009 kl. 13.59 skrev Matt Wynne <matt at mattwynne.net>:
>
>>
>> On 13 Mar 2009, at 21:47, aslak hellesoy wrote:
>>
>>>
>>>
>>> On Fri, Mar 13, 2009 at 10:28 PM, Tim Hart <THart at picagroup.com>
>>> wrote:
>>> List,
>>>
>>> Quick question about Cucumber/Gherkin.
>>>
>>> I'm considering adding 'With' as a step definition to support
>>> scenarios like:
>>>
>>> Given a policy
>>> With a PCF practice state
>>> And a secondary risk
>>> ...
>>>
>>>
>>>
>>>
>>> Unfortunately, this only aliases the ruby methods (this will let
>>> you call With /some step/ do..end in a step definition ruby file.
>>> In order to make the plain text parser recognise other words, a
>>> change is needed in languages.yml.
>>>
>>> If you add a feature request in Lighthouse I'll see if I can add it.
>>
>> I'm not sure if I like this - dependency between steps seems like a
>> dodgy road to go down.
>>
>> When you're in a step definition, how would you know what object the
>> 'With' was referring to?
>>
>
> Good question Matt. Let's clarify this first. Maybe there is a better
> way to express this with the current language.
>>

As a test, I removed the 'add alias' line from my env.rb file, and  
updated languages.yaml. I updated the line that read

and: And

To read

and: And|With

Then my step_definition file can have a step definition like

Given /a PCF Practice state/ do ... end

Which I'd exactly what I was looking for.

My only concern I'd that I'd like to be able to add the 'With' to the  
language through code instead of having to update the yaml file. That  
way I have the option of varying the language for specific projects  
without having to 'polute' the basic language globally. I assumed this  
was what the 'add_alias' function would do for me in the first place. 
  
*****************************************************************************

Disclaimer: This electronic message may contain information that is Confidential or legally privileged. It is intended only for the use of the individual(s) and entity named in the message. If you are not an intended recipient of this message, please notify the sender immediately and delete the material from your computer. Do not deliver, distribute or copy this message and do not disclose its contents or take any action in reliance on the information it contains.

*****************************************************************************



More information about the rspec-users mailing list