Closed jetaggart closed 11 years ago
See https://github.com/jimweirich/rspec-given/pull/1 for a discussion of this issue.
After that discussion, I did add And to the GIven/When/Then lexicon, but its not a synonym, it has its own semantics (similar to Then, but without rerunning the setup code).
That makes a lot of sense.
One question though. In the case of the acceptance test, the subsequent Given's/When's MUST be run in order (top down). Is there any reason to introduce it for order dependent Given's and When's?
Or would you prefer this style over the previous example?:
Given do
admin_logged_in
visit admin_dashboard_page
end
Non-lazy Givens will run in order from first to last, outermost to innermost scope. After the non-lazy Givens, the Whens will be run in the same order. This is guaranteed by the framework.
Maybe I'm not understanding the question.
Your comment sounds like the order is not guaranteed:
"(1) And implies sequential processing or some kind of ordering. The lazy givens can actually be executed in any order."
In my case, I want that sequential processing. Your last response answered my question.
I'm just trying to figure out the best way to use rspec-given :) Thanks for the responses.
This https://github.com/jimweirich/rspec-given#execution-ordering gives the details on order guarantees.
I've been using rpsec-given in capybara acceptance tests. I find myself doing something like this:
I find myself wanting to do:
I know I can use
do; end
blocks, but I find this much nicer to read.Is adding support for Given -> And, When -> And worth it? Or am I missing the point?