adds specs for poll state

This commit is contained in:
rgarcia
2016-11-21 11:19:03 +01:00
parent a93a10b04d
commit 84bafa8107
3 changed files with 32 additions and 8 deletions

View File

@@ -14,5 +14,4 @@ class Poll::PartialResult < ActiveRecord::Base
scope :by_author, -> (author_id) { where(author_id: author_id) }
scope :by_question, -> (question_id) { where(question_id: question_id) }
end
end

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
describe Poll::PartialResult, type: :model do
describe Poll::PartialResult do
describe "validations" do
it "validates that the answers are included in the Enquiry's list" do

View File

@@ -4,13 +4,38 @@ describe :poll do
let(:poll) { build(:poll) }
it "should be valid" do
expect(poll).to be_valid
describe "validations" do
it "should be valid" do
expect(poll).to be_valid
end
it "should not be valid without a name" do
poll.name = nil
expect(poll).to_not be_valid
end
end
it "should not be valid without a name" do
poll.name = nil
expect(poll).to_not be_valid
describe "#opened?" do
it "returns true only when it isn't too early or too late" do
expect(create(:poll, :incoming)).to_not be_current
expect(create(:poll, :expired)).to_not be_current
expect(create(:poll)).to be_current
end
end
describe "#incoming?" do
it "returns true only when it is too early" do
expect(create(:poll, :incoming)).to be_incoming
expect(create(:poll, :expired)).to_not be_incoming
expect(create(:poll)).to_not be_incoming
end
end
describe "#expired?" do
it "returns true only when it is too late" do
expect(create(:poll, :incoming)).to_not be_expired
expect(create(:poll, :expired)).to be_expired
expect(create(:poll)).to_not be_expired
end
end
end