RSpec: What is the difference between let and a before block?

What is difference between let and a before block in RSpec?

And when to use each?

What will be good approach (let or before) in below example?

let(:user) { User.make !}
let(:account) {user.account.make!}

before(:each) do
 @user = User.make!
 @account = @user.account.make!
end

I studied this stackoverflow post

But is it good to define let for association stuff like above?

87
задан Community 23 May 2017 в 12:34
поделиться