Sep 4, 2017

minitestでログイン後のテストをする

なんかこれすげえ詰まった・・・。 ./test/test_helper.rb ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' module ActiveSupport class TestCase DatabaseCleaner.strategy = :transaction setup do DatabaseCleaner.start end teardown do DatabaseCleaner.clean logout end end end def integration_test? defined?(post) end def login(user) return unless integration_test? post session_url, params: { session: { email: user.email, password: "12345678" } } end def logout return unless integration_test?