[rspec-users] [Cucumber] a few clarifications please...

Zach Dennis zach.dennis at gmail.com
Wed Dec 17 21:44:13 EST 2008


On Wed, Dec 17, 2008 at 8:30 PM, Steve Molitor <stevemolitor at gmail.com> wrote:
> What about two steps with the same regex but are of different types -- i.e.
> a Given and a Then with the same regexp?

They do the exact same thing. Given|When|Then is just a nicety for you
as the developer. Cucumber could care less. This is the code from
Cucumber:

    def Given(key, &proc)
      step_mother.register_step_proc(key, &proc)
    end

    def When(key, &proc)
      step_mother.register_step_proc(key, &proc)
    end

    def Then(key, &proc)
      step_mother.register_step_proc(key, &proc)
    end

> Steve
>
> On Wed, Dec 17, 2008 at 6:07 PM, aslak hellesoy <aslak.hellesoy at gmail.com>
> wrote:
>>
>>
>> On Wed, Dec 17, 2008 at 11:50 PM, Tim Walker <walketim at gmail.com> wrote:
>>>
>>> Great information guys, making some progress on this end. It is much
>>> appreciated.
>>>
>>> Discovered that step definitions can not be duplicated even across
>>> step files. Is this correct?
>>
>> Regexen can not be the same (even if the blocks are different). I just
>> refactored the wiki a little and added a new page about this:
>> http://github.com/aslakhellesoy/cucumber/wikis/step-definitions
>>
>> Aslak
>>
>>>
>>> Thanks again.
>>>
>>> Sincerely,
>>>
>>> Tim
>>>
>>> On Wed, Dec 17, 2008 at 2:39 PM, Joseph Wilk <josephwilk at joesniff.co.uk>
>>> wrote:
>>> > David Chelimsky wrote:
>>> >>
>>> >> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker <walketim at gmail.com>
>>> >> wrote:
>>> >>
>>> >>>
>>> >>> Hi Guys,
>>> >>>
>>> >>> Things are working great with Cucumber and am getting better at
>>> >>> expressing requirements as behaviors. Kudos!
>>> >>>
>>> >>> I seek a couple of points of clarification, or confirmation, if
>>> >>> someone has a minute or two...
>>> >>>
>>> >>> FWIW - I've read the wiki and the given-when-then page and just seek
>>> >>> confirmation:
>>> >>>
>>> >>> There is no dependency implied in the keywords "given", "then" and
>>> >>> "when" (as well as "and" and "but), correct? These are simply naming
>>> >>> conventions that denote the well known "Build/Operate/Check" pattern
>>> >>> but have no real physical relationship, they're just tags that denote
>>> >>> the steps.
>>> >>>
>>> >>
>>> >> Correct.
>>> >>
>>> >>
>>> >>>
>>> >>> A "pending" step is any step that has a matching step but nothing is
>>> >>> implemented.
>>> >>>
>>> >>
>>> >> Correct.
>>> >>
>>> >
>>> > In the latest version in Github (0.1.13) you can also force steps which
>>> > have
>>> > an implementation to the pending state using the 'pending' method which
>>> > works in the same way as Rspec's pending.
>>> >
>>> > When "I want to be lazy" do
>>> >  pending "Implement me!"
>>> > end
>>> >
>>> > --
>>> > Joseph Wilk
>>> > http://blog.josephwilk.net
>>> >
>>> >>
>>> >>>
>>> >>> A "successful" step is any step that is matched, has some code and
>>> >>> doesn't assert anything resolving to false.
>>> >>>
>>> >>
>>> >> Or raise an error.
>>> >>
>>> >>
>>> >>>
>>> >>> A "gray" out step means that no steps were found that matched the
>>> >>> feature.
>>> >>>
>>> >>
>>> >> Blue? Means that a step was found, but a previous step was either
>>> >> pending or failed.
>>> >>
>>> >>
>>> >>>
>>> >>> You need to be careful that features do not match steps in the step
>>> >>> file or cucumber will execute the first step it finds that matches
>>> >>> (really don't know how this works, will a test sequence ever go
>>> >>> 'backwards'?)
>>> >>>
>>> >>
>>> >> Cucumber tells you when it finds two steps definitions that could
>>> >> match the step in the feature.
>>> >>
>>> >>
>>> >>>
>>> >>> Going back and changing the stuff in the .feature file is risky as
>>> >>> it's very easy to create a mismatch and the step won't be found.
>>> >>>
>>> >>
>>> >> Not sure why that is risky, unless you mean that there are
>>> >> non-developers making these changes. If so, then they should probably
>>> >> be made collaboratively.
>>> >>
>>> >>
>>> >>>
>>> >>> Thanks very much,
>>> >>>
>>> >>> Tim
>>> >>> _______________________________________________
>>> >>> rspec-users mailing list
>>> >>> rspec-users at rubyforge.org
>>> >>> http://rubyforge.org/mailman/listinfo/rspec-users
>>> >>>
>>> >>>
>>> >>
>>> >> _______________________________________________
>>> >> rspec-users mailing list
>>> >> rspec-users at rubyforge.org
>>> >> http://rubyforge.org/mailman/listinfo/rspec-users
>>> >>
>>> >>
>>> >
>>> > _______________________________________________
>>> > rspec-users mailing list
>>> > rspec-users at rubyforge.org
>>> > http://rubyforge.org/mailman/listinfo/rspec-users
>>> >
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com


More information about the rspec-users mailing list