无法在模块内部测试类[未初始化的常量] Rspec

时间:2019-09-05 06:51:32

标签: rspec-rails

这是我的身份验证文件:

module Command
  class AuthenticateUser
    prepend SimpleCommand
    ...
  end
end

然后我对此进行了测试:

require 'rails_helper'

RSpec.describe Command::AuthenticateUser do

 ...
end

运行测试时,出现此错误:

# --- Caused by: ---
# NameError:
#   uninitialized constant Command
#   ./spec/commands/authenticate_user_spec.rb:3:in `<top (required)>'

不确定我的代码在哪里,您能提出一些建议吗?

1 个答案:

答案 0 :(得分:0)

尝试一下:

class AuthenticateUser

    prepend SimpleCommand
    ...
end

require 'rails_helper'

    describe AuthenticateUser do
    ...
end