如何将夹具加载到命名空间模型表中?

too*_*olz 5 ruby-on-rails minitest

我的模型是CWB::Account(它们是命名空间的,因为我继承了这个项目并且他们使用了一些保留字作为模型名称)

我正在使用minitest-spec-rails gem进行测试,我收到此错误 -

ActiveRecord::FxitureClassNotFound: No class attached to find.

测试/测试helper.rb

...

class ActiveSupport::TestCase
  fixtures :all
end
...
Run Code Online (Sandbox Code Playgroud)

测试/控制器/ sessions_controller_test.rb

require 'test_helper'

class SessionsControllerTest < ActionDispatch::IntegrationTest
  before do
    account_one = Accounts(:account_one)
    register(account_one)
  end
...
Run Code Online (Sandbox Code Playgroud)

测试/装置/ accounts.yml

account_one:
  id: 1
  name: testnameone
  email: one@gmail.com
  password_hash: passwordone
...
Run Code Online (Sandbox Code Playgroud)

如果我在test_helper.rb中执行此操作

set_fixture_class :accounts => 'CWB::Account'
fixtures :all
Run Code Online (Sandbox Code Playgroud)

我收到错误 - StandardError no fixture named <CWB::Account:0x0000004bdf32> found for fixture set 'accounts'

编辑

有趣的更新,如果我把account.yml放在fixtures/cwb/accounts.yml我得到一堆关于循环依赖的错误

但如果我把它放在夹具/ CWB/accounts.yml(注意大写)我得到一个错误说

undefined method accounts for ...

Bre*_*red 11

1)将您的夹具放在/test/fixtures/cwb/accounts.yml中

2)调用cwb_accounts(:account_one)来获取记录

require 'test_helper'

class SessionsControllerTest < ActionDispatch::IntegrationTest
  before do
    account_one = cwb_accounts(:account_one)
    register(account_one)
  end
...
Run Code Online (Sandbox Code Playgroud)