Sha256: 88bbcd2d3244ac6812eb8d6e702e3da492ab1ec86b23bb6207f39f1ff0861d9d
Contents?: true
Size: 1.16 KB
Versions: 6
Compression:
Stored size: 1.16 KB
Contents
require 'spec_helper' describe SerialTranslator::SerialTranslatorPresenceValidator do let(:example) { Fake.new } describe 'validation' do it 'validates presence correctly if attribute is nil' do example.description = nil expect(example).to have(1).error_on(:description) end it 'validates presence correctly if attribute is empty' do example.description = '' expect(example).to have(1).error_on(:description) end it 'has no error if everything is fine' do example.description = 'This is a nice foo thing' expect(example).to have(:no).errors_on(:description) end it 'is valid if any language has a value' do example.description_translations = { en: '', de: '' } expect(example).to have(1).error_on(:description) example.description_translations = { en: '', de: 'foobar' } expect(example).to have(:no).errors_on(:description) example.description_translations = { en: 'foobar', de: nil } expect(example).to have(:no).errors_on(:description) end end it 'is of kind "presence"' do expect(described_class.new(attributes: %i(foo)).kind) .to eq :presence end end
Version data entries
6 entries across 6 versions & 1 rubygems