Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 小型测试测试错误的类_Ruby On Rails_Ruby_Minitest_Shoulda - Fatal编程技术网

Ruby on rails 小型测试测试错误的类

Ruby on rails 小型测试测试错误的类,ruby-on-rails,ruby,minitest,shoulda,Ruby On Rails,Ruby,Minitest,Shoulda,我是minitest的新手,过去我一直使用RSpec。我有一个问题,在删除一个对象后将其移动到另一个表中。所以我有两个类,一个是名称空间,另一个不是。有关代码中的说明,请参见下文。我在minitest中使用的其他一些宝石是minitest spec rails和shoulda。感谢您的帮助 user.rb class User < ActiveRecord::Base self.table_name = 'users' end cache/user.rb module Cache

我是minitest的新手,过去我一直使用RSpec。我有一个问题,在删除一个对象后将其移动到另一个表中。所以我有两个类,一个是名称空间,另一个不是。有关代码中的说明,请参见下文。我在minitest中使用的其他一些宝石是minitest spec rails和shoulda。感谢您的帮助

user.rb

class User < ActiveRecord::Base
  self.table_name = 'users'
end
cache/user.rb

module Cache
  class User < ActiveRecord::Base
    self.table_name = 'cache_users'
  end
end
test/models/cache/user_test.rb

require 'test_helper'

module Cache
  class UserTest < ActiveSupport::TestCase
    #this tests User not Cache::User
  end
end

我找到了解决办法

class Cache::UserTest < ActiveSupport::TestCase
  @model = Cache::User #this tell what we're testing
end

你试过class Cache::UserTest