Jon Snow
Jon Snow

Reputation: 11882

What's the before block without the :each or :all parameter in Rspec?

I'm familiar with the Rspec's before blocks.

For example,

before(:each) do
  # some setup code before each test
end

and

before(:all) do
  # some setup code before all the tests
end

But I have seen

before do
  # some code
end

How is this before without any parameter different from before(:each) and before(:all)? If it's different, when is it executed?

Thank you.

Upvotes: 5

Views: 490

Answers (1)

jkeuhlen
jkeuhlen

Reputation: 4517

before do
  # some code
end

Is simply shorthand for

before(:each) do
  # some code
end

Upvotes: 7

Related Questions