trackabout/speceasy — pull request #2 by appakz (2013-05-22 19:22:53+00:00)
Title: Issue with calling nested given actions multiple times?

Noticed this (potential) issue when writing specs where the action invoked in Given calls was not idempotent (creating records in a database). Three levels of nested Given calls leading up to a Then resulted in the actions defined by the givens being called multiple times

For example, consider a test laid out like this:

When(something)
Given(given 1 action).Verify
Given(given 2 action).Verify
Given(given 3 action).Verify
Then(verify some expected state)

Given 1 action
Given 1 action (again) -> Given 2 action
Given 1 action (againt) -> Given 2 action (again) -> Given 3 action -> When -> Then

Should this be happening this way? I was under the impression that the setup actions defined by the givens wouldn't actually be invoked until a 'Then' was encountered. The pull request contains a failing test that illustrates what I mean.