Open ronen opened 9 years ago
In rspec-given@1.x, this was not encouraged but worked perfectly well because there was no interplay between the given/when/then methods.
In 2.x there may be subtle problems depending on what is combined, particularly in cases where a before
or let
raises error and is in turn only invoked by a Then
. But honestly, the nuance needed to keep them working is mostly wasted as long as folks keep the given and traditional DSLs to mostly-separate contexts (which works fine)
Oh, your response beat me to it -- i was just about to close this and repost on the new repo. WIll continue discussing here...
as long as folks keep the given and traditional DSLs to mostly-separate contexts (which works fine)
So should the README have a short section such as:
## Combining Given/When/Then with the traditional before/let/it DSL
Given/When/Then clauses and traditional rspec DSL blocks can coexist in the same suite,
as long they are in separate contexts, without any shared `before(:each)` or `let` blocks.
Shared `before(:all)` and `before(:suite)` blocks are fine and will apply normally.
Is that last sentence true?
I waffle on whether it's worth addressing in that light in the README. :+meh: for now
Clearly not a huge deal. But I'd lean towards including something like it for two reasons:
before(:all)
will work in a context that has Given/When/Then in it.I think the latter is a compelling point we need to make, but I'm wary of saying it loudly and proudly until we really understand the constraints on the former
Oh... I thought it was just me who didn't understand :) In that light, yeah I'd agree hold off proclaiming anything that ain't necessarily so.
I've found that depending on what I'm testing in some cases I might prefer the traditional rspec
context
/it
flow, and in other casesGiven/When/Then
flow. Or I might want to gradually migrate a file full of tests from one to the other, so while in transition the file might have some of each kind.It would be nice if the README could document whether & how it's OK to do something like:
That seems like it would work (and I think it does), but things seems like they'd get messy if there was a
Given
nested inside a context with abefore
or vice versa. (Or maybe there's a well-defined way in which it can work?) Though I imaginebefore(:suite)
hooks wouldn't be a problem.Anyway, WBN for rspec-given to take a firm stand on what's expected to work.