[rspec-users] "config.before(:each)" is not run after "let!" ?
Patrick J. Collins
patrick at collinatorstudios.com
Thu Aug 2 22:29:19 UTC 2012
> let! adds a before hook and before hooks get run in the order they're
> declared, so just declare them in the other order:
>
> let!(:yo_momma) { create_yo_momma }
> config.before(:each) do
> ActionMailer::base.deliveries.clear
> end
Hmm.. The way that I usually work is that my "lets" are specific to a
spec...
# some_spec.rb
let!(:xyz) { "XYZ" }
# some_other_spec.rb
let!(:foo) { "foobar!" }
...
So, my goal is to not have to clutter my actual spec files with things
like ActionMailer::Base.deliveries.clear ... That's something that I
want to always assure is blank at the beginning of an example regardless
of the what spec file I am running.
I was hoping there was some way to change the order of hook execution,
and make the stuff in spec_helper happen last...
Patrick J. Collins
http://collinatorstudios.com
More information about the rspec-users
mailing list