这是我的课程工厂,即 course.rb
FactoryGirl.define do
factory :lesson do |lesson|
lesson.sequence(:title) { |n| "title#{n}" }
lesson.sequence(:description) { |n| "description#{n}" }
lesson.sequence(:transcript) { |n| "transcript#{n}" }
association :course, strategy: :build
end
end
这是我的 course_spec.rb 文件
require 'spec_helper'
describe Lesson do
before { let(:lesson) { FactoryGirl.create(:lesson) } }
subject (:lesson)
it { should validate_presence_of :title }
end
有什么帮助吗?提前致谢!!!