Before (: each) vs before before

I'm new to rubies on rails. And playing with testing

Is there a difference between

before(:each) do #some test code end 

and

 before do #some test code end 
+4
source share
1 answer

The before method accepts a scope parameter, which defaults to :each . When you leave this, it means what you mean :each , so your two examples do the same.

Here is a useful tidbit from RSpec RDoc, Module: RSpec :: Core :: Hooks # to :

Options:

  • scope (Symbol) - :each :all or :suite (default :each )
  • (Hash) - restricts this hook to examples matching these conditions, for example. before(:each, :ui => true) { ... } will only work with examples or groups declared with :ui => true .
+3
source

Source: https://habr.com/ru/post/1490829/


All Articles