poll_validator_spec.rb 709 B

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe PollValidator, type: :validator do
  4. describe '#validate' do
  5. before do
  6. validator.validate(poll)
  7. end
  8. let(:validator) { described_class.new }
  9. let(:poll) { double(options: options, expires_at: expires_at, errors: errors) }
  10. let(:errors) { double(add: nil) }
  11. let(:options) { %w(foo bar) }
  12. let(:expires_at) { 1.day.from_now }
  13. it 'have no errors' do
  14. expect(errors).not_to have_received(:add)
  15. end
  16. context 'expires just 5 min ago' do
  17. let(:expires_at) { 5.minutes.from_now }
  18. it 'not calls errors add' do
  19. expect(errors).not_to have_received(:add)
  20. end
  21. end
  22. end
  23. end