0
Rspec 및 Shoulda와의 관계를 통해 has_many를 테스트하려고합니다.Shoulda Matcher와 has_many through : nil 클래스에 대한 정의되지 않은 메소드 class_name
# student.rb
has_many :presences
has_many :calls, through: :presences
# student_spec.rb
it { should have_many(:presences) }
it { should have_many(:calls).through(:presences) }
#presence.rb
belongs_to :call
belongs_to :student
#presence_spec.rb
it { should belong_to(:call) }
it { should belong_to(:student) }
#call.rb
has_many :presences
has_many :students, through: :presences
#call_spec.rb
it { should have_many(:presences) }
it { should have_many(:students).through(:presences) }
만이 시험의 마지막 반환, 실패
NoMethodError:
undefined method `class_name' for nil:NilClass
Did you mean? class_eval
내가
this issue을 찾았지만, 제안 된 솔루션은 나에게 도움이되지 않습니다.