wweare
wweare

Reputation: 241

Why spec does not see the class in the module?

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

Upvotes: 0

Views: 23

Answers (1)

apneadiving
apneadiving

Reputation: 115541

Because its namespaced, use DeviseModels::UserWithCustomEncryption.new

Upvotes: 1

Related Questions