poll_validator_spec.rb 745 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe PollValidator do
  4. describe '#validate' do
  5. before do
  6. validator.validate(poll)
  7. end
  8. let(:validator) { described_class.new }
  9. let(:poll) { instance_double(Poll, options: options, expires_at: expires_at, errors: errors) }
  10. let(:errors) { instance_double(ActiveModel::Errors, 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).to_not have_received(:add)
  15. end
  16. context 'when expires is just 5 min ago' do
  17. let(:expires_at) { 5.minutes.from_now }
  18. it 'not calls errors add' do
  19. expect(errors).to_not have_received(:add)
  20. end
  21. end
  22. end
  23. end