Why Cucumber hook methods aren't lowercase?
Question
Cucumber has a few different hook methods like Before, After or AfterStep.
I was wondering - why doesn't these method names follow Ruby's naming conventions to write method names all lowercase?
Thanks.
Solution
- The
Before
,After
,AfterStep
,World
etc. Ruby hooks are uppercase because theGiven
,When
,Then
Ruby hooks are uppercase. - The
Given
,When
,Then
Ruby hooks are uppercase because theGiven
,When
,Then
Gherkin keywords are uppercase. - The
Given
,When
,Then
Gherkin keywords are uppercase because the Gherkin language is intended to match the standard template for BDD User Stories.
OTHER TIPS
This is merely speculation on my part but I guess the hook methods' names are camel-cased to match Then
, When
, and Given
methods which are used to define steps:
Then "I should be served coffee" do
@machine.dispensed_drink.should == "coffee"
end
Step definition methods' names are in turn camel-cased to match the way scenarios look:
Scenario: Buy last coffee
Given there are 1 coffees left in the machine
And I have deposited 1$
When I press the coffee button
Then I should be served a coffee
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow