I am new to ruby on rails. And playing around with testing
Is there a difference between
before(:each) do
#some test code
end
and
before do
#some test code
end
The before method accepts a scope parameter that defaults to :each. When you leave it out, it's implied that you mean :each, so your two examples do the exact same thing.
Here is a helpful tidbit from the RSpec RDoc, Module: RSpec::Core::Hooks#before:
Parameters:
- scope (Symbol) —
:each,:all, or:suite(defaults to:each)- conditions (Hash) — constrains this hook to examples matching these conditions e.g.
before(:each, :ui => true) { ... }will only run with examples or groups declared with:ui => true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With