You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
709 B

  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