6
나는이 쉬운 검증에 대해 머리를 터뜨 렸으며 유효성을 검사 할 수 없습니다.Rspec 및 FactoryGirl 수락 확인
describe "event has many attendances" do
it "should have attendances" do
event = FactoryGirl.create(:event)
user1 = FactoryGirl.create(:user, firstname: "user1", email: "[email protected]")
user2 = FactoryGirl.create(:user, firstname: "user2", email: "[email protected]")
attendance1 = FactoryGirl.create(:attendance, event: event, user: user1, terms_of_service: true)
end
end
이 오류를 가지고 있지만하지 않습니다한다 : 이것은 내 테스트입니다
factory :attendance do
user
event
terms_of_service true
end
: 이것은 내 공장
class Attendance < ActiveRecord::Base
belongs_to :user, counter_cache: true
belongs_to :event, counter_cache: true
validates :terms_of_service, :acceptance => true
end
이다 : 나는 다음과 같은 모델을 가지고 .
Running spec/models/workshop_spec.rb
.............F
Failures:
1) Event event has many attendances should have attendances
Failure/Error: attendance1 = FactoryGirl.create(:attendance, event: event, user: user1, terms_of_service: true)
ActiveRecord::RecordInvalid:
Validation failed: Terms of service must be accepted
# ./spec/models/event_spec.rb:33:in `block (3 levels) in <top (required)>'
브라우저에서 이러한 작업을 수행 할 때 모든 항목이 정상적으로 처리됩니다. 나는 무엇을 여기에서 놓치고 있냐?!
감사합니다. 나는 문자열을 제외한 모든 것을 시도했다. 감사합니다, 기록을 위해 그것은 사실상의 속성이었습니다! –
@dimuch 당신이 내 영웅이라는 것을 당신은 알고 있습니까? 감사. – Jeff