Ruby on rails 小型测试测试错误的类
我是minitest的新手,过去我一直使用RSpec。我有一个问题,在删除一个对象后将其移动到另一个表中。所以我有两个类,一个是名称空间,另一个不是。有关代码中的说明,请参见下文。我在minitest中使用的其他一些宝石是minitest spec rails和shoulda。感谢您的帮助 user.rbRuby 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
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