Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Option < ApplicationRecord
- has_many :quizzes
- has_many :some_questions, through: :quizzes
- end
- class Question < ApplicationRecord
- has_many :quizzes
- has_many :options, through: :quizzes
- end
- class Some::QuizQuestion < ApplicationRecord
- belongs_to :questions
- belongs_to :options
- end
- # question has many options through quiz
- FactoryGirl.define do
- factory :question do
- option "What color are your eyes"
- end
- end
- # option has many questions through quiz
- FactoryGirl.define do
- factory :option, class: 'Option' do
- option "blue"
- end
- end
- # JoinTable
- FactoryGirl.define do
- factory :quiz, class: 'Quiz' do
- option
- question
- end
- end
- FactoryGirl.define do
- sequence :question_text do |number|
- "Do you even #{number}?"
- end
- factory :question do
- question_text
- factory :question_with_options do
- transient do
- options_count 3
- end
- end
- after(:create) do |question, evaluator|
- create_list(:option, evaluator.options_count, questions: [question])
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement