ruby on rails - Confusion between the RSpec before/after hooks -
i've been working rspec 3 few days , realized don't understand before/after hooks provided.
my confusion in 2 areas -
- the various hook parameters available -
:suite,:context,:example,:all,:each(am missing any?). first 3 appear new, i've ever seen last two. last 2 deprecated , replace others? - the scope each of above covers -
- i'm guessing
before(:context),before(:example)run once before eachcontextblock , individual example. - does
before(:suite)run once before examples in give_specfile? - does each
before(:xxx)block apply contexts , examples @ own nesting level , below?
- i'm guessing
thanks!
per documentation, :context , :example aliased :all , :each in rspec3.
note: :example , :context scopes available :each , :all, respectively. use whichever prefer.
the before :suite scope executed first , :context , :example scopes:
before :suite before :context before :example after :example after :context after :suite beyond that, i'd recommend reading documentation, includes working examples of specific testing scenarios.
Comments
Post a Comment