我是 Minitest 和 Apartment 的新手,很难正确配置环境以运行测试用例。我想使用 Capybara & Selenium 进行验收测试。当我运行测试时,我收到以下错误消息:
Apartment::TenantNotFound:         Apartment::TenantNotFound: One of the following schema(s) is invalid: "test-tenant" "public"
Run Code Online (Sandbox Code Playgroud)
所以似乎没有正确创建租户。Apartment gem 有关于如何将它与 Rspec 一起使用的说明,但我不知道如何在 Minitest 中进行类似的设置。应该如何定义租户,以便 Minitest 可以看到它们?
我的 test_helpers.rb:
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
require "minitest/rails/capybara"
Minitest::Reporters.use!
class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all
end
class ActionController::TestCase
  include Devise::TestHelpers
end
class ActionDispatch::IntegrationTest
end
Run Code Online (Sandbox Code Playgroud)
和测试用例:
require "test_helper"
class LoginTest < Capybara::Rails::TestCase
  def setup
    Apartment::Tenant.drop( "test-tenant" …Run Code Online (Sandbox Code Playgroud)