Why spec does not see the class in the module?

47 views Asked by At

I trying to test my app, and when I do this

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
  ...

and when I call in my spec

UserWithCustomEncryption.new

shell show me an error

 NameError:
   uninitialized constant UserWithCustomEncryption

and when I include this module on the top in my spec, its work well.how fix?

sorry for my bad English

1

There are 1 answers

0
apneadiving On BEST ANSWER

Because its namespaced, use DeviseModels::UserWithCustomEncryption.new