RORLabNew/rorla_api — pull request #70 by plaredspear (2014-04-03 09:50:10+00:00)
Title: Question Spec 추가

### 1. Question 사용하지 않는 FactoryGirl 제거 ###

- shoulda-matcher를 활용하였기에, answer를 추가하는 Question FactoryGirl 부분은 삭제함.

**spec/factories/questions.rb**

factory :question_with_answers do
ignore do
answers_count 1
end

after(:create) do |question, evaluator|
create_list(:answer, evaluator.answers_count, question: question)
end
end

### 2. Question : plaza 관계 추가 ###

- (post 모델과 동일하게) question 모델에 after_create filter로 plaza 생성.

**app/models/question.rb**

after_create :set_plaza_question
private
def set_plaza_question
self.create_plaza
end

- question 모델 spec에 spec 추가

**spec/models/question_spec.rb**

it "> has_one :plaza, dependent: :destroy" do
expect(create(:question)).to have_one(:plaza).dependent(:destroy)
end