I am wondering whether the before
(as seen below) is the same as before :all
in RSpec. Sometimes neither :each
nor :all
is specified and it confuses me as to what before
actually does.
require 'spec_helper'
describe "this is a description" do
before do # vs. before :all or before :each
# do something...
end
end
Would appreciate if anyone can explain the differences, if any. Thanks!
So the answer is No. before
is equivalent to before :each
, not before :all
Update: Wow, this question is popular. To save your head from cognitive overload, I suggest you explicitly state :each
or :all
.