Re:BDD with RSpec and Steak (via a real example)
by sleight42 on Sunday December 12, 2010 @09:36PM
(#1999003)
The only problem that I see with this is the same that I see with vanilla RSpec or shoulda: state is accumulated through nested blocks.
This is why I tend to prefer the Given-When-Then style with reusable "macros" (class methods) that provide niceties such as "given_a :user", "when_i_visit root_path", etc.
Assuming that you are writing automated acceptance test, any test of more than trivial length would then be nested several levels deep.
Re:BDD with RSpec and Steak (via a real example)
by ludicast on Monday December 13, 2010 @12:31AM
(#1999465)
That's a reasonable argument but doesn't bother me because
1) I don't like the given/when/then syntax anymore (a personal thing, but I do see the advantages (Uncle Bob has a great article about it))
2) I don't mind the nesting as long as each context is making explicit what it does.
Of course it's a "different strokes" thing. I could see this not fitting in with everybody's style but for me it has DRYed up the parts of a test that should be DRY (imho).
https://github.com/ludicast/saki
It lets you write your specs with "smart contexts" so you can do stuff like:
or I'm obviously biased, but I think this sort of testing kicks ass. I initially wrote them as extensions to Steak, but then ripped them out to use with vanilla rspec.