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 -

  1. 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?
  2. the scope each of above covers -
    • i'm guessing before(:context) , before(:example) run once before each context block , individual example.
    • does before(:suite) run once before examples in give _spec file?
    • does each before(:xxx) block apply contexts , examples @ own nesting level , below?

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

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -