ray rspec trước khi tất cả vs trước mỗi contest_entry_spec.rb
require 'spec_helper'
describe ContestEntry do
before(:all) do
@admission=Factory(:project_admission)
@project=Factory(:project_started, :project_type => @admission.project_type)
@creative=Factory(:approved_creative, :creative_category => @admission.creative_category)
@contest_entry=Factory(:contest_entry, :design_file_name => 'bla bla bla', :owner => @creative, :project => @project)
end
context 'non-specific tests' do
subject { @contest_entry }
it { should belong_to(:owner).class_name('User') }
it { should belong_to(:project) }
it { should have_many(:entry_comments) }
it { should validate_presence_of(:owner) }
it { should validate_presence_of(:project) }
it { should validate_presence_of(:entry_no) }
it { should validate_presence_of(:title) }
end
end
Khi tôi chạy các bài kiểm tra mọi thứ đều okey nhưng nếu tôi thay đổi trước (: tất cả) để trước (: mỗi) mỗi thử nghiệm sẽ được thất bại Tôi không biết tại sao nó lại xảy ra?
Đây là lỗi
Failure/Error: @contest_entry=Factory(:contest_entry, :design_file_name => 'bla bla bla', :owner => @creative, :project => @project)
ActiveRecord::RecordInvalid:
Validation Failed: User is not allowed for this type of project
Hãy cho tôi biết nếu bạn đặt câu hỏi về bất cứ điều gì. vui lòng giúp đỡ – fontno