为什么 spec 在模块中看不到 class?
Why spec does not see the class in the module?
我正在尝试测试我的应用程序,当我这样做时
spec/support/devise_models.rb
module DeviseModels
class UserWithCustomEncryption < User
protected
def password_digest(password)
password.reverse
end
end
end
spec/rails_helper.rb
RSpec.configure do |config|
config.include DeviseModels
...
当我调用我的规范时
UserWithCustomEncryption.new
shell 显示错误
NameError:
uninitialized constant UserWithCustomEncryption
当我将这个模块放在我的规范的顶部时,它的工作 well.how 修复了吗?
抱歉我的英语不好
因为它的命名空间,使用DeviseModels::UserWithCustomEncryption.new
我正在尝试测试我的应用程序,当我这样做时
spec/support/devise_models.rb
module DeviseModels
class UserWithCustomEncryption < User
protected
def password_digest(password)
password.reverse
end
end
end
spec/rails_helper.rb
RSpec.configure do |config|
config.include DeviseModels
...
当我调用我的规范时
UserWithCustomEncryption.new
shell 显示错误
NameError:
uninitialized constant UserWithCustomEncryption
当我将这个模块放在我的规范的顶部时,它的工作 well.how 修复了吗?
抱歉我的英语不好
因为它的命名空间,使用DeviseModels::UserWithCustomEncryption.new