[rspec-users] Given/When/Then blocks on Cucumber
joe at josephwilk.net
Fri Jun 5 17:03:33 EDT 2009
Maurício Linhares wrote:
> Hello guys,
> I've been looking at Pyccuracy and found the "Given/Then/When" blocks
> to be very interesting and easier to understand and write, specially
> when writting scenarios with more than one of those. An example can be
> found here: http://www.pyccuracy.org/getting_started_3.html
> Here's how they do:
> Scenario 1 - Searching for Hello World
> I go to "http://www.google.com"
> I fill "q" textbox with "Hello World"
> And I click "btnG" button
> I see "Hello World - Google Search" title
> And here's how we would do with Cucumber
> Scenario: Searching for Hello World
> Given I go to "http://www.google.com"
> When I fill "q" textbox with "Hello World"
> When I click "btnG" button
> Then I see "Hello World - Google Search" title
> With cucumber we need to repeat the When's, Then's and Given's if
> there's more than one, woudn't it be nice to avoid this?
We don't have to repeat ourselves in Cucumber:
Scenario: Searching for Hello World
Given I go to "http://www.google.com"
When I fill "q" textbox with "Hello World"
And I click "btnG" button
Then I see "Hello World - Google Search" title
While the block idea is interesting the key thing for me is the scenario
reads like prose.
Also we have moved Cuke to its own mailing list, so please send any
Cucumber related questions there.
> Maurício Linhares
> http://alinhavado.wordpress.com/ (pt-br) |
> http://codeshooter.wordpress.com/ (en)
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users