2015-06-09 13 views
0

我想測試我的應用程序,當我做到這一點爲什麼spec在模塊中看不到該類?

規格/支持/ devise_models.rb

module DeviseModels 
    class UserWithCustomEncryption < User 
    protected 
    def password_digest(password) 
     password.reverse 
    end 
    end 
end 

規格/ rails_helper.rb

RSpec.configure do |config| 
    config.include DeviseModels 
    ... 

,當我打電話給我spec

UserWithCustomEncryption.new 

shell向我顯示一個錯誤

NameError: 
    uninitialized constant UserWithCustomEncryption 

當我在我的規範中包含這個模塊的頂部,它的工作well.how修復?

對不起我的英語不好

回答

1

由於它的命名空間,使用DeviseModels::UserWithCustomEncryption.new

+0

笑:d,謝謝! – wweare

相關問題