In RSpec you can use let!(:user) { User.create }
to eager load :user
variable so it gets created before entering test case. Is there equivalent method in ActiveSupport::TestCase
?
Since tests in TestCase
are basically ruby classes, you can always define instance variables to your test in the setup
method (which is the first thing executed in a test):
UserTest < ActiveSupport::TestCase
def setup
@user = User.create
end
test 'my user test' do
assert_not @user.nil?
end
end