adds answer spec

This commit is contained in:
Juanjo Bazán
2017-01-25 13:04:26 +01:00
parent 5806d86e33
commit 8d8d822323

View File

@@ -0,0 +1,16 @@
require 'rails_helper'
describe Poll::Answer do
describe "validations" do
it "validates that the answers are included in the Poll::Question's list" do
q = create(:poll_question, valid_answers: 'One, Two, Three')
expect(build(:poll_answer, question: q, answer: 'One')).to be_valid
expect(build(:poll_answer, question: q, answer: 'Two')).to be_valid
expect(build(:poll_answer, question: q, answer: 'Three')).to be_valid
expect(build(:poll_answer, question: q, answer: 'Four')).to_not be_valid
end
end
end