Rspec doesn't see my model Class. uninitialized constant error

后端 未结 7 1914
予麋鹿
予麋鹿 2021-01-30 19:09

I\'m writing tests on Rspec for my models in Ruby on Rails application. And I receive this error while starting \'rspec spec\'

command:
/spec/models/client_spec         


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-30 20:05

    Factories folder define in your app

    FactoryBot.define do
      factory :user_params , :class => 'User' do
        username 'Alagesan'
        password '$1234@..'
    
      end
    end
    

    Your Controller RSpec file:

    it 'valid params' do
      post :register, params: {:user => user_params } 
    end
    

提交回复
热议问题