Sha256: ae144e7ec04e7e340304d45761273cf12235b52b0d6b63bd0e55f449d2efc2a6
Contents?: true
Size: 1.26 KB
Versions: 18
Compression:
Stored size: 1.26 KB
Contents
require 'rails_helper' describe PgEngine::ErrorHelper do let(:dummy) { Class.new { include PgEngine::ErrorHelper }.new } describe '#error_message_for' do subject do categoria.validate dummy.error_message_for(categoria, associations: [:cosas]) end let!(:categoria) { create :categoria_de_cosa } before { create_list :cosa, 2, categoria_de_cosa: categoria } it do expect(subject).to be_nil end context 'cuando solo tiene errores de presencia' do before do categoria.nombre = nil end it do expect(subject).to eq :only_presence_errors end end context 'cuando solo tiene otros errores' do before do categoria.validate_aux = true end it do expect(subject).to eq :not_presence_errors end end context 'cuando tiene multiples errores' do before do categoria.validate_aux = true categoria.nombre = nil end it do expect(subject).to eq :multiple_error_types end end context 'cuando tiene errores anidados' do before do categoria.reload categoria.cosas[0].nombre = nil end it do expect(subject).to eq :only_presence_errors end end end end
Version data entries
18 entries across 18 versions & 1 rubygems