I'm definitely not speaking as an authority on this, but I can tell you
from experience that the word (Given, When, Then) does not matter in the
_steps.rb files. I create absolutely all of mine using Given and have
had zero problems.
Peace,
Phillip
That is correct. If you are writing your steps with the intention for
them to behave differently based on what preposition is used, you are
writing steps that will become too confusing.
Tom.
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Ā Tom ten Thij
Ā Unboxed Consulting, http://unboxedconsulting.com
Ā T: +44 20 3137 2943 F: +44 20 7183 4251
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
On Thu, May 5, 2011 at 2:39 PM, Arve Knudsen <arve.k...@gmail.com> wrote:
> Hi
> Cucumber is registering or looking for Step Definitions.' I would think
> Given/When/Then are prepositions rather than adjectives/adverbs, but I guess
> that's what's referred to here?
> Anyway, if it is indeed correct that Cucumber disregards the preposition (or
> whatever you want to call it) upon the loading of step definitions, what's
> the rationale for this behaviour? For instance, if I write a Given step
> definition 'Given /^something$/ do', this'll also match 'Then something'. I
> just found out about this today and it utterly confused me (I happened to
> write a Then step definition with the same pattern as a Given step
> definition).
> Arve
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cukes" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to
> cukes+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cukes?hl=en.
>
use the Given/When/Then and Ands to make your scenarios read better in
the feature file. How they are implemented in the steps doesn't matter
(for example, reusing a prior "Then" from one scenario as an "And" in
another scenario).
The more logical you make your "methods" the easier it will be to reuse
them for subsequent scenarios. I often find myself writing less and less
step definitions as the feature scenarios for a given part of my
application grow over time. It is indeed a sweet thing.
I also find myself looking at some of my very first feature files and
throwing up a little at how stupid they look. So I refactor them :-)
jon
blog: http://technicaldebt.com
twitter: http://twitter.com/JonKernPA
Arve Knudsen said the following on 5/5/11 9:39 AM:
HiIs it correct that step definitions' prepositions (Given, When, Then) do not matter? The wiki says thatĀ 'The adjective/adverb hasĀ noĀ significance when Cucumber is registering or looking for Step Definitions.' I would think Given/When/Then are prepositions rather than adjectives/adverbs, but I guess that's what's referred to here?
Anyway, if it is indeed correct that Cucumber disregards the preposition (or whatever you want to call it) upon the loading of step definitions, what's the rationale for this behaviour? For instance, if I write a Given step definition 'Given /^something$/ do', this'll also match 'Then something'. I just found out about this today and it utterly confused me (I happened to write a Then step definition with the same pattern as a Given step definition).
On Thu, May 5, 2011 at 2:39 PM, Arve Knudsen <arve.k...@gmail.com> wrote:HiIs it correct that step definitions' prepositions (Given, When, Then) do not matter? The wiki says thatĀ 'The adjective/adverb hasĀ noĀ significance when Cucumber is registering or looking for Step Definitions.' I would think Given/When/Then are prepositions rather than adjectives/adverbs, but I guess that's what's referred to here?All dictionaries I have seen describe Given as an adjective and When/Then as adverbs (in the context they are used in Gherkin).A preposition is a word that says something about an object's position - for example On the sofa, Behind the desk etc.
ĀAnyway, if it is indeed correct that Cucumber disregards the preposition (or whatever you want to call it) upon the loading of step definitions, what's the rationale for this behaviour? For instance, if I write a Given step definition 'Given /^something$/ do', this'll also match 'Then something'. I just found out about this today and it utterly confused me (I happened to write a Then step definition with the same pattern as a Given step definition).The rationale of the decision is simplicity. Although not used a lot, all Gherkin adverb/adjectives are aliased with "* ", making it impossible to distinguish them if you say:* I have 4 cukes in my basket* I eat 1 cuke* I have 1 cukes in my belly
I also second what Tom says - this "limitation" is also there to protect you from accidentally ambiguous language.
All dictionaries I have seen describe Given as an adjective and When/Then as adverbs (in the context they are used in Gherkin).A preposition is a word that says something about an object's position - for example On the sofa, Behind the desk etc.Ā
On Thu, May 5, 2011 at 3:43 PM, Arve Knudsen <arve.k...@gmail.com> wrote:
On Thu, May 5, 2011 at 4:10 PM, aslak hellesoy <aslak.h...@gmail.com> wrote:All dictionaries I have seen describe Given as an adjective and When/Then as adverbs (in the context they are used in Gherkin).A preposition is a word that says something about an object's position - for example On the sofa, Behind the desk etc.ĀI stand corrected. UpdatedĀ https://github.com/aslakhellesoy/cucumber/wiki/Step-Definitions
FWIW, the New Oxford American Dictionary (the one which comes with OS
X) indicates that the usage of given in Cucumber steps IS a
preposition.
given |ĖgivÉn|
past participle of give .
adjective
1 specified or stated : our level of knowledge on any given subject.
2 [ predic. ] ( given to) inclined or disposed to : she was not
often given to anger.
3 conferred or bestowed as a gift : she squandered what was a given
opportunity.
4 archaic Law (of a document) signed and dated : given under my hand
this eleventh day of April.
preposition
taking into account : given the complexity of the task, they were
able to do a good job.
noun
a known or established fact or situation : at a couture house,
attentive service is a given.
And while some prepositions indicate positional relationships, the
word is more general than that:
preposition |ĖprepÉĖzi sh Én|
noun Grammar
a word governing, and usually preceding, a noun or pronoun and
expressing a relation to another word or element in the clause, as in
āthe man on the platform,ā āshe arrived after dinner,ā āwhat did you
do it for ?ā
The words when, then, 'and' and but as used in Gherkin are used as conjunctions.
--
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale