#167 √ invalid
Kero

blocks provided to When/Then clauses should always be used

Reported by Kero | December 7th, 2007 @ 03:23 AM

When multiple When/Then clauses are given, with the same string and a block each, the blocks should be executed.

This is behaviour I'd expect (that's why I tried to specify multiple blocks), so I classified it as a bug. You may consider it a feature request instead.

NB: Ticket #165 seems to be lost, which I filed originally, but where I did not specify any tag?

Comments and changes to this ticket

  • David Chelimsky

    David Chelimsky December 7th, 2007 @ 04:07 AM

    • → State changed from “new” to “open”
    • → Assigned user changed from “” to “Dan North”

    That's actually as designed. Each block gets defined only once.

    Dan - WDYT?

  • Kero

    Kero December 7th, 2007 @ 02:29 PM

    I see, when you would specify twice, which one to use afterwards... Neither?

  • David Chelimsky

    David Chelimsky December 7th, 2007 @ 02:33 PM

    It uses the first definition and ignores any subsequent definitions. It always looks for a step definition and then uses it if it finds it. If it doesn't find one it creates one with the block you've supplied or, if no block is supplied, with a block that raises a PendingError.

  • Dan North

    Dan North December 7th, 2007 @ 05:58 PM

    I think it should fail with a DuplicateStepError or something. I want to know if I am trying to express the same intent (the step name) in two different ways. It almost certainly means that a) I forgot I already had one or b) the step name contains a hidden assumption that differs between the two cases.

    In the latter case I probably want to break out the assumption into a new Given.

    The one thing I don't want is for the same step name to mean different things at different times during the run. That way madness and ambiguity lies.

  • Kero

    Kero December 7th, 2007 @ 07:44 PM

    OK, I agree with the observations.

    My blocks set up something very similar, hence I used the same name.

    a DuplicateStepError would have told me why things were not happening as I expected.

    Now how would a test for that look like...

    (When "again" do end).should raise_error DuplicateStepError

    or something?

    Shall I submit a new ticket?

    (adapting this one seems not right.)

  • David Chelimsky

    David Chelimsky December 7th, 2007 @ 11:43 PM

    • → State changed from “open” to “resolved”

    A new ticket is fine. I'll go ahead and close this one now.

    Thanks.

  • David Chelimsky

    David Chelimsky December 7th, 2007 @ 11:43 PM

    • → State changed from “resolved” to “invalid”

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Behaviour Driven Development for Ruby.

Shared Ticket Bins

People watching this ticket

Attachments